I am using Gurobi 6.0 with Python 2.7. I am curious to know if Gurobi allows the objective function to have values coming from a dictionary with indices of the decision variables. Attaching the code:
from gurobipy import *
d = {
(0, 0): 0,
(0, 1): -5,
(1, 0): 4,
(1, 1): 2,
(2, 0): 0,
(0, 2): 10
}
m = Model()
x = m.addVar(vtype=GRB.INTEGER)
y = m.addVar(vtype=GRB.INTEGER)
m.update()
m.addConstr(x + y <= 2)
m.setObjective(d[(x, y)], GRB.MAXIMIZE)
m.optimize()
print m.objVal
print x.x
print y.x
The answer to the model was
-5.0
-0.0
-0.0
which clearly makes no sense because max(d[(x,y)]) = 10 happens at x=0 and y=2 as per the given data. What is the issue here? Does Gurobi even allow such dictionary references ? Is it even allowed?