title: Gurobi objective with python dictionary values
body: <p>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:</p>
  
  <pre><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 &lt;= 2)
  m.setObjective(d[(x, y)], GRB.MAXIMIZE)
  m.optimize()
  print m.objVal
  print x.x
  print y.x
  </code></pre>
  
  <p>The answer to the model was</p>
  
  <blockquote>
    <p>-5.0</p>
    
    <p>-0.0</p>
    
    <p>-0.0</p>
  </blockquote>
  
  <p>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? </p>