Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Simple Python API syntax question

    Posted 12/07/11 12:20 AM

    Originally posted by: Eumpfenbach


    I stop my problem when I find the first feasible solution. I want reference the objective gap in the python API (something like "while gap > # do ...").

    I've messed around with it for over a half hour so I just figured I'd ask. solution.quality_metric.objective_gap seems like where the information would be but it doesn't have a get() method.

    If I use solution.get_quality_metrics() it gives me the gap but I am not sure how to reference just this one number, since this function seems to print a list.

    So yeah, I just want the gap at the time the solver stops. Absolute or relative will both work fine.

    Thanks,
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Simple Python API syntax question

    Posted 12/07/11 05:12 AM

    Originally posted by: SystemAdmin


    The relative gap is available via
    c.solution.MIP.get_mip_relative_gap()
    

    The absolute gap is (for minimization)
    c.solution.get_objective_value() - c.solution.MIP.get_best_objective()
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Simple Python API syntax question

    Posted 12/07/11 02:45 PM

    Originally posted by: Eumpfenbach


    Thank you.

    I was using dir(cpx.solution) and missed MIP because it is listed before all the __ ... __, whereas all the other attributes are listed after.
    #CPLEXOptimizers
    #DecisionOptimization