Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Unequal constraint for indizes

    Posted 09/07/17 05:49 AM

    Originally posted by: Breemes


    Hi everyone,

     

    i want to create a constraint regarding my indizes. I have to define it as an range, because for the array all indizes must be the same. 

    So my question how can I ensure that every number of a range is only used once?
    I want a fixed assignment for every i.

    There will be a flow from r to w, but it should not be possible that i =1 goes to w 1,2,3 - 

    Can I add s.th in the constraints like 

    forall i unequal i?

     

    range i =1...5;

    range w =1,..3;

    range r=1,..3;

     

    Can anyone assist?
     

    Thanks a lot and regards,

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Unequal constraint for indizes

    Posted 09/07/17 09:13 AM

    Sorry, I don't quite understand what constraint you are trying to establish. I only see ranges in your model, no decision variables. What do you mean by "every number of a range is used only once"? Do you have decision variables that are indexed by your ranges and then you have some conditions on these decision variables being zero or non-zero. What do you mean by "flow from r to w"? Can you please try to elaborate?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Unequal constraint for indizes

    Posted 09/07/17 09:51 AM

    Originally posted by: Breemes


    Hey,

     

    thanks for your response - i try to explain my problem.

     

    Yes I have certain decision variable like
     

    dvar int+ vonReUse [time] [location][ Handy] [Inspektion] [Reuse]

    with

    range time = 1..Planungshorizont;

    range Handy=1...10;

    range Inspektion=1...3;

    range Reuse=1..3;

    range location=1..3;

     

    The decision variable is a flow variable and should express the flow of the product handy : in time t in a location x the flow of Handy i from department Inspektion to department Reuse

    In the results a lot of Handys with Number 1 goes from one department to the other, but  i want that every Number of the indices Handy is unique. That handy Number 1 only can  go in one location to other departments but that is not possible that handy=1 wil be assigned to different locations.

     

    Sorry it is a little bit complicated to explain what i want to express. I hope you understand my problem and can help me.

     

    Thanks and regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Unequal constraint for indizes

    Posted 09/07/17 11:59 AM

    Hi

    in the example CPLEX_Studio1271\opl\examples\opl\warehouse warehouse.mod

    forall( s in Stores )
        ctEachStoreHasOneWarehouse:
          sum( w in  Warehouses )
            Supply[s][w] == 1;

     

    could help ?

    regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Unequal constraint for indizes

    Posted 09/08/17 01:20 AM

    I am still not sure I understand you correctly, but if I do then things are slightly more complicated than Alex' solution.

    So let me see whether I got you right.

    For a fixed time period t0 in time and a fixed handy h0 in Handy you require that at most one of Reuse[t0][l][h0][i][r] is non-zero. Since variable Reuse is a general integer you will need an auxiliary variable and then can model things like this (untested):

    dvar boolean aux[time][location][Handy][Inspektion][Reuse];
    int M = ...;
    
    subject to {
       forall (t0 in time) {
         forall (h0 in Handy) {
           // At most one of the aux variables can be non-zero
           sum (l in location) sum (i in Inspektion) sum (r in Reuse) aux[t0][l][h0][i][r] <= 1;
         }
       }
       forall (t in time) {
         forall (h in Handy) {
           forall (l in location) {
             forall (i in Inspektion) {
               forall (r in Reuse) {
                 // A Reuse variable may only be non-zero if the corresponding
                 // aux variable is 1.
                 Reuse[t][l][h][i][r] <= M * aux[t][l][h][i][r];
               }
             }
           }
         }
       }
    }
    

    Here 'M' is an upper bound on the Reuse variables (I assume that such an upper bound exists).

     

    BTW, it seems you are German (like me). So if your question is still not answered and it is any easier to explain things in German, then please feel free to drop we an email to daniel(dot)junglas(at)de(dot)ibm(dot)com.


    #CPLEXOptimizers
    #DecisionOptimization