- The AMPL website
contains the
first chapter
of the AMPL book,
a collection of
frequently asked questions,
and a list of
all the cplex options available in AMPL.
- If you are working in a Windows operating system,
you can edit your model
and data files in Office, for example. Save the files as plain text files.
Windows may append the suffix txt to the file names, in which case you would
need to include that suffix when asking ampl to read the file.
- If you want to read in a new model file chips.mod
and data file chips.dat,
you can use the reset command:
ampl: reset;
ampl: model chips.mod;
ampl: data chips.dat;
- If you want to reset the whole data file
and read in a new data file chips.dat,
but you want to keep the model
file as before, you can type
ampl: reset data;
ampl: data chips.dat;
- If you want to change one parameter, you can use the let
command as follows:
(OS) ampl
ampl: model sample/steel.mod;
ampl: data sample/steel.dat;
ampl: solve;
MINOS 5.4: optimal solution found.
2 iterations, objective 192000
ampl: let rate["bands"]:=250;
ampl: solve;
MINOS 5.4: optimal solution found.
1 iterations, objective 217200
This changes the rate for bands and then resolves the problem.
- If you want to add some constraints, you can put them in a file
and then read them in. For example, let linord.mod
and linord.dat
describe a linear
ordering problem, without any
triangle inequalities.
Let cuts.mod contain some violated triangle inequalities.
The model with the extra cuts can be solved as follows:
(OS) ampl
ampl: model linord.mod;
ampl: data linord.dat;
ampl: solve;
ILOG CPLEX 9.100, licensed to "rensselaer-troy, ny", options: e m b q
CPLEX 9.1.0: optimal solution; objective -35
0 dual simplex iterations (0 in phase I)
ampl: model cuts.mod;
ampl: solve;
ILOG CPLEX 9.100, licensed to "rensselaer-troy, ny", options: e m b q
CPLEX 9.1.0: optimal solution; objective -33
1 dual simplex iterations (0 in phase I)
A log of this AMPL run can be found
here.
- To find the value of a dual variable
corresponding to a constraint called fabcap,
type
display fabcap;
To find the slack in the constraint, type
display fabcap.slack;
- To find the reduced cost of a variable called SELL in the optimal
tableau, type
display SELL.rc;
- One way to find bounds on parameters in AMPL
is to use the cplex option
of sensitivity.
This will let you find ranges in which parameters can be changed
without the set of optimal basic variables changing.
First make sure CPLEX is the solver:
ampl: option solver cplexamp;
Once you've established cplex as the solver,
enter the following command:
ampl: option cplex_options 'sensitivity';
Solve the problem again, and then
you can then use the suffices up and down on variable names,
as described for reduced costs and slacks.
- All the variables and their reduced costs can be displayed
simultaneously by using the command
display {j in 1.._nvars} (_varname[j],_var[j],_var[j].rc);
(See page 249 of the AMPL text.)
All the constraints and their shadow prices can be displayed simultaneously by using the command
display {j in 1.._ncons} (_conname[j],_con[j]);
(Again, see page 249 of the AMPL text.)
These commands can be used with the other suffices available when using the
cplex sensitivity option.
- You can use sum and other AMPL commands after solving the
problem to find values of various combinations of the primal and
dual variables and the parameters.
- A variable can be declared binary. For example:
var make {SET} binary;
- A variable can be declared integer
as well as nonnegative and bounded. For
example:
var make {SET} >= 0, <= 100, integer;
- On RCS or Windows machines, you can use the solver cplex
for solving mixed integer programming problems.
For MacOSX, you may be able to find a useful solver from the
AMPL webpage.
Alternatively, you can submit your model to the NEOS server at
http://www.neos-server.org/neos/.
I would suggest using the solver MINTO.
Note that you will need to use a commands file
if you want to get output that is nicely formatted and easy to interpret.
The command file can be pretty simple. For example:
solve;
display invest0, nblocks0;
display invest1, buy, sell, buyindicator;
- Debugging
an infeasible model by
Gabor Pataki.
This uses the IIS options within CPLEX.
In particular, you can use the AMPL command
option cplex_options 'iisfind 1';
- A
list of
all the cplex options available in AMPL.