Originally posted by: Haschmir
Hello everyone,
i hope you can helb me! My task is to implement a DLSP model with cplex in java. Now i have the problem that the expression to minimize the objective includes the following:
Sum over two indices(k,t) of
(double[k] s * max(0, (IloIntVar[k][t] v - IloIntVar[k]
t-1 v)) + double [k] h * IloIntVar[k][t] y)
Important: v[k][t] is initialized as a boolVarArray.
Remark: This is only Pseudocode, so you know what kind of type my variables are. I hope you can understand my notation.
Back to my problem: How to imlement the max()-function? In my case i have to sum a lot of expressions, so i think i need a linear expression to add all these. But in that case, i can't use cplex.max().
I also tried a combination of four cplex.ifThen() where r[k][t] is a variable of the Typ IloIntVar (boolVarArray) and replaces the whole max()-function in my objective expression:
cplex.ifThen(cplex.and(cplex.eq(y[k][t],1), cplex.eq(y[k]
t-1,0)),cplex.eq(r[k][t],1));
cplex.ifThen(cplex.and(cplex.eq(y[k][t],1), cplex.eq(y[k]
t-1,1)),cplex.eq(r[k][t],0));
cplex.ifThen(cplex.and(cplex.eq(y[k][t],0), cplex.eq(y[k]
t-1,1)),cplex.eq(r[k][t],0));
cplex.ifThen(cplex.and(cplex.eq(y[k][t],0), cplex.eq(y[k]
t-1,0)),cplex.eq(r[k][t],0));
The constraints are not listed in my LP, so i think this attempt of mine has failed too...
I really hope you have any idea or solution to handle my Problem!
If i missed any relevant threads already existing, i'm sorry, but i couldn't find something helping me. In case i forgot important informtions, pardon me, its my first time asking for help. :)
Kind regards and thanking you in anticipation,
Tobias
#CPLEXOptimizers#DecisionOptimization