You optimize 2 goals, which are complex expressions, and want to change their coefs.
As obj.setCoef only deals with variables, you need to use 2 variables in the objective, and add 2 constraints in the subject-to to make them equal to the variables.
A very simple example:
<code>
int N = 5;
range R = 0..5;
{float} coefs = { i/N | i in R};
float coef1 = 1;
dvar int X[R] in 0..1;
dvar int Y[R] in 0..1;
dexpr float exp1 = sum(i in R) item(coefs,i)*X[i];
dexpr float exp2 = sum(i in R) item(coefs,i)*Y[i];
// obj.setCoef only deals with variables, not dexpr => Need an indirection.
dvar float goal1;
dvar float goal2;
maximize coef1 * goal1 + (1-coef1) * goal2;
subject to{
// force the dexpr to be == to the vars.
goal1 == exp1;
goal2 == exp2;
exp1 <= 2.5;
exp2 <= 1.5;
}
main{
thisOplModel.generate();
for (var c in thisOplModel.coefs){
thisOplModel.getObjective().setCoef(thisOplModel.goal1, c);
thisOplModel.getObjective().setCoef(thisOplModel.goal2, 1-c);
cplex.solve();
thisOplModel.postProcess();
writeln("New Objective for threshold "+c + " is "+ thisOplModel.getObjective().solutionValue);
}
}
</code>
It will produce:
<code>
New Objective for threshold 0 is 1.4
New Objective for threshold 0.2 is 1.6
New Objective for threshold 0.4 is 1.8
New Objective for threshold 0.6 is 2
New Objective for threshold 0.8 is 2.2
New Objective for threshold 1 is 2.4
</code>
------------------------------
Vincent Beraudier
------------------------------
Original Message:
Sent: Tue July 13, 2021 12:32 PM
From: Siamak Mushakhian
Subject: Change a parameter in the objective function
Yes, you are right. It is a dexpr but unfortunately, I didn't get your point. How can I change it to a dvar?
Here you can find the f1_normal where f1 is another dexpr, but f1_optimal and f1_nadir are parameters (as I already know their values).


Would you mind if you provide me a simple example?
------------------------------
Siamak Mushakhian
------------------------------
Original Message:
Sent: Tue July 13, 2021 11:42 AM
From: Vincent Beraudier
Subject: Change a parameter in the objective function
You can modify the objective only via changing the coefficients of variables.
See https://www.ibm.com/docs/api/v1/content/SSSA5P_20.1.0/ilog.odms.ide.help/refjsopl/html/IloObjective.html#setCoef
I guess that f1_normal is a dexpr and not a variable.
If so, you may insert variables, use them in the objective and make them equal to the dexpr?
------------------------------
Vincent Beraudier