Solvable Simultaneous Equations Returns "Infeasible model"
AnsweredI am trying to solve a set of 10 by 10 simultaneous equations using gurobipy. The original code is shown below:
import gurobipy as gp
import numpy as np
A = np.array(
[[0, 0, 2.25171, 8.95928, 4.4778, 1.21527, 0, 0, 26.39027, 0],
[27.06379, 14.61077, 0, 0, 27.01525, 0.62793, 0, 0, 0, 16.96571],
[14.80508, 0.83121, 1.55167, 0, 23.91044, 0, 2.22328, 14.09781, 1.06263, 9.70157],
[3.18459, 0, 1.00949, 1.554, 0, 3.44998, 0, 0, 16.22922, 5.14289],
[13.29879, 0, 8.46611, 7.69697, 0, 0, 9.19035, 2.16896, 8.83559, 0],
[11.80379, 17.47908, 16.50753, 10.99252, 0, 0, 0, 0, 24.69994, 8.05508],
[3.05873, 7.80076, 10.46765, 9.21063, 0, 0, 6.59954, 3.85601, 0, 3.60016],
[0, 0, 25.75262, 18.11505, 3.52464, 5.82234, 11.77743, 21.51821, 0, 0],
[0, 0, 0, 0, 10.14581, 4.08672, 5.20011, 21.21334, 9.89348, 0],
[23.38353, 0, 24.02229, 21.91727, 4.9149, 0, 0, 1.15203, 0, 0.0554]])
b = np.array([[41.50387],[17.7489],[33.95538],[15.73681],[48.93402],[38.87969],[12.6149],
[12.82158],[49.51045],[24.03097]])
b_t = np.reshape(b, 1)
model = gp.Model()
x = model.addMVar(10)
model.addConstr(A@x == b_t)
model.optimize()
print("Result:")
When I am trying to solve for Ax = b_t, the optimizer shows "Infeasible model". But the simultaneous equations are solvable using x = A inverse multiplies by b, which gives the result of:
Please let me know what did I do wrong with the gurobipy model. Thanks!

Without having verified this, I guess you are using the default lower bound of 0. You should add the variables with lower bound INF.
Best regards,
Thomas1 
Hi Thomas,
Thanks for the reply. The problem was indeed caused by me not defining lower bound/upper bound. I added the bounds in the add variable section and now it works!
0 
The default upper bound should be +INF, so you should not have to specify it explicitly. But of course, it is perfectly ok to do so.
Best regards,
Thomas0
Please sign in to leave a comment.
Comments
3 comments