convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

Do automatic solution checking and validation #23

Closed whoburg closed 9 years ago

whoburg commented 10 years ago

Very low priority:

We could create GP.solution_check(self, sol). It would validate that a particular primal/dual solution pair solves the GP. Could be useful for sanity checks and trying out 'suspect' solution codes.

This is very very very low priority.

bqpd commented 10 years ago

Partway there!

bqpd commented 9 years ago

Currently validates primal feasibility, and that the sensitivities of free variables are close to 0.

whoburg commented 9 years ago

Todo: (optional) we could evaluate both the primal and dual objective functions and make sure that they match. I can do this and/or explain how.

bqpd commented 9 years ago

That would be great! I'm happy to implement it.

whoburg commented 9 years ago

To implement -- gpkit.GP.__run_solver already does some checks -- can add more there.

bqpd commented 9 years ago

Note to do this using the A matrix / matrix math, etc., not substitution.

whoburg commented 9 years ago

Will implement this once #226 is complete.

bqpd commented 9 years ago

Closing this will close half of the remaining issues! (#125 and #217) Go @whoburg go. :p

whoburg commented 9 years ago

where should this be implemented?

bqpd commented 9 years ago

In geometric_program.solve()

bqpd commented 9 years ago

Probably either just before or just after self.result = result: before means that no bad result is made available if these checks fail, after means that the bad result is made available but not returned.

whoburg commented 9 years ago

I should be able to work on this in a few hours.

whoburg commented 9 years ago

Sorry for delay -- still getting to this, but I want to investigate a possible bug first that I consider higher priority. More info soon.

whoburg commented 9 years ago

still psyched to implement this, but waiting until #338 and #335 are fixed.

whoburg commented 9 years ago

@bqpd how do I best get the slice of A corresponding to:

?

bqpd commented 9 years ago

I think gp.A.tocsr()[0,:] will get the objective, and >0 the constraints?

whoburg commented 9 years ago

TypeError: 'coo_matrix' object has no attribute '__getitem__'

Also, that's just the first monomial in the objective, but I can deal with that via p_idxs

whoburg commented 9 years ago

I think I have a solution where I don't actually need the answer to this, but I'm still curious...

bqpd commented 9 years ago

Sparse matrices are fun!

(yeah, you need a CSR sparse matrix to index, hence the tocsr above)

whoburg commented 9 years ago

doh, my fault.

whoburg commented 9 years ago

this is coming along -- hard at work