Originally posted by: SystemAdmin
[prubin said:]
[quote author=Mr.Buxley link=topic=1238.msg3536#msg3536 date=1247038735]
What I ment to ask was can I add or remove something from the coeff without knowing the value of the coeff.
For example
IloRange myCon= x1+x2<=3<br />setLinerarCoef (
Here I would like to add 3 to the coef before x1 so myCon would become 3x1+x2<=3 and if it would have been 2x it would become 5x and so on...<br />
However I have many,many constraints and don't know the different values for the coeffs in the differnet constraints.
Store them somewhere (either at the time you compute them or at the time you read them in, whichever applies), then update the stored values at the same time you change them in the constraints.
The CPLEX programmers have an odd affinity for asymmetry. There's a method to set an individual coefficient directly but not (at least as of version 11) a method to get one directly. The only alternative I know to storing them yourself is to use a IloLinearNumExprIterator, but that requires that you iterate over every term in each expression until you find the one you want. Storing the coefficients is much less painful.
#CPLEXOptimizers#DecisionOptimization