Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Functions, arrays and vectors in OPL script

  • 1.  Functions, arrays and vectors in OPL script

    Posted 07/25/13 05:44 AM

    Originally posted by: Nicolas33


    Hello,

     

    I have a question in OPL script, I would like to declare a vector of integer in a main script block (or an execute) is it possible?

    I usually declare such arrays and a fixed size in preamble, but it is not possible in my case, because the size of the vector change..

    Do you have a solution?

     

    If I declare it in a function, is it a local variable that is suppressed after the end of the function?

    Thanks,

    nicolas


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Functions, arrays and vectors in OPL script

    Posted 07/25/13 11:05 AM

    Hi,

     

    in scripting  when an element of an array is set beyond the current length of the array, the array is automatically expanded.

    main
    {
     var a=new Array(1);
     a[1]=2;
     writeln(a.length);
     a[5]=4;
     writeln(a.length);
    }

     

    gives

    2

    6

    You should have a look at

     

    in the documentation


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Functions, arrays and vectors in OPL script

    Posted 07/29/13 07:55 AM

    Originally posted by: Nicolas33


    Thank you very much!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer