Hi Robert,
Thank you for replying. X is the decision variable and it is also the binary variable. S,O,L,K are variables which are affected by x. D is the parameter given from the data.
On Fri, Apr 1, 2022 at 7:36 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
There are many symbols in this constraint: S, O, D, L, K, and x.Also, does x(n) have to be either 0 or 1? This information can make a big difference to the difficulty of representing this constraint in AMPL, in a way that the solver can understand.
- Which are parameters, whose values are given in the data for the problem?
- Which are decision variables, whose optimal values will be set by the solver?
--
Robert Fourer
am...@googlegroups.com
Dear Robert,
Thank you for replying. It's exactly what I mean. And they are all linear.
On Sun, Apr 3, 2022 at 3:01 AM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Are you trying to say that either
x(n) = 1 and Si(n) = Si(n-1) + Di(n)
or else
x(n) = 0 and Si(n) = max (0, Si(n-1) + Di(n) + Oi(n) - Li(n) - K0)
Also, are all of the terms in your objective and constraints (except for this max) going to be linear?
--
Robert Fourer
am...@googlegroups.com
Dear Robert,
Thank you for replying again. I was just code as you taught, and I was not sure about the meanning of y(n). Also, the new problem caught me up. When I run the code, it showed that
'Sorry, minos cannot handle logical constraints'.
Here is my code. I don't find where I forgot to put a operator in my constraints.
On Tue, Apr 5, 2022 at 10:25 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
Do you have access to CPLEX, Gurobi, or Xpress for AMPL? Then you can use the ==> operator, which means "implies", to write the following "indicator constraints" that those solvers will recognize:
x(n) = 1 ==> Si(n) = Si(n-1) + Di(n)
x(n) = 0 ==> Si(n) >= 0
x(n) = 0 ==> Si(n) >= Si(n-1) + Di(n) + Oi(n) - Li(n) - K0
Actually this only implies that if x(n) = 0, then Si(n) >= max (0, Si(n-1) + Di(n) + Oi(n) - Li(n) - K0). That might be enough to make your model correct.
But if it is necessary for your model to explicitly require that also Si(n) = max ( . . . ), then you will need to also enforce Si(n) <= max (0, Si(n-1) + Di(n) + Oi(n) - Li(n) - K0). To do that, you can define an extra set of zero-one variables z(i), and constraints like this:
x(n) = 0 ==> Si(n) <= M * (1-y(n))
x(n) = 0 ==> Si(n) <= Si(n-1) + Di(n) + Oi(n) - Li(n) - K0 + M * y(n)
where M is some upper limit on possible value of Si(n).
Of course, you will need to transform these statements to proper AMPL syntax, as described in the AMPL book. (For example, Si(n) could be Si[n] in AMPL.)
--
Robert Fourer
am...@googlegroups.com
Dear Robert,
On Thu, Apr 7, 2022 at 3:27 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
You cannot use the MINOS solver for this problem. MINOS does not accept the ==> operator; i it is possible to linearize the constraints that use ==>, but that requires defining some extra binary (zero-one) variables, which MINOS also does not handle. To solve your problem, try selecting the CPLEX, Gurobi, or Xpress solver, by giving one of the following commands before "solve":
option solver cplex;
option solver gurobi;
option solver xpress;
If you want, you can make three different test runs, each specifying a different solver, and then keep using the one that gives the fastest results in your test.
--
Robert Fourer
am...@googlegroups.com
Dear Robert,
The constraints like 'x(n) = 0 ==> Si(n) >= Si(n-1) + Di(n) + Oi(n) - Li(n) - K0' doesn't work. The specific constraints in my code are ss3e, ss4d, ss9c, ss10a... I examined these constraints and found when I remove the term 'Stay[i,n-1]', the constraints will work. It seems like ampl doesn't find the value of 'Stay[i,n-1]'. What should I do?
On Sat, Apr 9, 2022 at 2:52 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
That is right, to solve with CPLEX, you will need to linearize all quadratic terms like "C[i,n-1]*x[n]" that appear in equality constraints.
--
Robert Fourer
am...@googlegroups.com
Dear Robert,
I tried to find the 'iis' command and 'drop' command to determine which constraints caused the infeasible. They all point to the constraints like:
subject to ss3d {i in NV,n in N}:
x[n] = 0 ==>Stay[i,n]>= O[i,n] + D[i,n] + Stay[i,n-1] - G[i,n] - KO;
The error is that 'CPLEX 12.5.0.0: logical constraint _slogcon[12] is not an indicator constraint.' .
However, the constraint like 'x[n] = 0 ==>Stay[i,n]>=0;' works.
Then , I tried to modify the constraints to 'Stay[i,n]>= O[i,n] + D[i,n] + Stay[i,n-1] - G[i,n] - KO;', then it does not report the error. I really don't know the reason. And how can i fix it?
On Tue, Apr 19, 2022 at 7:45 PM UTC, AMPL Google Group <am...@googlegroups.com> wrote:
When I send your model and data to the CPLEX solver, it reports the following result:
CPLEX 20.1.0.0: integer infeasible.
This says that your problem is infeasible: there is no way to assign values to the variables that will satisfy all of your constraints, and also all the bounds and integrality restrictions on the variables. Since the problem is infeasible, any solution that CPLEX returns cannot satisfy all of the requirements of your problem, and thus cannot be a useful solution for your model.
Both CPLEX and AMPL have worked correctly here. Most likely, the infeasible result is due to an error in your model. Or it might be that there is something wrong with your data, that makes a feasible solution impossible. There is no simple and general way to deal with an error like this; you may need to study the model and the data for a while before you can understand the cause of the infeasibility. It is possible to suggest some good ways to get started, however.
As an initial troubleshooting step, it is often helpful to use AMPL's expand command to see see whether AMPL generated the constraints that you expected. By itself, expand; shows all of the constraints. If there are many of them, you can use, for example, expand ss3e; to expand all of the constraints that have a particular name. Also you can write, for instance, expand >listing.txt; or expand ss3e >listing.txt; to send all of the output to the file listing.txt.
You should also consider using AMPL's drop and restore commands to narrow your search for the cause of the infeasibility. If you drop some constraints and the resulting problem is still infeasible, then you don't need to consider the dropped constraints in looking for the cause of infeasibility. By trying a series of drops, you may be able to determine that infeasibility is being caused by only a small subset of the constraints. (Removing a variable is not helpful, though.)
If you are using one of the popular MIP solvers then to get more help with diagnosing the infeasibility, you can ask the solver to compute an irreducible infeasible subset. For more on this topic, search "IIS" at groups.google.com/group/ampl, and also see the discussion of "infeasibility diagnosis" in chapter 14 of the AMPL book (https://ampl.com/BOOK/CHAPTERS/17-solvers.pdf#page=25). I have found that the Gurobi solver is the most reliable for IIS finding.
--
Robert Fourer
am...@googlegroups.com