Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Scripting parser error?

    Posted 06/17/14 11:16 PM

    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? 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
    #MathematicalProgramming-General


  • 2.  Re: Scripting parser error?

    Posted 06/18/14 12:57 AM

    OPL questions like this should go to the OPL Forum here.

    I am not an OPL expert. Could it be that you cannot use 'sum'  in a scripting block? One thing that works without problem for me is

    execute {
       var numerator = 0;
       var denominator = 0;
       for (var i in idtot) { numerator += vol[i][2][2]; denominator += vol[i][1][2]; }
       kband = numerator / denominator;
    }


    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: Scripting parser error?

    Posted 06/18/14 01:27 AM

    Originally posted by: TracyLLL


     

     Daniel,

    Thank you for your answer. Your suggestion works well.

    I would like to figure out if 'sum' cannot be used in scripting block. I will move this post to the OPL forum.

    Thanks!

     

     


    #DecisionOptimization
    #MathematicalProgramming-General