convexengineering / gpkit

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

RuntimeWarning: The primal solution was not returned. #1547

Closed zephyr06 closed 3 years ago

zephyr06 commented 3 years ago

I have a very simple and feasible program to run, but meets this error. Variables in the debug model is added there. My code is pretty simple after setting variables and constraints: m =Model(objective, constraints) sol = m.solve(verbosity=2) print (sol.table())

Could anyone help on this issue? Thanks! ***debug parameters* N = {int} 4 addition = {Posynomial} 10·x[0] + x[1]·10 + x[2]·10 + x[3]·10 constraints = {list: 8} [gpkit.PosynomialInequality(10·x[0] <= 50), gpkit.PosynomialInequality(x[0] >= 1), gpkit.PosynomialInequality(10·x[0] + x[1]·10 <= 120), gpkit.PosynomialInequality(x[1] >= 1), gpkit.PosynomialInequality(10·x[0] + x[1]·10 + x[2]·10 <= 180), gpkit.Posynomial 0 = {PosynomialInequality} 10·x[0] <= 50 1 = {PosynomialInequality} x[0] >= 1 2 = {PosynomialInequality} 10·x[0] + x[1]·10 <= 120 3 = {PosynomialInequality} x[1] >= 1 4 = {PosynomialInequality} 10·x[0] + x[1]·10 + x[2]·10 <= 180 5 = {PosynomialInequality} x[2] >= 1 6 = {PosynomialInequality} 10·x[0] + x[1]·10 + x[2]·10 + x[3]·10 <= 300 7 = {PosynomialInequality} x[3] >= 1 len = {int} 8 energy_initial = {int64: ()} 40 i = {int} 3 initial_solution = {ndarray: (4,)} [1. 1. 1. 1.] m = {Model: 8} \nCost\n----\n 10·x[0]² + 10·x[1]·x[1] + 10·x[2]·x[2] + 10·x[3]·x[3]\n\nConstraints\n-----------\n 10·x[0] <= 50\n x[0] >= 1\n 10·x[0] + x[1]·10 <= 120\n x[1] >= 1\n 10·x[0] + x[1]·10 + x[2]·10 <= 180\n x[2] >= 1\n 10·x[0] + x[1]·10 + x[2]·10 + x[3]·10 <= 300\n x[3] >= objective = {Posynomial} 10·x[0]² + 10·x[1]·x[1] + 10·x[2]·x[2] + 10·x[3]·x[3] any_nonpositive_cs = {bool} False ast = {tuple: 2} ('add', (gpkit.Posynomial(10·x[0]² + 10·x[1]·x[1] + 10·x[2]·x[2]), gpkit.Monomial(10·x[3]·x[3]))) cached_strs = {dict: 2} {frozenset({'unnecessary lineage', 'root', 'units'}): '10·x[0]² + 10·x[1]·x[1] + 10·x[2]·x[2] + 10·x[3]·x[3]', frozenset({'units'}): '10·x[0]² + 10·x[1]·x[1] + 10·x[2]·x[2] + 10·x[3]·x[3]'} cs = {ndarray: (4,)} [10. 10. 10. 10.] exps = {tuple: 4} ({x[0]: 2}, {x[1]: 2}, {x[2]: 2}, {x[3]: 2}) hmap = {NomialMap: 4} {{x[0]: 2}: 10.0, {x[1]: 2}: 10.0, {x[2]: 2}: 10.0, {x[3]: 2}: 10.0} units = {NoneType} None value = {Posynomial} 10·x[0]² + 10·x[1]² + 10·x[2]² + 10·x[3]² varkeys = {KeySet: 4} KeySet({x[1], x[2], x[3], x[0]}) vks = {set: 4} {x[1], x[2], x[3], x[0]} srtg = {SRTG: 4} <SRTG.SRTG object at 0x7fb0cb3f0cd0> x = {NomialArray: (4,)} x[:100]


zephyr06 commented 3 years ago

I use this command to set minimum value for vector x, but it seems this sets x as a constant value? x = VectorVariable(N, "x",[1,1,1,1])

bqpd commented 3 years ago

Yup! As documented in https://gpkit.readthedocs.io/en/latest/gettingstarted.html#declaring-constraints, that's a syntax used to set fixed variables. Seems like your model got figured out? If it was primal infeasible and took less than a second to solve, it should have output some Model.debug() information by default -- hope that was helpful!

zephyr06 commented 3 years ago

Thanks! That's helpful!