Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  add iterative a matrix to a tuple using Main-Script

    Posted 11/14/11 05:04 AM

    Originally posted by: Ben87


    Hallo,
    I want to add iterative a two-dimensional matrix to a tuple in the Main-Script, so I can use it in a submodel (which I also solve iterative) as a constraint. I do not know the number of elements or the values of the elements in advance. For example I want to add in every iteration a matrix like that:

    
    [[0 -1350 0 0] [0 0 0 -500] [-600 -225 -250 -1680]]
    


    While using just single values it works fine, when doing it in the following way in Opl Script:
    
    SomeOpl.BetaTuple.add(0); SomeOpl.BetaTuple.add(1.1);
    

    or:
    
    SomeOpl.BetaTuple.add(someVariable);
    


    and in my submodel I use it in the following way:
    
    forall ( f in BetaTuple) ctKoeffizienten: f.b <= Theta;
    


    My overall main goal with these matrices and the single values is to do something like that in the sub-model:
    
    tuple BCuts
    { 
    
    float b; 
    } 
    {BCuts
    } BetaTuple=
    {
    };   tuple ACuts
    { 
    
    float a[Werke][Produkte]; 
    }
    // I know that this is not possible, but some like that i want to do.   
    {ACuts
    } AlphaTuple=
    {
    }; … Minimize… Subject to
    { … forall (e in AlphaTuple, f in BetaTuple, i in facility, j in products) ctCoefficient: (sum(i in facility, j in products)e.a[i][j] * Allocation[i][j]) + f.b <= Theta; …
    }
    


    Maybe the mathematical formulation helps to understand the problem a bit better:
    
    Min ( (sum(i in facility, j in products) (CostAllocation[i][j] * Allocation[i][j])) + Theta)   s.t.  Theta >= ( sum(i in facility, j in products)a_k[i][j]*y[i][j]) + b_k ; forall(k)
    


    k = Iteration;
    Allocation[i][j] is a boolean;

    I know that multidimensional Arrays are not allowed in Tuples. So my question is, if there is any other method or work-around for doing something I have described above?

    Best Regards,
    Benjamin
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: add iterative a matrix to a tuple using Main-Script

    Posted 11/15/11 06:48 PM

    Originally posted by: SystemAdmin


    > I know that multidimensional Arrays are not allowed in Tuples. So my
    > question is, if there is any other method or work-around for doing
    > something I have described above?

    How about changing the ACuts tuple structure to something like:

    tuple ACuts{
            //float a[Werke][Produkte];
            int facility;
            int products;
            float a;
    }
    


    So, you will have one tuple entry for every element in your 2d array, consisting of the 1st index, 2nd index and the actual value. Thus if your variables look like:

    BetaTuple = {<1>,<1.1>};
    AlphaTuple = {<1,3,7>,<1,4,8>,<2,3,9>,<2,4,10>};
    facility={1,2};
    products={3,4};
    a[facility][products]=[[7,8],[9,10]];
    


    you should be able to add them like such:

    subOpl.AlphaTuple.add(1,3,7);
       subOpl.AlphaTuple.add(1,4,8);
       subOpl.AlphaTuple.add(2,3,9);
       subOpl.AlphaTuple.add(2,4,10);
    

    Hope this helps.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: add iterative a matrix to a tuple using Main-Script

    Posted 11/16/11 01:26 PM

    Originally posted by: Ben87


    Thanks for the idea. I should really work more often with tuples.

    Best regards,
    Benjamin
    #DecisionOptimization
    #OPLusingCPLEXOptimizer