Originally posted by: FANS_Nader_Al_Theeb
Hello, Dear all
(Using CPLEX - C++):
I have the complicated constraint shown in the attachment. The constraint should be applied for all (c, o, and t). Left hand side has summations of (tau and P). Whereas the right hand side has summations of ( tau, h, and p) ahich is not the same of left hand side. can any one help me to do that constraints.
I have the following thoughts so far
for ( c=0; c<nbComm; c++){
IloExpr expr(env);
IloExpr expr2(env);
IloExpr expr3(env);
for( o=0; o<nbDNodes; o++){
for ( t=0; t<curr_t; t++){
for ( tau=0; tau<t; tau++){
expr3 += dcot [c] [o]
tau ;
for ( p=0; p<nbNodes; p++){
if (o==p) {continue;}
if (top[p][o]>curr_t) {expr=expr + Q_copt[c][o][p]
tau;}
if (top[p][o]<=curr_t){expr=expr + (-1*Q_copt[c][p][o]
tau) + Q_copt[c][o][p]
tau;}
for ( h=0; h< nbWoundedCat; h++){
expr2 += -1*(fc[c] * X_hopt[h][o][p]
tau);
}//end h loop
}//end tau loop
}//end p loop
}//end t loop
model.add(expr - DEV_cot[c][o]
t-1 == expr3 - expr2);
expr.end();
expr2.end();
expr3.end();
}// end o loop
}// end c loop
As a general Idea is that correct? And in this case, I received a segmentation fault because I end the expressions after t-loop, then I re-use them. To solve that, I put the IloExpr definition before starting the loops, then I end them after the loops, I know this is not correct because the expressions will accumulate the values.
Any help about such constraints, and does the IloExprArray help in such cases?
Thanks
#CPLEXOptimizers#DecisionOptimization