I develop a quadratic programming model using Gurobi python API. In terms of objective formulation containing a function associated with decision variable, such as obj = f(x) + g(y), I need to get values of the decision variables for the functions f(), g(). This is why the input of functions f(), g() should be list or array type acceptable format to the functions while Gurobi model uses tupledict structure that does not fit for general calculation. How can I get values of variables awaiting model update as below?
: x[0] <br>
: <gurobi.Var *Awaiting Model Update*>
---------------------- pseudo code ---------------------------
import gurobipy as gp<br>
from gurobipy import GRB
def func():
mdl = gp.Model()
x = mdl.addVars(100, lb=0, vtype=GRB.INTEGER)
for i in range(100):<br>
_x[i] = x[i] # TypeError: float() argument must be a string or a number, not 'Var'<br>
_x[i] = x[i].X # AttributeError: Index out of range for attribute 'X'
obj = func(_x)
mdl.setObjective(obj, GRB.MINIMIZE)