Incorrect Result for single variable problem
回答済みmin z = -y
st. x-y >= 1, y <= 0, x + y <= 2
The solution to the problem must be 1. Can someone please explain this egregious result?
Thanks
import gurobipy as gp
m = gp.Model()
x = m.addVar(name = 'x')
y = m.addVar(name = 'y')
x = 0
m.addConstr(x -y >= 1)
m.addConstr(y <= 0)
m.addConstr(x + y <= 2)
m.setObjective((-1)*y, gp.GRB.MINIMIZE)
m.optimize()
Gurobi Optimizer version 9.1.0 build v9.1.0rc0 (win64)
Thread count: 2 physical cores, 2 logical processors, using up to 2 threads
Optimize a model with 3 rows, 2 columns and 3 nonzeros
Model fingerprint: 0x4470dc98
Coefficient statistics:
Matrix range [1e+00, 1e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 2e+00]
Presolve removed 0 rows and 1 columns
Presolve time: 0.03s
Solved in 0 iterations and 0.03 seconds
Infeasible or unbounded mode
1
-
正式なコメント
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
By default, all variables have a lower bound of 0. You should change the definition of y as follows:
y = m.addVar(lb=-gp.GRB.INFINITY, name = 'y')
1 -
Worked. Thanks!!
0
投稿コメントは受け付けていません。
コメント
3件のコメント