Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Using operators for sets in the forall condition

  • 1.  Using operators for sets in the forall condition

    Posted Thu July 27, 2017 10:54 AM

    Originally posted by: Striker121


    Hi there,

    I run CPLEX version 12.7.0.0.

    I have difficulty in modelling the following constraint in CPLEX: 

     

     

    where Phi is the empty/null set. 

     

    More specifically, the part stating that the union of both sets Ris and Ri's' must not equal the null/empty set. CPLEX returns the following error: "Operator not available for {int} != {void}". I have searched to find an analog of the operator "!=" for sets but I have no luck in both the forum and documentation. I would greatly appreciate any help in modelling this constraint. I have attached my .mod file and .dat file as well as the accompanying Excel spreadsheet to this post. I will also copy paste it below.

     

    Thanks in advance!

     

    .mod file:

     

    int nbBatchesI = ...;
    int nbStagesS = ...;
     
    range BatchI= 1..nbBatchesI;
    range StagesS= 1..nbStagesS;

    //The following strings are used to extract the data from the Excel sheets
    string stS[BatchI] = ...;
    string stRis[BatchI][StagesS] = ...;

    {int} S[BatchI];//Set Si
    {int} Ris[BatchI][StagesS];


    //Parameters
    int H=200;

    //Continuous Decision Variables
    dvar float C[BatchI][StagesS];
    dvar float Start[BatchI][StagesS];//Is the variable Sis in the equation 

    //Binary Decision Variables
    dvar boolean W[BatchI][StagesS][BatchI][StagesS];

    execute convert_strings
    {
    for(var b in BatchI)
    {
       var ar=stS[b].split(",");
       for(var i=0;i<ar.length;i++) S[b].add(Opl.intValue(ar[i]));
    }
    }


    execute convert_strings_Obtain_Ris
    {
    for(var b in BatchI)
    {
       for(var s in StagesS)
       {
         var ar=stRis[b][s].split(",");
         for(var i=0;i<ar.length;i++) Ris[b][s].add(Opl.intValue(ar[i]));   
       }
       
    }
    }

     

    subject to {
        
    //A lot of other constraints before this
         
        forall (i in BatchI, ip in BatchI, s in S[i], sp in S[ip] : ( (Ris[i][s] union Ris[ip][sp] != {}) && (ip != i) ))
         ResourceOverlapConstraint13:
         C[ip][sp] - Start[i][s] <= H*W[ip][sp][i][s];
              
    }

     

    Also my .dat file

     

    nbBatchesI = 3;
    nbStagesS = 3;


    SheetConnection Example_Data ("ExampleDataTEST.xls");
    stS from SheetRead(Example_Data, "'Si'!A1:C1");
    stRis from SheetRead(Example_Data, "'Ris'!A1:C3");

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Using operators for sets in the forall condition

    Posted Thu July 27, 2017 11:30 AM

    Hi,

    you should use card!

    forall (i in BatchI, ip in BatchI, s in S[i], sp in S[ip] : ( 0!=card(Ris[i][s] union Ris[ip][sp]) && (ip != i) ))
         //ResourceOverlapConstraint13:
         C[ip][sp] - Start[i][s] <= H*W[ip][sp][i][s];

    will work fine

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Using operators for sets in the forall condition

    Posted Thu July 27, 2017 12:26 PM

    Originally posted by: Striker121


    Hi Alex,

     

    Many thanks for your help!

     

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer