Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need GP class as data model #7

Closed
whoburg opened this issue Jun 26, 2014 · 3 comments
Closed

need GP class as data model #7

whoburg opened this issue Jun 26, 2014 · 3 comments

Comments

@whoburg
Copy link
Collaborator

whoburg commented Jun 26, 2014

We need a class that represents a GP (or a 'GP constraint set', if we decide we don't want it to include an objective). This ticket is a placeholder to get some ideas down on paper -- it probably needs to be split into multiple sub-tickets as we flesh these issues out.

The GP class should support:

  • dict-indexing of variables, so that the column index of a variable can be looked up in O(1) time
  • dict-indexing of constraints (via names??), so that the row index of a constraint can be looked up in O(1) time
  • Fast re-solve for varying parameters, as enabled by indexing above.
  • Combining of multiple GP constraint sets into a single GP constraint set (with coupling via shared variable names)
  • Sparse matrix storage (scipy.sparse.coo_matrix) of the A matrix (cvxopt calls it F)

The data model (A, c, map) should probably match MOSEK instead of CVX, for efficiency once we get mosek working. And we presumably want ways of going back-and-forth while still supporting fast re-solve.

@whoburg whoburg changed the title need GP class as data model, as opposed to passing lists of posynomials to solvers need GP class as data model Jun 26, 2014
@bqpd
Copy link
Contributor

bqpd commented Jun 26, 2014

RE: 'matrix of exponents associated with each constant in each constraint'

I think the GP class should have a 'constants' attribute that it applies to its purely symbolic representation of the cost and constraints before solving, and an 'update' function. This would look something like:

GP = gpkit.GP(cost, slf+other_constraints, constants)
sol1 = GP.solve()['solution']
# change the constraints...
GP.update(constraints = new_constraints)
sol2 = GP.solve()['solution']  # also stored at GP.solution
# change the constants...
GP.update(constants = new_constants)
sol3 = GP.solve()['solution']
# change the cost function and merge with another GP
GP.update(new_cost, new_GP.constraints, new_GP.constants)
# the GP class will have automatically generated and efficiently kept up-to-date:
#    - a sparse A matrix (called F by CVXopt)
#    - a c vector (called g by CVXopt)
#    - a map vector for MOSEK
#    - a 'k' vector for CVXopt, because I can't see of a clean way to do without it
sol4 = GP.solve()['solution']

@whoburg
Copy link
Collaborator Author

whoburg commented Jun 30, 2014

yes, like everything we're outlining here.

@bqpd
Copy link
Contributor

bqpd commented Jun 30, 2014

I implemented it just as above except that GP.solve() does not return a dictionary, but the primal solution. Everything in the original request has been covered...

@bqpd bqpd closed this as completed Jun 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants