Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Dynamic array length.

    Posted 09/23/09 05:15 PM

    Originally posted by: SystemAdmin


    [philippe said:]

    I've a problem with array lengths in OPL.

    From the C++ API one can do something like this:


    struct Container
    {
      std::vector<float> floats;
    };

    void test()
    {
      std::vector<Container> containers;
     
      IloEnv env;
      IloArray<IloNumVarArray> vars( env );

      for ( int i = 0; i < containers.size(); ++i ) {<br />    vars.add( IloNumVarArray( env ) );

        for ( int j = 0; j < containers&#91;i&#93;.floats.size(); ++j ) {<br />      vars[i].add( IloNumVar( env ) );
        }
      }
    }


    The lengths of the inner float vectors don't have to be the same. Works fine and saves some variables.

    Not so with OPL:


    tuple Container
    {
      {float} floats;
    }

    {Container} containers = ...;

    float vars[i in containers][j in i.floats] = 0;


    The code gives the following error:
    [b]
    Variable indexer size not allowed for a generic array.
    [/b]

    Any idea how to work around this? Otherwise I've to find out the longest float set and constrain the unused variables to something reasonable...

    Thanks for any hints.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Dynamic array length.

    Posted 10/05/09 07:30 PM

    Originally posted by: SystemAdmin


    [jfk said:]

    hello,
    I hate bringing bad news: but you can't do dynamic arrays in OPL, you have to create the whole 2D array with the max length (sort of suggested already).


    cheers
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Dynamic array length.

    Posted 10/05/09 07:45 PM

    Originally posted by: SystemAdmin


    [philippe said:]

    Ok, thanks for the answer. At least I know it for sure now ;-)

    Is there any hope to have this feature implemented in a future release or is it a language limitation that won't be overcome?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Dynamic array length.

    Posted 10/07/09 04:51 PM

    Originally posted by: SystemAdmin


    [jfk said:]

    Hello,
    the clear and loud answer is: yes, in the future it will be there. However, what is not clear when it can happen... It brings lots of benefits not just convenience...

    cheers

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Dynamic array length.

    Posted 10/07/09 05:08 PM

    Originally posted by: SystemAdmin


    [philippe said:]

    Thanks for the info. I'm really looking forward to it.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Dynamic array length.

    Posted 10/08/09 09:53 PM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Hi,

    the suggested way today when you deal with sparse structures is to use tuple sets.

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Dynamic array length.

    Posted 10/08/09 09:59 PM

    Originally posted by: SystemAdmin


    [afleischer said:]

    Let me give you some details:



    tuple Container
    {
      {float} floats;
    }

    {Container} containers = ...;

    tuple t
    {
    Container c;
    float f;
    }

    {t} s={<i,j> | i in containers, j in i.floats};

    and then you have a light array

    float vars[s] = 0;


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Dynamic array length.

    Posted 10/15/09 02:18 PM

    Originally posted by: SystemAdmin


    [philippe said:]

    Thanks for the details!

    As long as the feature isn't available I'll use the suggested workaround.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer