Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Can the ceil() function be used in a constraint

    Posted 04/10/17 11:03 PM

    Originally posted by: pineapple365


    I am trying to return a smallest integer array  in a constraint in CPLEX which uses the ceil() function, but keep getting the ''can not use dvar float in constraint''. Following is constraint:

     [CODE]

    forall(i in Plants, h in Hubs, s in Ships)
            Nship[i][h] == plant_hub[i][h]/ShipCapa[s];
     forall(i in Plants, h in Hubs)
            N[i][h] = ceil(Nship[i][h]);

    [/CODE]

     

    The array is two-dimensional, but formulation is simple. I think ceil() function could be used in constraint, and there is something wrong with my coding.

    Any help would be great.

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Can the ceil() function be used in a constraint

    Posted 04/17/17 01:02 PM

    Hi,

    you cannot use ceil directly because it is not linear but you may write the following if you need to get

    y=ceil(x)

    within the constraints:

    range r=1..4;

    float x[r]=[1.5,4.0,2.0001,5.9999];

    dvar int y[r];
    dvar float f[r] in 0..0.9999999;

    subject to
    {
    forall(i in r) y[i]==x[i]+f[i];


    }

    execute
    {
    writeln(x," ==> ",y);
    }

    assert forall(i in r) y[i]==ceil(x[i]);

    which gives

    [1.5 4 2.0001 5.9999] ==>  [2 4 3 6]

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Can the ceil() function be used in a constraint

    Posted 04/17/17 11:15 PM

    Originally posted by: pineapple365


    Alex, thank you for your kind explanation. I tried the way you said, and got the right answer! 

    Regards.

    pineapple

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer