Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Format output in Scripting Log? Using SheetWrite command Question?

    Posted 02/25/10 02:59 PM

    Originally posted by: Ed Chamberlayne


    Two questions:

    1. Does anyone know how to format the data precision output in the scripting log? I would like to restrict the data output to 0.00 (the hundredths position) but can't seem to figure out how to do this from the documentation.

    2. Additionally, does anyone know how to use the SheetWrite command to write only one component of a variable's output? For instance if variable x is defined over a set C of 5 cells and over time range T (float+ xhttp://C,O..T), how would I write the output for just the x variable for Cell 1 for all time periods using the SheetWrite command?

    Thank you,

    Ed
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Format output in Scripting Log? Using SheetWrite command Question?

    Posted 02/26/10 02:07 AM

    Originally posted by: SystemAdmin


    Ed,

    just an answer to your first point.
    OPL does not (yet?) support formatted output. You will have
    to write your own function (based on string manipulation).
    I enclose a function I used a couple of years ago.

    Hope that this will help.

    Best regards
    Norbert

    function toFixed(v, prec) {
    var m = Opl.pow(10,prec);
    var s = "" + Opl.round(m * v) / m;
    var idx = s.indexOf(".");
    if(idx >= 0 && idx+prec < s.length)
    {
    s = s.substring(0,idx+prec+1);
    }
    return (s);
    }
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Format output in Scripting Log? Using SheetWrite command Question?

    Posted 02/26/10 02:39 AM

    Originally posted by: SystemAdmin


    It depends what you are displaying, it you print float values inside OPL elements, like sets and arrays, the OPL setting displayPrecision can be used.

    The ECMA-262 standard (aka JavaScript) does not provide any means to control the display precision for number objects in the scripting scope, it uses "%.16g".
    trebon's workaround seems the best solution here.

    More details on settings.displayPrecision here:
    http://publib.boulder.ibm.com/infocenter/oplinfoc/v6r3/topic/ilog.odms.ide.help/html/refjsopl/html/IloOplSettings.html#displayPrecision
    and: http://publib.boulder.ibm.com/infocenter/oplinfoc/v6r3/topic/ilog.odms.ide.help/Content/Optimization/Documentation/OPL_Studio/_pubskel/globals/eclipse_and_xplatform/ps_opl1035.html

    Tschau, Frank
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Format output in Scripting Log? Using SheetWrite command Question?

    Posted 02/26/10 10:45 AM

    Originally posted by: Ed Chamberlayne


    Norbert,

    Thanks! Where would I paste this function? In the .mod or .dat file? There seems to be a lot of syntax errors when I paste this into the .mod file.

    How would I use this function in my "execute DISPLAY" section? I would assume something like - "write(toFixed(x,prec))..."

    Ed
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Format output in Scripting Log? Using SheetWrite command Question?

    Posted 03/01/10 03:32 AM

    Originally posted by: SystemAdmin


    Ed,

    first of all the function has to be coded in a mod-file.

    What I have is a mod-file that is shared between several
    OPL-projects (call it shared_functions.mod - ar alike).
    In this mod file you should have soemthing like :
    execute Utilities{
    function toFixedPrecision(v, prec) {
    // as posted above ....
    }
    }

    The extra file is not required but convenient ...

    In the mod-file representing the current math model
    (whatever.mod) should have a

    include "shared_functions.mod";

    In whatever.mod you use the function as you indicated

    execute{
    writeln(x, " = ", toFixed(x,2));
    }

    In case that you still get errors please sedn me a
    simplified OPL-project by personal mail. I will have
    a look at it.

    Hope that helps.

    Best regards
    Norbert
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Format output in Scripting Log? Using SheetWrite command Question?

    Posted 03/01/10 10:53 AM

    Originally posted by: Ed Chamberlayne


    Norbert - That works great! Thanks a lot!

    Ed
    #DecisionOptimization
    #OPLusingCPLEXOptimizer