Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  range with step

    Posted 05/25/18 02:44 AM

    Originally posted by: Marko_Obert


    Hi,

     

    I want to create a range with a step, similar to e.g. numpy.arange (https://docs.scipy.org/doc/numpy/reference/generated/numpy.arange.html)

    start = 1

    stop = 3

    step = 0.5

    to obtain a range of: 1.0, 1.5, 2.0, 2.5

     

    According to the documention https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.5.1/ilog.odms.ide.help/OPL_Studio/opllang_quickref/topics/tlr_opl_range.html it is possible to define a range of type "float"

    "range float 1.0 ... 2.0 "but I can not find a paramter to define the step.

     

    If this is not possible, I would like to try an alternative solution, but I'm also not sure how to achieve it.

     

    in common.mod I create an hours tuple:

     

    {float} Hours= ...;    ## [1, 1.5, 2.0, 2.5.... 8759.5, 8760] 

     

    Is it somehow possible to "slice" an subset of this tuple

    start = 4000

    stop = 4002

    e.g. subset = Hours[start:stop] ? => subset = [4000.0, 4000.5, 4001.5]

     

    Kind regards,

    Marko

     

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: range with step

    Posted 05/25/18 07:31 AM

    Instead of a "range with step" you can use a set:

    int start = 1;
    int stop = 3;
    float step = 0.5;
    {float} values = { start + i * step | i in 0..ftoi(ceil((stop - start) / step)) };

    As for array slicing, a set should do as well:

    {float} hours = { 1., 2., 3., 4., 5., 6., 7., 8. };
    int sstart = 2;
    int send = 3;
    {float} subset = { item(hours, i) | i in sstart..send };

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: range with step

    Posted 05/25/18 07:37 AM

    Originally posted by: Marko_Obert


    Nice, thank you :-)


    #CPLEXOptimizers
    #DecisionOptimization