Decision Optimization

 View Only
Expand all | Collapse all

How to get CPLEX solution without any rounding

  • 1.  How to get CPLEX solution without any rounding

    Posted Thu December 29, 2022 03:51 AM
    Edited by System Test Fri January 20, 2023 04:35 PM
    Dear All,
    Is there any code or syntax to get the solution value from the CPLEX without any rounding?
    What I mean is for example, λ (objective_lambda) from the CPLEX calculation is 0.00494835681 instead of 0.005.
    By the way, I use python in pycharm with CPLEX library.
    If yes, could you share the python syntax for non-rounding solution value, please?
    image.png

    Thank you.
    Yours sincerely,
    Nicholas

    #DecisionOptimization


  • 2.  RE: How to get CPLEX solution without any rounding

    Posted Thu December 29, 2022 05:17 AM
    I think you refer to the display precision of the model/solution printer, which is by default 3. (docplex does not round any value except the integer values, which can be controlled)
    You can change the printing precision with 
    mdl = Model(float_precision = n)


    ------------------------------
    Vincent Beraudier
    ------------------------------