Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

Root square and logarithm functions in OPL studio

  • 1.  Root square and logarithm functions in OPL studio

    Posted 07/20/14 02:24 PM

    Originally posted by: CMP-SFL


    Dear all,

    In a linear programming problem, I want to use the root square and logarithm functions.

    I found a list of all functions in the following page:


    http://pic.dhe.ibm.com/ infocenter/cosinfoc/v12r2/ index.jsp?topic=%2Filog.odms. ide.help%2FContent% 2FOptimization% 2FDocumentation%2FOPL_Studio% 2F_pubskel%2Fglobals% 2Feclipse_and_xplatform%2Fps_ opl749.html

    Two functions "log" and "sqrt" fulfill the needs. However, I don't know how to use them. Could you please help me on that?

    Below, I'have put the reduced models to illustrate the case.

    // Begin of Model 1
    minimize sum(m in Unit) varaiable2[m] ;

    subject to
    {
    forall(m in Unit) varaiable2[m] >= (varaiable1[m] - Parameter[m])^(1/2) ;
    }

    main {
        cplex.solve();
        var UB = cplex.getObjValue();
        var LB = cplex.getBestObjValue();
        }
    // End of Model 1




    // Begin of Model 2
    minimize sum(m in Unit) varaiable2[m] ;

    subject to
    {
    forall(m in Unit) log(varaiable2[m]) >= log (varaiable1[m] - Parameter[m]) ;
    }

    main {
        cplex.solve();
        var UB = cplex.getObjValue();
        var LB = cplex.getBestObjValue();
        }
    // End of Model 2



    Many thanks in advance,

    Best regards

    Mehdi


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Root square and logarithm functions in OPL studio

    Posted 07/21/14 03:45 AM

    Hi,

    here an example of the syntax:

    float s=sqrt(100);
    float l=log(100);

    execute
    {
    writeln(s);
    writeln(l);
    }

     

     

    If you want to use the square root or the log of a decision variable, maybe you should rather use CPO and write use CP; at the beginning of your model

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Root square and logarithm functions in OPL studio

    Posted 07/21/14 08:29 AM

    Originally posted by: CMP-SFL


    Hi,

    Thanks for the answer.

     

    I have never used CP optimizer. By looking at OPL examples, I added using CP; at the beginning of the model, and I got other errors. I think, the syntax must be changed!

    The models I use are simple. I put again the gist of the models below. Do you know how to put the model in the right format in order to use sqrt and log functions? Thanks again!

    // Begin of Model 1

    float Parameter [Unit]=...;

    dvar float+ varaiable1[Unit];

    dvar float+ varaiable2[Unit];

     

     

    minimize sum(m in Unit) varaiable2[m] ;

     

    subject to

    {

    forall(m in Unit) varaiable2[m] >= (varaiable1[m] - Parameter[m])^(1/2) ;

    }

     

    main {

        cplex.solve();

        var UB = cplex.getObjValue();

        var LB = cplex.getBestObjValue();

        }

    // End of Model 1

     

    // Begin of Model 2

    float Parameter [Unit]=...;

     

    dvar float+ varaiable1[Unit];

    dvar float+ varaiable2[Unit];

     

    minimize sum(m in Unit) varaiable2[m] ;

     

    subject to

    {

    forall(m in Unit) log(varaiable2[m]) >= log (varaiable1[m] - Parameter[m]) ;

    }

     

    main {

        cplex.solve();

        var UB = cplex.getObjValue();

        var LB = cplex.getBestObjValue();

        }

    // End of Model 2


    #DecisionOptimization
    #OPLusingCPLEXOptimizer