Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  'sum' cannot be used in script block?

    Posted 06/18/14 01:29 AM

    Originally posted by: TracyLLL


    Hi There,

    I was debugging my OPL program and kept getting this error msg:

    Scripting parser error: missing ')' at the following line:

    kband=sum(i in idtot)vol[i][2][2]/sum(i in idtot)vol[i][1][2];

    Though I don't see a problem here, I tried adding parenthesis and revise it to the following (or similar) but still failed.

    kband=(sum(i in idtot)vol[i][2][2])/(sum(i in idtot)vol[i][1][2]);

    Can anyone tell what the problem was? Can't I use 'sum' in script block? Thanks a lot!

    The related code block and the whole structure are as follows:

     

    int vol[idtot][apid][LTRid]=...;

    float kband;
    ...
     
    execute precal_vol{
            kband=sum(i in idtot)vol[i][2][2]/sum(i in idtot)vol[i][1][2];
            for(var in idtot){
                    for(var in apid){
                            ...
                    }
            }
    }

    dvar...

    minimize
            ...;
    subject to{
            ...;
    }

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: 'sum' cannot be used in script block?

    Posted 06/18/14 11:52 AM

    Hi,

    indeed sum is for OPL and not for the scripting part.

    What you can write is

    float kband=sum(i in idtot)vol[i][2][2]/sum(i in idtot)vol[i][1][2];

    in the OPL part

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: 'sum' cannot be used in script block?

    Posted 06/19/14 09:59 AM

    Originally posted by: TracyLLL


    Thanks a lot! This helps!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer