modeling a complex probelm using gurobi api
Answered

Coefficient statistics:
Matrix range [2e-08, 2e+00]
QMatrix range [7e-07, 5e+04]
Objective range [0e+00, 0e+00]
Bounds range [1e+00, 1e+00]
RHS range [1e+00, 1e+00]
Warning: Quadratic constraints contain large coefficient range
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
-
In the above formula, all uppercase variables are related to decision variables, while all lowercase variables are constants. I am willing to provide more information if needed. Any help would be greatly appreciated.
0 -
Hi Jan,
I won't guarantee the details are correct - that is for you to check - but you have the general idea of translating the objective into something that can be used with Gurobi correct.
Generally speaking it is a good idea to give your variables upper and lower bounds - the best bounds you can. This is particularly true for variables in quadratic constraints.
- Riley
0 -
Hi Riley,
I converted my code from an IPOPT + Pyomo format to a GurobiPy format, and it returned that my model is infeasible. Due to numerical issues indicated in the log, I scaled down large numbers (dividing by the mean to ensure the equations hold and there are no numerical problems). However, Gurobi seems to take an exceptionally long time to explore the solution without producing an output (far exceeding the time IPOPT takes to solve the problem, which I don't think is normal). Additionally, my problem does not require finding a solution that satisfies all constraints, so I tried `feasrelax` and passed the constraints I want to relax as parameters, but this also took a long time without producing an solution. I do want to know how to resolve this issue. Alternatively, I would like a solution, similar to IPOPT, where I can get a solution within a limited number of iterations (it does not need to satisfy all constraints, but I still want to move in that direction). Setting a CPU time limit does not seem to achieve this, as I get an "Unable to retrieve attribute 'x'" error when accessing the variables.
0 -
Hi Jan,
IPOPT is a local solver and comparing it to Gurobi is like comparing an Olympic 400m sprinter to me, but I get to stop whenever I feel like it. Using a local solver means not caring about proving the optimality of a solution - this can only be done by global solvers. It doesn't sound like you care about global optimality and so you can instruct Gurobi to focus on finding solutions via parameters, and put less effort into improving the dual bound. I'd try experimenting with NoRelHeurTime, MIPFocus=1, or setting Heuristics to a high value.
If IPOPT is finding solutions quickly and Gurobi is not then the code being incorrect is an explanation I'd explore. Be aware that by default, the lower bound of variables is 0 - I suspect a lower bound of 0 is not valid for many of yours, and this can catch people out.
my problem does not require finding a solution that satisfies all constraints
This is referred to as soft constraints. You can use feasrelax but you will have more control if you simply add a variable to each constraint which allows it to soft, and penalize this variable in the objective function.
- Riley
0 -
Thank you for your reply. I will try the suggestions you provided. I am quite new to optimization problems, and your response has taught me a lot.
If I prefer to get a local solution under large-scale data (one that satisfies most constraints but does not need to satisfy all), can I roughly say that IPOPT is more suitable for my scenario, since my problem may naturally not have a global optimal solution?
0 -
Hi Jan,
All problems have at least one global optimal solution. But yes, if you're already getting ok solutions with IPOPT then continuing to use it seems like the easiest solution.
- Riley
0 -
My company is considering purchasing Gurobi as our solver because the efficiency of IPOPT may not be satisfactory for us. Therefore, I need to make some comparisons. Please allow me to ask some questions on this thread from time to time. Thank you for your response. :)
0 -
Hi Jan,
In your case it would be better to initiate a commercial evaluation with Gurobi, which will ensure you get appropriate answers to your questions and are using Gurobi in the best way - the level of support will be much higher. It is very easy to miss questions posted in the forum, especially for older questions.
Kind Regards,
Riley0
Please sign in to leave a comment.
Comments
8 comments