Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Variable indexer size for array

    Posted Tue December 15, 2009 11:51 AM

    Originally posted by: NicoGDFSUEZ


    I have the following code in my .mod file :
    {string} C = ...;
    {string} P[C] = ...;

    Then I want to create a variable v which is indexed by C and P[C] like :
    dvar float+ v[c in C, p in Pc];
    But I have the error message "Variable indexer size not allowed for a generic array".

    I found two ways for solving this problem :
    • using tuple pair but it is not very convenient
    • using another data "{string} P1 = ...;" which contains all the string present in P[C] and then define v as "dvar float+ vC,P1;". The problem of this solution is that it create a lot of useless variables and I would like to avoid this !!!

    Does anyone have a "miracle" solution ????
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Variable indexer size for array

    Posted Tue December 15, 2009 11:53 AM

    Originally posted by: NicoGDFSUEZ


    sorry for the type mistake :
    I would like to write : dvar float+ v[c in C, p in P c ; and dvar float+ v C,P1 ;
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Variable indexer size for array

    Posted Mon January 24, 2011 09:52 AM

    Originally posted by: DinuN


    Hi,
    I'm currently facing the same problem, I am trying to define a variable with an index which is varying based on the previous index, and I keep getting the same error "Variable indexer size not allowed for a generic array."

    I want to define a variable- dvar boolean x[i in I][j in J][k in K[j]];.

    Did you happen to find any solution to the problem? Please let me know if you did. Thank you.

    Dinakar
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Variable indexer size for array

    Posted Mon January 24, 2011 10:18 AM

    Originally posted by: SystemAdmin


    Hi,

    what you should try is to define a tupe set "someSet" that contains
    all combinations of "i in I, j in J, k in K[j]" and than define
    your variable set over "someSet, i.e. you have something like
    tuple someTuple{
      int i;
      int j;
      int k;
    }
    {someTuple} someSet = {<i,j,k> | i in I, j in J, k in K[j]};
    dvar boolean x[s in someSet];
    

    (code is not tested)

    Hope this will help.

    Best regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Variable indexer size for array

    Posted Mon January 24, 2011 04:35 PM

    Originally posted by: DinuN


    Thanks Norbert. I did not get any compilation errors, which is good. I'm trying to figure out if it is doing what I want to.
    Thanks a lot for your help again.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Variable indexer size for array

    Posted Tue April 10, 2012 10:42 AM

    Originally posted by: SystemAdmin


    Hi Nobert,

    I faced the same issue, but with a data matrix.
    I had

    int fa in Ab in B = ... ;
    range Ca in Ab in B = 1..f[a][b];
    float T a in Ab in B[c in C[a]b] = ... ;

    But the programme have given me an error on both last lines.
    So I change my structure for the one you suggested.
    Maybe, in a case of data arrays, there is a better solution, but now, I have :

    tuple TripleIndex{int a;int b;int c;}
    {TripleIndex} Index = {<a,b,c> | a in A, b in B, c in 1..C[a][b]};
    float TIndex = ... ;

    But how do I write down data now that I have only one dimension ?
    In other words, how do I say which a,b,c correspond to the floats in my array ?

    Because the structure T = [ [ 1 2 3 4] [ 5 6 7 8] ] ; does not work, of course....

    Thanks a lot

    Adrien
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Variable indexer size for array

    Posted Wed April 11, 2012 02:37 AM

    Originally posted by: SystemAdmin


    Hi,
    I think I found the answer on my on finally...
    That kind of writing should work :

    T = #[
    <a,b,c> : k
    <a',b',c'> : k'
    ...
    ]#;

    That's it...
    But there may be smarter ways to it...

    I'm here listening if that's so...
    #DecisionOptimization
    #OPLusingCPLEXOptimizer