Skip to main content

Quadratic Expression

Answered

Comments

4 comments

  • Jaromił Najman
    • Gurobi Staff

    Hi Irem,

    Could you please try using the addGenConstrNorm method to introduce the L2 norm?

    Are you using the latest Gurobi version 11.0.0? If no, please try updating to the latest version if possible.

    Could you please also share a log snippet showing the optimization process?

    I just tried your code on my personal Mac with Gurobi v11 and it reaches a MIPGap of ~0.7% in only a few seconds. What is the required solution quality for your model, i.e., what is a satisfying MIPGap value for your application?

    I can also see the warning

    Warning for adding constraints: zero or small (< 1e-13) coefficients, ignored

    This means that some of the coefficients you compute are very small. If these coefficients are of relevance, you would have to re-scale your model. If they are not of any relevance, I would recommend removing them from the start.

    You should also try adding upper bound for your variables. I don't know the details of your model, but I would guess that an upper bound of 1 might be fitting for most of your variables.

    Best regards, 
    Jaromił

    0
  • İrem Bahtiyar
    • Gurobi-versary
    • First Comment
    • First Question

    Mr. Najman Hi,

    Thank you for your response, I appreciate it! I did not specify MIPGap at first, but now I did and it solved my problem quickly! MIPGap of 0.03 is enough for me. Thank you!

    I am aware of that warning but I could not understand how can I get rid of it. I would appreciate elaboration on this.

    Best,

    İrem

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi İrem,

    I am aware of that warning but I could not understand how can I get rid of it. I would appreciate elaboration on this.

    It may not be easy to detect. One way to find out would be to print every coefficient you compute just to find out which ones are so tiny.

    For example, you could print the values of \(\texttt{price * P}\)

    for j in range(product):
    if price[j] * P[j,j] < 1e-6:
    print(f"index {j} value: {price[j] * P[j,j]}")

    You would have to do this manually for other coefficients you generate. This way, you can detect which coefficients are very small and why and possibly remove them from the model completely. It is usually OK to remove terms with tiny coefficients. However, please note that you can completely remove these terms from your model only if the tiny coefficient don't play a significant role on the model and solution behavior. If these rows are required for the correctness of the application, you should have a look at our Guidelines for Numerical Issues and try to re-scale the model.

    Best regards, 
    Jaromił

    0
  • İrem Bahtiyar
    • Gurobi-versary
    • First Comment
    • First Question

    I understand, let me check my model. Thank you for your help!

    Best,

    İrem 

    0

Please sign in to leave a comment.