Skip to main content

Obtain a feasible solution but there are constraints that are not met.

Answered

Comments

1 comment

  • Michel Soares
    Gurobi-versary
    Thought Leader

    Hi Dominico,

    It is likely that, if the constraints are being violated at all, it is by a very small margin. Numerical issues are a big topic in computer science, it arises from the simplest problem such as comparing two floating number to more complex calculations done in a mathematical solver.

    You may check if that is indeed the case adding an error margin, for example:

    for temperature in temperature_type:
        for city in cities:
            for period in periods:
                for period2 in periods:
                    print((ycity[temperature,city,period,period2].x* big_M  + (period2 - deliverytime_city[city,period,temperature].x) >= (0 -0.0001) ))
                    print(((1-ycity[temperature,city,period,period2].x)* big_M) - (period2 - deliverytime_city[city,period,temperature].x) >= (1 -0.0001))

     

    If you need more precision, you may want to change the NumericFocus parameter.

    There are also two warning that you should look at, which can greatly improve the solver time of your model as well as the precision:

    Coefficient statistics:
      Matrix range     [4e-02, 1e+20]
      Objective range  [1e+00, 3e+01]
      Bounds range     [1e+00, 1e+00]
      RHS range        [1e+00, 1e+20]
    Warning: Model contains large matrix coefficient range
    Warning: Model contains large rhs
             Consider reformulating model or setting NumericFocus parameter
             to avoid numerical issues.

    There are 2 warnings regarding big ranges in matrix coefficients and RHS. This can makes your model a lot slower to solve and may lead to greater numerical issues.

    It is recommended that you keep your coefficients range small. Your "big M" may be too big (I have a feeling you are using 1e+20). You should try to keep it as small as possible to satisfy your model. This "big M" might vary from constraint to constraint, for example, and be based on the maximum/minimum value the other terms may have.

    1

Please sign in to leave a comment.