convexengineering / gpkit

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

Redundant equality constraint causes issues with CVXOPT #1551

Closed nillst closed 3 years ago

nillst commented 3 years ago

When using CVXOPT, a redundant equality constraint will fail to solve and send the model into debug mode (see the example below). The model is feasible as demonstrated by the successful solve on the first go. Once in debug mode, the model is solved successfully with relaxed constraints but shows 0% relaxation.

As far as I have tried, redundant inequality constraints do not seem to have this issue.

Thoughts?

Environment Information

Test model

from gpkit import Model, Variable

a = Variable('a', 1)
b = Variable('b')
c = Variable('c', 2)
d = Variable('d')
z = Variable('z', 0.5)

# create a simple GP with equality constraints
const = [
    z == b/a,
    z == d/c,
]

# simple cost
cost = a + b + c + d

# create a model
m = Model(cost, const)

# solve the first version of the model (solves successfully)
m.solve(solver='cvxopt')

# add a redundant equality constraint
m.extend([
    z == b/a
])

# solver will fail and attempt to debug
m.solve(solver='cvxopt')

Example Output

Using solver 'cvxopt'
 for 2 free variables
  in 5 posynomial inequalities.
Solving took 0.00302 seconds.
Using solver 'cvxopt'
 for 2 free variables
  in 7 posynomial inequalities.
Solving took 0.00111 seconds.
The model ran to an infinitely low cost; bounding the right variables would prevent this.
Since this model solved in less than a second, let's run `.debug()` automatically to check.
`
< DEBUGGING >
> Trying with bounded variables and relaxed constants:
>> Failure.
> Trying with relaxed constraints:
Solves with these constraints relaxed:
   0:    0% relaxed, from z = b/a 
                     to z <= a^-1·b 
>> Success!
whoburg commented 3 years ago

Hmm, it's surprising to see "The model ran to an infinitely low cost". This model's cost definitely seems bounded (should be 1.5 I believe).

bqpd commented 3 years ago

ah I think that's just my blanket dual infeasibility statement, I should be more exact.

Strange that this is dual infeasible!

bqpd commented 3 years ago

Also strange that it doesn't solve with relaxed constants

bqpd commented 3 years ago

newest master prints " Model seems feasible without modification, or only needs relaxations of less than 1%. Check the returned solution for details." which is a little more clarifying

bqpd commented 3 years ago

confirmed that it solves with MOSEK

bqpd commented 3 years ago

it wouldn't be difficult to remove duplicate constraints on the gpkit side