Decision Optimization

Decision Optimization

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


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

Why does this model solve interactively but not when called via .net API?

  • 1.  Why does this model solve interactively but not when called via .net API?

    Posted 01/15/13 12:54 PM

    Originally posted by: SystemAdmin


    Hi,

    We build up our model constraints in code from user input. A recent addition has been a quadratic constraint representing a "least square" matching constraint. This has given us problems when we come to solve the model. We solve the LP problem first and then switch to a MIP and solve again.

    I've stripped the model right back to include just the new quadratic constraint (see x.lp, attached) and have observed the following:

    If I use the interactive optimiser, I can load the model, optimise it, switch the problem type to miqcp and run mipopt to get an optimised solution.

    If I write a most basic code snippet in CSharp to import the model and call Solve, the method returns quickly with false and the status is set to Unknown.

    Relaxing the RHS of the constraint even by by 0.0001 allows the model to solve as an LP using the API. However, this is a very basic model whereas the real-life ones will include many more vars and larger weightings so I'd like to understand what the issue is before allowing tolerances on the RHS when the user doesn't actually specify one - they can specify an exact match.

    Not sure if it's related, but we've also noticed some models that do solve taking significantly longer to solve using the API as opposed to interactively.

    Thanks in advance,
    Neil
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Why does this model solve interactively but not when called via .net API?

    Posted 01/16/13 02:46 AM

    Originally posted by: SystemAdmin


    Does the problem persist if you use .sav files instead of .lp files (your coefficients are non-integral and thus using .lp files may introduce undesired round-off)?
    When I solve your x.lp in the interactive I get
    42   3.1248662e+03   3.1248535e+03  5.97e-08  0.00e+00  3.03e-09  7.12e+04
     
    Barrier - Non-optimal:  Objective =  3.1248661625e+03
    

    As you can see, barrier stops with a non-optimal solution.
    When I solve x.lp with this java snippet (which should be equivalent to .NET)
    IloCplex cplex = new IloCplex();
    cplex.importModel(args[0]);
    System.out.println("Solve: " + cplex.solve());
    System.out.println("Status: " + cplex.getStatus());
    System.out.println("CPLEX status: " + cplex.getCplexStatus());
    cplex.end();
    

    then I get
    42   3.1248662e+03   3.1248535e+03  5.97e-08  0.00e+00  3.03e-09  7.12e+04
    Solve: false
    Status: Unknown
    CPLEX status: NumBest
    

    which is consistent with the interactive.

    Do you get an optimal solution status in the interactive from barrier?
    What does GetCplexStatus() return for you?
    #CPLEXOptimizers
    #DecisionOptimization