Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Defining subset in cplex

  • 1.  Defining subset in cplex

    Posted Tue April 05, 2016 09:47 PM

    Originally posted by: SMABinAlIslam


    Hi,

    I am new in cplex. I need to know something. Maybe it is very easy, but I couldn't figure it out.

    I am working with a model, that has a constraint:

    g[i]+g[j]<=1

    where i,j belongs to N={1,2,3,4}

    if i = 1, j= {3,4}

    if i=2, j={1,4}

    if i= 3, j={1,2}

    if j= 4, j= {2,3}

    How can I represent it in Cplex?

    Thanks in advance

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Defining subset in cplex

    Posted Wed April 06, 2016 02:00 AM

    Hi,

    for example

    {int} N={1,2,3,4};
     dvar boolean g[N];
     
     maximize sum(i in N) g[i];
     subject to
     {
      forall(i,j in N:
      (i==1) && (j in {3,4}) ||
      (i==2) && (j in {1,4}) ||
      (i==3) && (j in {1,2}) ||
      (i==4) && (j in {3,2})
      )
        g[i]+g[j]<=1;

    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Defining subset in cplex

    Posted Thu April 07, 2016 01:31 PM

    Originally posted by: SMABinAlIslam


    Hi,

    Thank you very much for the reply. It works.

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer