Decision Optimization

 View Only
  • 1.  Why is a*a not equal to a^2

    Posted Thu April 01, 2010 05:31 AM

    Originally posted by: SystemAdmin


    Howdy,

    what is "a^2" in the context of ILOG-script?
    For sure not what "a*a" as the following
    code snippet indicates.
    execute{
    writeln(4^2);
    writeln(5^2);
    writeln(6^2);
    writeln((3.4)^2);
    }

    yields the following output

    6
    7
    4
    1

    I'm a bit confused?

    Can I be sure that

    dexpr float xxxx = sum(a in someSet) (x[a] - 1.0)^2

    does the right job?

    Best regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Why is a*a not equal to a^2

    Posted Thu April 01, 2010 04:20 PM

    Originally posted by: Ed Chamberlayne


    Hello Norbert. Could you use the "pow" OPL function instead?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Why is a*a not equal to a^2

    Posted Tue April 06, 2010 03:12 AM

    Originally posted by: SystemAdmin


    Sure, pow() does the job properly,m as well as a*a.
    But I am still wondering what ^2 is doing?

    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Why is a*a not equal to a^2

    Posted Tue April 06, 2010 03:41 AM

    Originally posted by: SystemAdmin


    Inside execute blocks you are using JavaScript (aka ECMAScript, ECMA-262).
    Here '^' is the XOR operator, see http://en.wikipedia.org/wiki/JavaScript_syntax#Operators.

    Tschau, Frank
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Why is a*a not equal to a^2

    Posted Tue April 06, 2010 04:03 AM

    Originally posted by: SystemAdmin


    Frank,

    thanks- that explains the behaviour.

    Regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  RE: Re: Why is a*a not equal to a^2

    Posted Thu April 25, 2024 10:23 AM

    agreed.



    ------------------------------
    Anthony Clement
    ------------------------------