Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Take the max of two values

    Posted Tue May 09, 2023 11:36 AM

    Hello, 

    Is there a way in cplex to take the max of two values ?
    I would like to create the following constraint : 

    forall(j in positions2) c[2][j] == max(c[1][j],c[2][j-1]) + sum(i in jobs) x[i][j]*durees[2][i];

    Where :
     
    dvar float+ c[machines][positions];
    float durees[machines][test] = [[4, 2, 3, 22, 3, 1, 1], [18, 16, 19, 2, 27, 3, 13], [7, 6, 5, 4, 3, 2, 1]];


    Thanks a lot, 

    Arthur 



    ------------------------------
    Arthur d'Hertog
    ------------------------------


  • 2.  RE: Take the max of two values

    Posted Tue May 09, 2023 11:46 AM

    CPLEX will let you take the maximum (or minimum) of two expressions in a constraint, but if the model is continuous (LP or QP) use of the max/min operator will make it discrete (MILP or MIQP).



    ------------------------------
    Paul Rubin
    Professor Emeritus
    Michigan State University
    ------------------------------



  • 3.  RE: Take the max of two values

    Posted Fri May 12, 2023 02:57 AM

    Hi,

    maxl could help

    See https://github.com/AlexFleischerParis/zooopl/blob/master/zoomaxl.mod

    int nbKids=300;
        
        {int} buses={30,40,50};
        
        
        dvar int+ nbBus[buses];
        dvar int maxNbOfBusesGivenSize;
        
            
        minimize maxNbOfBusesGivenSize;
             
        subject to
        {
         // logical constraint
         // maxNbOfBusesGivenSize is the max of all nbBus
         //maxNbOfBusesGivenSize==max(i in buses) nbBus[i];
         
         // but instead of max we ca use maxl for a list
         maxNbOfBusesGivenSize==maxl(nbBus[30],nbBus[40],nbBus[50]);
         
         
         sum(i in buses) i*nbBus[i]>=nbKids;
        }
    
        execute DISPLAY_After_SOLVE
        {
          writeln("The max number of buses is ",maxNbOfBusesGivenSize);
          writeln("nbBus = ",nbBus);
        }
        
        /*
        
        gives
        
        The max number of buses is 3
        nbBus =  [3 3 3]
        
        */


    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------