Hi,

Could you please tell me how I can rewrite the following part of my code more efficient?

// W and S are variables

// D is a data matrix

IloNumExpr OBJECTIVE(*envvv,0);

for(i = 0; i < n; i++){

for (j = 0; j < m; j++){

OBJECTIVE += (S[i]+D[W[i]]>j)&&(S[i]<j))* W[i];

}

}

Mysolve(); //It calls cp.next() in a function and solve a cp model with the objective function of OBJECTIVE.

for(i = 0; i < n; i++){

for (j = 0; j < m; j++){

((S[i]+D[W[i]]>j)&&(S[i]<j)).end();

}

}

OBJECTIVE.end();

Actually I found out that when I delete OBJECTIVE, the part of memory related to the logical expression (S[i]+D[W[i]]>j)&&(S[i]<j)) is not deleted and I have to call "((S[i]+D[W[i]]>j)&&(S[i]<j)).end();" separately. The problem is that deleting the logical expression in this way is very time consuming.

Anybody has any idea how to write this code more efficient?