Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Correcting the objective function iteratively

    Posted Thu June 20, 2013 03:04 PM

    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


  • 2.  Re: Correcting the objective function iteratively

    Posted Tue June 25, 2013 12:36 PM

    Originally posted by: Philippe_Refalo


    It is not possible to change only the cofficient of these expression since they are encoded in a special way inside. They are not shared. So changing the values in an array will not have any effect. If this memory release take too much time, and if the objective is an important part of the model (in terms of number of subexpressions) then you should consider destroying the whole model and even the environment and recreate everything at each iteration.

     

    Philippe


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Correcting the objective function iteratively

    Posted Tue June 25, 2013 01:29 PM

    Originally posted by: Hosssein


    Thank you for your reply. It is actually what I am doing currently in my model. The problem is that deleting environment with .end() is very time consuming. Is there any special command in c++ to delete the environment faster than .end() ?

    Thank you for all of your helps.


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: Correcting the objective function iteratively

    Posted Tue July 02, 2013 05:44 AM

    Originally posted by: Philippe_Refalo


    Unless your model is really huge (can you give us its size ?) env.end() should not take long, but unfortunately, there is no other way to release the memory.

    Philippe


    #CPOptimizer
    #DecisionOptimization