Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Limiting variables to discrete list of real numbers

    Posted Sat July 06, 2019 04:07 PM

    Originally posted by: kreitzpa


    Hi all,

     

    Is it possible to set CPLEX to allow variables to only have the values from a discrete list of real values?  For example, set variable m to be allowed to be only a value from the list of elemental masses (1.008,4.0026,6.94,...)? 

    Or would I need to do something like:

    b_1*m == 1.008

    b_2*m == 4.0026

    .

    .

    b_118*m == 294

    b_1 + b_2 + ... + b_118 == 1

    Where m is the variable allowed to be masses and b variables are binary.  Then constraining the sum of binary variables to equal 1 means only one binary variable is equal to 1 which forces m to be equal to one of the masses.

     

    Thanks


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Limiting variables to discrete list of real numbers

    Posted Sat July 06, 2019 05:30 PM

    Originally posted by: DavidGravot


    Note that your model is not feasible

    You could write 

    m== b_1*1.008+ b_2*4.00261+b_118*294

    b_1 + b_2 + ... + b_118==1

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Limiting variables to discrete list of real numbers

    Posted Sun July 07, 2019 03:35 AM

    Hi,

    if you use OPL

    you may also rely on disjunctions: https://www.ibm.com/developerworks/community/forums/html/topic?id=6c3d9687-328a-423f-9bae-114424883e1b&ps=25

    and rewrite

    m== b_1*1.008+ b_2*4.00261+b_118*294

    into

    (m== 1.008) || ( m==4.00261) || (m==294 );

    regards

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Limiting variables to discrete list of real numbers

    Posted Fri August 09, 2019 05:46 PM

    Originally posted by: EdKlotz


    Yes, you can use disjunctions, but I would hesitate to use them in this case.   In this case the formulation provided by David is straightforward to express with any API or OPL.   OPL and the CPLEX and CPO APIs will process the disjunction, but will probably view the disjunctions in a more general framework that will generate a linearized formulation that is far more complex, and potentially more time consuming than David's formulation.    The time to use these disjunctions if when you have complicated logical conditions that would be really hard to linearize yourself.   In those situations, the OPL/CPLEX/CPO processor will probably generate something as good or better than your own formulation.   But in a case where you can easily generate the linearized formulation of the condition of interest yourself, you probably should just do that.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Limiting variables to discrete list of real numbers

    Posted Tue July 09, 2019 03:47 AM

    Yes, this is the way to go (including David's fix).

    Another option would be to have an integer variable i that ranges from 1 through 118 and then define m as a piecewise linear function in i. However, my guess is that the approach with explicit binary variables is the most efficient one.


    #CPLEXOptimizers
    #DecisionOptimization