Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Optimality Target Python

    Posted 10/08/19 08:15 AM

    Originally posted by: Mark Towers


    Hi,

    I have a MIQCP problem and I am using the python wrapper, the file below describes how to set the optimality target however only when you load the model from a file.

    https://github.com/cswaroop/cplex-samples/blob/master/globalqpex1.py

    How do I set the optimality target to global optimal with a python Model

     

    Many thanks,

    Mark


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Optimality Target Python

    Posted 10/08/19 08:36 AM

    You do this the exact same way. You still have an instance of the Cplex class and you use parameters.optimalitytarget.set:

    c = cplex.Cplex()
    # populate the model here
    ...
    c.parameters.optimalitytarget.set(...)

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Optimality Target Python

    Posted 10/08/19 08:45 AM

    Originally posted by: Mark Towers


    Thanks, currently when I make my model in python I dont use the cplex class but the Model class from docplex.mp.model

    Which doesnt have the parameter.optimalitytarget.values variable.

     

    My current code is

    from docplex.mp.model import Model
    
    model = Model("test")
    
    # populate model
    
    model.parameters.optimalitytarget.set(3)
    
    solution = model.solve()
    

     

    However this just throws "Error: model is non-convex" which to me means that the optimality target hasnt worked

     

    Mark

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Optimality Target Python

    Posted 10/08/19 11:05 AM

    Can you show us the first twenty lines or so of the engine log? This will show us the non-default parameters that are set and we can verify whether the parameter is being set correctly. With docplex, you can do this by setting log_output=True when creating the model (see here).


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Optimality Target Python

    Posted 10/08/19 11:19 AM

    Originally posted by: Mark Towers


    CPXPARAM_Read_DataCheck                          1
    CPXPARAM_OptimalityTarget                        3
    Warning: Value CPX_OPTIMALITYTARGET_OPTIMALGLOBAL for CPXPARAM_OptimalityTarget is only available for QP and MIQP.
    CPLEX Error  5002: 'q1' is not convex.
    Presolve time = 0.00 sec. (0.01 ticks)
    Root node processing (before b&c):
      Real time             =    0.01 sec. (0.01 ticks)
    Parallel b&c, 4 threads:
      Real time             =    0.00 sec. (0.00 ticks)
      Sync time (average)   =    0.00 sec.
      Wait time (average)   =    0.00 sec.
                              ------------
    Total (root+branch&cut) =    0.01 sec. (0.01 ticks)
    Error: Model is non-convex
    CPLEX Error  1217: No solution exists.
    CPLEX Error  1217: No solution exists.

    So I know that the problem does have a solution because I have programmed the same model in the cp version of cplex.

    Looking at the Q1 constraint, it is (constant / variable) + (constant / variable) <= constant

    However due to mp not liking division by variable, the equation is reformatted to constant * variable + constant * variable <= constant * variable * variable

    Mark


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Optimality Target Python

    Posted 10/08/19 11:34 AM

    Your model has non-convex quadratic constraints (as the error message indicates). This is not supported by CPLEX. Only non-convex quadratic objectives are supported.

    Setting the parameter worked (you get the warning that it does not apply to this model) but it cannot cure the problem of non-convex quadratic constraints.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Optimality Target Python

    Posted 10/08/19 11:38 AM

    Originally posted by: Mark Towers


    Ohh, thanks for the clarification. 

    I had read this article which says that it is possible. 

    https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.9.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/mip_quadratic/03_introMIQCP.html

    However, I notice now that the quadratic term in a constraint involves only multiplication of binary variables which mine does not.

     

    Thanks for your help,

    Mark


    #CPLEXOptimizers
    #DecisionOptimization