Closed rileyjmurray closed 4 years ago
@rileyjmurray additionally to specifying reltol in localsolve (for feasibility within a reltol), you can apply Tight from gpkit.constraints.tight on all constraints where you would like to see if the tightness of the constraint is above some reltol.
m = some_model_or_constraintset()
from gpkit.constraints.tight import Tight
tight_constraints = Tight(m, reltol=1e-5)
So, for an equality, if your tight constraint reltol is smaller than your localsolve reltol, it would tell you how much the actual residual is. I would check out gpkit.constraints.tight!
Tight will only check constraints written in GPkit as Posynomial or Signomial inequalities at present; in addition you could iterate through Model.flat (for c in m.flat
) for gpkit.nomials.MonomialEquality and gpkit.nomials.SingleSignomialInequality instances, sub the results into c.left and c.right and compare; or just modify the code in Tight to also check equalities.
actually, just realized that an easier way to do this for equality constraints is just to create a new SP whose substitutions are equal to the solution: that is,
m.substitutions.update(sol["variables"])
m.sp()
which should raise an error if there are any "impossible" constraints, with a tolerance specified in PosynomialInequality.feastol
that you can change at runtime
@rileyjmurray does this address your issue?
@bqpd it does! I actually had been meaning to come back here and explain that your solution from last week worked for my purposes. This new solution is definitely much cleaner though. Thanks so much for your help, Ned (and also yours, Berk!).
A hopefully quick question for @bqpd or @1ozturkbe. If I run local solve on a signomial program, how do I check the quality (w.r.t. feasibility) of the returned solution? Like -- how do I check that equality constraints were actually satisfied up to reasonable precision?
If at all possible it would be great to know how to do this for GPKit 0.9.9.2 or lower.