Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Quadratic expression

    Posted 12/04/15 09:42 AM

    Originally posted by: Rajasekhar_Kadambur


    Hi, I am trying to model quadratic expression in CONCERT technology using C#.

    In OPL, CPO supports bilinear term. i am trying to replicate the model in concert.

    I got struck with the following issue, please help in this

     

    ILinearNumExpr[, ] ctEq23Expr = new ILinearNumExpr[period, resources];

    //ILQNumExpr[, ] ctEq23Expr = new ILQNumExpr[period, resources];

    for (var i = 0; i < period; i++)
       {
          for (var r = 0; r < resources; r++)
             {

                   ctEq23Expr[i,r] = cp.LinearNumExpr();

              }

       }

    where ctEq23Expr = X[i,r] * Y[i,r];   // integer decision variables

     

    how to model the quadratic expression in concert for CPO using C#. thanks in advance.


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Quadratic expression

    Posted 12/04/15 11:11 AM

    Originally posted by: Petr Vilím


    Hello,

    you don't need to use any special class for quadratic expressions. You can use just IIntExpr and INumExpr for all kinds of expressions, including the quadratic ones. A quadratic term can be created by multiplication: function cp.Prod. You can also have a look on examples in directory examples/src/csharp.

    Just a side note: CP Optimizer supports all kind of expressions that could be created and combined by many operators and functions including absolute value, element expression etc. The only thing that must be taken into account is whether it is an integer expression (IIntExpr) or floating-point expression (INumExpr).

    Best regards, Petr


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Quadratic expression

    Posted 12/07/15 01:36 AM

    Originally posted by: Rajasekhar_Kadambur


    Hi Petr, thanks a lot for your help and quick response.

    I do have a small doubt about the performance of CPO with using OPL and Concert C#.

    I have modeled the same formulation in OPL and concert C# where opl CPO gives 1 solution with objective 16045 in 300 sec, where as concert CPO gives 35 solution with objective 14964 in 300 sec.

     

    you may say that there may be a problem in the constraints modeling. the formulation give the same objective in OPL CPLEX and concert CPLEX. if i solve the same formulation using the CP, i am facing this experience as explained earlier.



    please share your comments on this.


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: Quadratic expression

    Posted 12/07/15 03:51 AM

    Originally posted by: Petr Vilím


    Hello,

    even with the same model, the performance can vary depending on the order of declaration of variables and constraints. It could be that in this particular case CPO is more sensitive to the ordering than CPLEX. Hard to say.

    The problem can be modelled using different APIs, in C#, OPL etc, but the underlying CPO solver is always the same. Given the same model it should give the same result regardless the API used. Especially in case of OPL though the ordering of constraints my be different than what you expect. OPl can also make some preprocessing that is not done in C#. So I suggest two things:

     

    1. Check whether the two models (C# and OPL) are really the same. The easiest way is to dump your model in .cpo file format and compare the results. Dumped models are text files that describe exactly the input given to the CPO after processing through different APIs. I suggest to use ILC_MODEL_DUMP_FILE environment variable for this. Set this variable to a name of a file with extension .cpo (including path if you want). When CPO solves a problem and the variable is set then it dumps the model into the file before the solve starts (it works regardless the API used, i.e. also in OPL and C#). Note that in C++, C# and Java you can also import a such dumped model using function importModel.

     

    2.  Check what is the performance variability of your model. It could be that in some settings (e.g. random seed) CPO can be very lucky/unlucky.  When performance variability is high then even slight change of the model could have dramatic impact on the performance. Even a change that should not have any real impact such as ordering of constraints. To test the performance variability run your model on multiple random seeds (parameter RandomSeed). You can do that for both OPL and C# model to see whether one of them really dominates the other or if it was just a coincidence.

     

    Best regards, Petr


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: Quadratic expression

    Posted 12/07/15 05:13 AM

    Originally posted by: Rajasekhar_Kadambur


    Thanks for your suggestion Petr, I will try the approaches you suggested


    #CPOptimizer
    #DecisionOptimization