Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  non effective sum using

    Posted 02/20/16 06:58 AM

    Originally posted by: Semen11111


    Hi guys, I'm in stuck, and I need help. I make this java code:

    IloIntExpr q = cp.intExpr();
    IloIntVar[][][] arr = ...;

     

    for (int i = 0; i < day; i++)
    {
      for(int j = 0; j < workersTypesNum - 1; j++)
      {
        for(int j1 = j + 1; j1 < workersTypesNum; j1++)
        {
          q = cp.sum(q, cp.prod(arr[i][j], arr[i][j1]));
        }
    }

     

    I start this code with profiler, and I get, that "cp.sum" function spend almost all time,  so my first question: how can I fix it?
    and the second question about logic: In my task I'd like to make all types of work in one day (this is my target function), and I decided to maximize quadratic function like: arr[i][j] * arr[i][j1], 
    where i -day numder, and j is work type (j <> j1). arr is matrix with 0 and 1.
    But may be I do it wrong? maybe it's linear task at all?

     

    thanks)


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: non effective sum using

    Posted 02/22/16 08:37 AM

    Originally posted by: ol


    Hello,

    the java API is a wrapper around C++, what are you profiling? you mean that the time to build the java expression is significative? what is the size of the expression? or do you mean the solving time?

    For your 2nd question, if there is a solution with all types of work each day, you can simply write a constraint, typically using "count" expressions, forcing that each day the number of type i is greater than 0 for all type i.

    Regards,

    Olivier

     


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: non effective sum using

    Posted 02/24/16 05:47 AM

    Originally posted by: Semen11111


    Hi ol, thanks for your answer, actually I have resolved my first problem, but I don't get what you suggested to me in my second problem... actualy I'd like to minimize the days number, when my arr (asset) are in service... so I'd like to do all work types in one day (or in minimum possible days number). And I have a plan service for all my assets, and the plan is deffenent for each asset.
    thanks.


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: non effective sum using

    Posted 02/25/16 05:35 AM

    Originally posted by: ol


    Hello,

    that was to avoid a O(N^2) size of your expression. But in your case, why not simply minimizing the number of days?


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: non effective sum using

    Posted 02/25/16 07:23 AM

    Originally posted by: Semen11111


    thanks, I get, best idea


    #CPOptimizer
    #DecisionOptimization