In the Gurobi Python API, I am trying to change one coefficient within a linear constraint of a quadratic optimization model.
grbModel.chgCoeff(constr, grbx[j], newvalue)
grbModel is a my optimization model
constr is a constraint within that model
grbx is a one-dimensional matrix variable within that model
j is a valid index into that matrix variable
newvalue is some float
My program bombs with this rather inscrutable error:
File "model.pxi", line 4915, in gurobipy.Model.chgCoeff
File "mvar.pxi", line 67, in gurobipy.MVar.__getattr__
File "mvar.pxi", line 186, in gurobipy.MVar.getAttr
File "attrutil.pxi", line 23, in gurobipy.__getattrinfo
AttributeError: 'gurobipy.MVar' object has no attribute '__cindex__'
What am I doing wrong?
If I want to use chgCoef, can I only use individual variables, not matrix variables?
I am very experienced in both programming and optimization, but this is my first time using this particular API.
Please sign in to leave a comment.