Originally posted by: Hosssein
Hi,
I am solving a CP model iteratively with same variables and constraints but different objective functions. The structure of the objective function does not change. The only things that change, from an iteration to the next, are the data arrays based on which the objective function is created in each iteration.
In my current implementation, in each iteration I delete the previous objective function and add a new objective function with new data arrays which is very time consuming. Actually the objective is very huge and its deletion is the source of long run time.
Is it possible just to change the data arrays in each iteration inside of the objective expression to correct the objective function rather than deleting the previous objective function and adding the new objective function?
An example of such objective function is as follows:
// W and S are variables
// D, P and L are data arrays
for (i = 0; i < n; i++){
for (j = 0; j < m; j++){
// D, P and L are updated here
OBJECTIVE = -((S[i]+D[W[i]]>j)&&(S[i]<j))*P[L[W[i]]*j];
//CP model is solved here
OBJECTIVE.end();
}
}
Thanks in advance for your comments.
#CPOptimizer#DecisionOptimization