--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/CAGnfZd7Nwt5NFWLmWcxnC%3DSD6wY6_Set1xrtRG-3ozosEe10eA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4894776144-1635174130-138289977%40helpscout.net.
Hello Sir,
Thank you for responding. I have tried to look at my codes again but I still can't understand the results that I am obtaining. In fact, my intention is to find the value of c,r, C_HC, and r_HV that give the highest profit. For the second time, I run the problem using the obtained value of c,r, C_HC, and r_HV as parameters to solve the optimization problem in the objective function to obtain the optimal profit and all the variables. Please help me to fix the issue. If possible please can you help me also to find a way to run the problem at once and get the results in MS Excel?
Attached are the files of my program.
Sincerely,
Davids
On Mon, Oct 25, 2021 at 3:01 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
When these messages appear, Gurobi has determined that the dual of your problem is infeasible: there is no way to assign values to the variables of the dual problem that will satisfy all constraints of the dual problem. Dual infeasibility implies that the original (primal) problem is either also infeasible, or is unbounded -- but Gurobi can't immediately tell which. (See "Infeasible or Unbounded" for a more detailed explanation.)
To get more specific help, replace your "option gurobi_options" command with these two commands:
option show_stats 1;
option gurobi_options 'outlev=1 nonconvex=2';
Then solve, and you will get a lot more output. Copy all of it from your terminal or console window, and paste it into a reply to this forum.
--
Robert Fourer
am...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4905396593-1635362031-227650359%40helpscout.net.
ampl: include Foodmarket2.run Presolve eliminates 2737 constraints and 2231 variables. Adjusted problem: 738 variables: 219 nonlinear variables 519 linear variables 980 constraints; 2642 nonzeros 139 nonlinear constraints 841 linear constraints 498 equality constraints 482 inequality constraints 1 nonlinear objective; 245 nonzeros. Gurobi 9.1.2: outlev=1 nonconvex=2 Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (win64) Thread count: 2 physical cores, 4 logical processors, using up to 4 threads Optimize a model with 841 rows, 738 columns and 1947 nonzeros Model fingerprint: 0x788ee70a Model has 72 quadratic objective terms Model has 139 quadratic constraints Coefficient statistics: Matrix range [3e-01, 1e+02] QMatrix range [1e+00, 7e+06] QLMatrix range [1e-03, 2e+05] Objective range [1e+00, 3e+06] QObjective range [1e+00, 2e+01] Bounds range [6e+00, 3e+03] RHS range [1e-07, 2e+02] QRHS range [1e-08, 5e+07] Presolve removed 144 rows and 19 columns Presolve time: 0.01s Barrier solved model in 0 iterations and 0.01 seconds Model is infeasible or unbounded Gurobi 9.1.2: infeasible or unbounded
Thank you so much for the direction.
I have identified the variable that was not in the objective function but still when I run the problem I obtain a solution that I don't understand well. Can you help me again? Attached is my new codes
On Wed, Oct 27, 2021 at 7:13 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
All of your optimization problems are being rejected by Gurobi as "infeasible or unbounded". However when I delete the objective function, then Gurobi does find a feasible solution. Thus it appears that your problems are unbounded: for any number M, no matter how large, there are feasible values of the variables that make your objective function larger than M. In general, unboundedness indicates that there is some kind of error in your model, which you will have to fix. There is no simple and easy way to determine the cause of unboundedness, but here are some tests that are often helpful.
First, for each variable in your objective function, check that it appears in the constraints somewhere. And for each term that is being summed to form your objective function, check that the constraints do not allow it to become infinitely large.
If the above checks do not reveal the problem, then proceed as follows. Choose M large enough that it's a value that you would not expect a variable to have in a proper optimal solution. For each variable that is not defined with a lower bound in your model, add a lower bound of -M, and for each variable that is not defined with an upper bound in your model, add an upper bound of M -- where M is some large number. (For example, "var P_b_tom {TT} >= -100000 <= 100000;".) With these bounds, Gurobi will find a finite solution. In the solution, look for variables that equal -M or M; they are the ones that were not being properly bounded by your model.
--
Robert Fourer
am...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4921871477-1635774852-1886371471%40helpscout.net.
ampl: include Foodmarket3.run Gurobi 9.1.2: nonconvex=2 Gurobi 9.1.2: optimal solution; objective -10330657.64 31013 simplex iterations No basis. No dual variables returned. Gurobi 9.1.2: nonconvex=2 Gurobi 9.1.2: optimal solution; objective -10923740.76 46105 simplex iterations No basis. No dual variables returned. Gurobi 9.1.2: nonconvex=2 Gurobi 9.1.2: optimal solution; objective -11266288.97 20471 simplex iterations No basis. No dual variables returned. Gurobi 9.1.2: nonconvex=2 Gurobi 9.1.2: optimal solution; objective -11497948.79 28768 simplex iterations No basis. No dual variables returned. Gurobi 9.1.2: nonconvex=2 Gurobi 9.1.2: optimal solution; objective -11670676.71 25599 simplex iterations No basis. No dual variables returned.
for {cval in 2..C_Max, rval in 1..R_Max, N_HC_val in 2..N_HC_Max, r_HV_val in 1..R_HV_Max} { ...Hello Sir,
I have tried to revise my problem again by if all of the variables in the objective function are also in the constraints and I fixed some flows. The program is running very slowly without terminating. Can you help me to check once again?
Sincerely Yours,
Davids
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4934269351-1636048385-1642476003%40helpscout.net.
Is there any possibility that you can recommend obtaining the value of c, r, N_HC, and r_HV that gives the optimal solution without solving in a loop? I need your help, please!
Davids,
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4944981691-1636403852-77135041%40helpscout.net.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4944981691-1636403852-77135041%40helpscout.net.
var N_HC integer >= 1, <= N_HC_Max;
subject to pzero_HV{t in TT}:
P_0_hv[t] = (sum{i in 0..(N_HC-1)}((((N_HC*Start_hv[t])^i)/(fact[i]))) +
(((N_HC*Start_hv[t])^N_HC)/(fact[N_HC]))*
((1 - (Start_hv[t]*(m_hv[t]^(r_HV))))/(1-Start_hv[t])) )^-1;The Gurobi log shows the following message (when outlev=1 is set):
Continuous model is non-convex -- solving as a MIP.
So I had the idea to use the Gurobi option bestbndstop=r, which only works with MIP (branch-and-bound) solves. This option stops the optimization as soon as the upper bound (for a maximization) is <= r. So if you set r to the best optimal objective value seen so far, then when the loop tries other values of c, r, N_HC, r_HV, the optimization will be stopped as soon as the MIP algorithm proves that the objective cannot be improved using those values.
However, when I implement this idea using Gurobi, I get error messages indicating that there may be a bug. I am reporting this problem now, and hopefully it will be fixed soon; I will post an update here when there is a fix available. Until then, your best bet may be to just wait for all 7200 problems to solve.
Currently Gurobi is the only solver that uses a MIP approach to solve non-convex continuous quadratic problems to global optimality, and that has an option like bestbndstop.
See also my follow-up in the next message.
--
Robert Fourer
am...@googlegroups.com
On Fri, Nov 12, 2021 at 2:23 PM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
Hello Sir,
I would like to know the optimal value (the optimal profit of the objective function, and the optimal value of the variables) for only the choice of variables that is best. I only need to know the optimal value for the choice that is best. Is there any possibility of solving with integer variables the value of c, r, N_HC, and r_HV without using the for loop? Can you please suggest to me the way to greatly reduce the Gurobi solving time? I need your help please.
Sincerely,
Leon
On Tue, Nov 9, 2021 at 1:42 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:In the model, I would like to consider -- c, r, N_HC, and r_HV -- as variables of the problem and solve to know the optimal value of my model (the optimal profit of the objective function, and the optimal value of the variables) for only the choice of variables that is best. I only need to know the optimal value for the choice that is best. Please suggest to me the way to greatly reduce the Gurobi solving time.
I also have Minos solver and cplex if any combination can work better than gurobi, I can consider it.
On Mon, Nov 8, 2021 at 8:37 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
It would be possible to make one or more of your four loop parameters -- c, r, N_HC, and r_HV -- into a variable of the problem, so that you would have a lot fewer problems to solve. However, because of the way that those parameters are used in the model, I expect that making even one of them into a variable would cause the resulting problems to be much harder to solve. Thus, I do not expect that this approach would be helpful.
I notice that you are asking Gurobi to solve every one of the 7200 problems to within the optimality tolerance. (By default, Gurobi stops when the gap between its lower and upper bounds on the objective differ by 0.01% or less.) Do you need to know the optimal value of your model for every one of the 7200 different choices of the parameters, or is it enough to know the optimal value for the choice that is best? If you say that you only need to know the optimal value for the choice that is the best, then I can suggest a way to greatly reduce the Gurobi solving time.
--
Robert Fourer
am...@googlegroups.com
Hello Sir,
I would like to know the optimal value (the optimal profit of the objective function, and the optimal value of the variables) for only the choice of variables that is best. I only need to know the optimal value for the choice that is best. Is there any possibility of solving with integer variables the value of c, r, N_HC, and r_HV without using the for loop? Can you please suggest to me the way to greatly reduce the Gurobi solving time? I need your help please.
Sincerely,
Leon
On Tue, Nov 9, 2021 at 1:42 AM UTC, AMPL Modeling Language <am...@googlegroups.com> wrote:
In the model, I would like to consider -- c, r, N_HC, and r_HV -- as variables of the problem and solve to know the optimal value of my model (the optimal profit of the objective function, and the optimal value of the variables) for only the choice of variables that is best. I only need to know the optimal value for the choice that is best. Please suggest to me the way to greatly reduce the Gurobi solving time.
I also have Minos solver and cplex if any combination can work better than gurobi, I can consider it.
On Mon, Nov 8, 2021 at 8:37 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
It would be possible to make one or more of your four loop parameters -- c, r, N_HC, and r_HV -- into a variable of the problem, so that you would have a lot fewer problems to solve. However, because of the way that those parameters are used in the model, I expect that making even one of them into a variable would cause the resulting problems to be much harder to solve. Thus, I do not expect that this approach would be helpful.
I notice that you are asking Gurobi to solve every one of the 7200 problems to within the optimality tolerance. (By default, Gurobi stops when the gap between its lower and upper bounds on the objective differ by 0.01% or less.) Do you need to know the optimal value of your model for every one of the 7200 different choices of the parameters, or is it enough to know the optimal value for the choice that is best? If you say that you only need to know the optimal value for the choice that is the best, then I can suggest a way to greatly reduce the Gurobi solving time.
--
Robert Fourer
am...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-4964856295-1636989816-228314644%40helpscout.net.
Thank you for the feedback.
In this case, can I say that my formulated problem is wrong?
On Mon, Nov 15, 2021 at 3:23 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Also as I mentioned previously, it would be possible to make one or more of your four loop parameters -- c, r, N_HC, and r_HV -- into a variable of the problem, so that you would have fewer problems to solve. However, because of the way that those parameters are used in the model, making them into variables would cause the resulting problems to be much harder to solve. Thus, the overall solution time might not be reduced.
For example, you could consider making N_HC into a variable:var N_HC integer >= 1, <= N_HC_Max;
But then there are two parameters (Start_hv and theta_hv) that depend on N_HC, and that will also have to be changed into variables. Also N_HC appears in the objective function. But the real trouble is that N_HC appears in many constraints in contexts where a variable is not permitted. For example,subject to pzero_HV{t in TT}: P_0_hv[t] = (sum{i in 0..(N_HC-1)}((((N_HC*Start_hv[t])^i)/(fact[i]))) + (((N_HC*Start_hv[t])^N_HC)/(fact[N_HC]))* ((1 - (Start_hv[t]*(m_hv[t]^(r_HV))))/(1-Start_hv[t])) )^-1;
You cannot write "sum{i in 0..(N_HC-1)}" where N_HC is a variable, or fact[N_HC] where fact is a param and N_HC is a variable; also Gurobi will not accept a highly nonlinear expression like ((N_HC*Start_hv[t])^N_HC) where N_HC is a variable. So you can see that your model would require significant reformulations to permit N_HC to be a variable, and then it could happen that the reformulated model is much more difficult to solve.
--
Robert Fourer
am...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ampl/reply-77152-1674140037-5010346039-1638035073-948279237%40helpscout.net.
Hello Robert,
Thank you so much for your help. I have tried to run the problem. The program is running and shows many solutions. How can I know the optimal case? I don't understand well what you mean by a case in your previous email.
Attached are both the current model and screenshots of the last page of the first and last pages of the displayed results.
Sincerely yours,
Davids
On Sat, Nov 27, 2021 at 5:44 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Since I am not familiar with your application, I cannot say whether your formulation is right or wrong. My comments only imply that your formulation is too hard to solve, using AMPL and good general-purpose solvers. Thus you will need to look for an improved approach.
One thing you can do is to reduce the amount of time that the solver spends on the 7200 different cases. I had thought to use Gurobi's bestbndstop=r option, but I found that it is not always working properly. It will be fixed eventually, but meanwhile another approach you can take is to solve each case first with Gurobi options nodelim=1 and bestbound=1. Then Gurobi will stop after 1 search node and will return an upper bound on the objective value in obj.bestbound. If this upper bound is <= the best objective function value you have seen so far, then you know that the case you are currently solving cannot be the optimal one, and you can go on to the next case. If the upper bound is > the best objective function value seen so far, then you do need to remove the nodelim=1 option and solve to optimality, but that might not happen very often.
Applying this approach to the example that you gave, I found that the first case was the optimal one, and only 5 other cases needed to be solved to optimality. The entire run took less than an hour. I used the attached run file, which you could modify for your needs.
--
Robert Fourer
am...@googlegroups.com