Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Sorted array as objective

    Posted 06/08/19 04:17 PM

    Originally posted by: trxw


    Hi. I have an integer array WorkingTime[1..10] with the time that every worker works. I would like to search for solutions that complain with the right order as much as possible. Meaning that the person 1 works less than 2; 2 less than 3 and so on. Something like to minimize the expression of the differente between a sorted and unsorted arrays.

     

    But I don´t want to put it as a constrain inside the subject as sometimes is not feasible to find a solution that complies with the order of all the people. So, I don´t want this:

    WorkingTimeConstraint:   
       forall (i in 1..9)
           WorkingTime[i] <= WorkingTime[i+1];


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Sorted array as objective

    Posted 06/09/19 02:01 AM

    Hi,

    you could try

    dvar int WorkingTime[1..10] in 1..10;
     
     maximize sum(i in 1..9) (WorkingTime[i]<=WorkingTime[i+1]);

    and

     

    dvar int WorkingTime[1..10] in 1..10;
     
     minimize sum(i in 1..9) maxl(0,WorkingTime[i]-WorkingTime[i+1]);

    regards

    PS: Do more with less

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Sorted array as objective

    Posted 06/09/19 04:06 AM

    Originally posted by: trxw


    Thanks again.

    Is there any way to remove one constraint from the CP model when no solution has been found?

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Sorted array as objective



  • 5.  Re: Sorted array as objective

    Posted 06/09/19 07:42 AM

    Originally posted by: trxw


    Can't figure it out... So if I have

     

             int CoefOrdenDeSalida=1;

    then

             OrdenSalida: 
             forall (i in 1..9)
                   CoefOrdenDeSalida*OrdenDeSalida[i] <= OrdenDeSalida[i+1];

    I want to be able to set CoefOrdenDeSalida=0 only if no cp solution is found

     

    main
    {
    thisOplModel.generate();
    cp.startNewSearch();
    while
    (cp.next()) {  thisOplModel.postProcess(); }


    thisOplModel.OrdenSalida.setCoef(thisOplModel.CoefOrdenDeSalida,0);
    while
    (cp.next()) {  thisOplModel.postProcess(); }
    }

    gives an error... Can you help me?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Sorted array as objective

    Posted 06/09/19 12:39 PM

    Hi,

    you could use multiobjective and have this as a fist objective and have a second objective.

    Then CPLEX will try to have the first objective as good as possible and then improve the second one. This works both for MIP and CPO:

    dvar int WorkingTime[1..10] in 1..9;
     
     dexpr int obj1=(0==sum(i in 1..9) maxl(0,WorkingTime[i]-WorkingTime[i+1]));
     dexpr int obj2=WorkingTime[1];
     
     
     maximize staticLex(obj1,obj2);
     
     
     subject to
     {
     WorkingTime[2]==3;
     WorkingTime[3]==1;
     }
     
     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer