AMPL > >Faqs

AMPL’s `expand`

command can display any explicit linear constraint, or indexed collection of constraints. For example:

ampl: model transp.mod; ampl: data transp.dat; ampl: expand Demand['STL']; s.t. Demand['STL']: Trans['GARY','STL'] + Trans['CLEV','STL'] + Trans['PITT','STL'] = 1700; ampl: expand Supply; s.t. Supply['GARY']: Trans['GARY','FRA'] + Trans['GARY','DET'] + Trans['GARY','LAN'] + Trans['GARY','WIN'] + Trans['GARY','STL'] + Trans['GARY','FRE'] + Trans['GARY','LAF'] = 1400; s.t. Supply['CLEV']: Trans['CLEV','FRA'] + Trans['CLEV','DET'] + Trans['CLEV','LAN'] + Trans['CLEV','WIN'] + Trans['CLEV','STL'] + Trans['CLEV','FRE'] + Trans['CLEV','LAF'] = 2600; s.t. Supply['PITT']: Trans['PITT','FRA'] + Trans['PITT','DET'] + Trans['PITT','LAN'] + Trans['PITT','WIN'] + Trans['PITT','STL'] + Trans['PITT','FRE'] + Trans['PITT','LAF'] = 2900;

The `expand`

command also works with variables and objectives, and has indexing options similar to those of `display`

or `print`

for specifying which components are expanded.

The built-in parameter `_nvars`

contains the number of variables; a symbolic parameter `_varname[j]`

contains the AMPL name of the `j`

th variable; and `_var[j]`

is a “synonym” that refers to the `j`

th variable. Thus to show the names of all variables that are below their upper bounds at the optimum, for example, you can write:

ampl: display {j in 1.._nvars: ampl? _var[j] < _var[j].ub - 0.00001} _varname[j]; _varname[j] [*] := 2 "PD_Ship['SE']" 5 "DW_Ship['NE','BWI']" 6 "DW_Ship['SE','EWR']" 7 "DW_Ship['SE','BWI']" ;

This is only one of the uses for AMPL’s generic synonyms for variables, constraints and objectives. See the discussion of AMPL’s generic names in Section A.19.4 of the reference appendix to the AMPL book.

AMPL’s suffix feature can be used by solvers to return ranging information. See in particular the discussion of solver-defined suffixes in Section 14.3 of the AMPL book for an example of range output from CPLEX. The option listings for the CPLEX and Gurobi solvers contain more information about how to request and retrieve this information.

AMPL does not currently support “parametric” algorithms for postoptimal analysis of objective functions or constraint right-hand sides.

In practice, ranging often provides sensitivity information of limited usefulness, and parametric algorithms are limited to certain kinds of linear changes to the data. You may do better to write a simple AMPL script that solves the same model for a series of different parameter values. For an example, see the simple sensitivity analysis script developed in Section 13.1 of the AMPL book.

AMPL cannot determine by itself the values from the linear programming tableau, because the sparse linear algebra routines capable of computing these values are found only in the solvers. Efficient solver implementations avoid computing or storing more than a few tableau columns at a time, however. Hence AMPL also has no solver directives that can cause tableau values to be returned.

For a specific AMPL model, it is possible to set up an auxiliary model that finds the tableau values, at least in the nondegenerate case; see our diet tableau example based on the diet model from Chapter 2 of the AMPL book. This approach is highly inefficient, but should be adequate for small linear programs — up to a few dozen variables, say.

The display command does not currently recognize `{k in SS} POW[k]`

where `POW`

is an indexed (subscripted) set. For this elementary case, you can exhibit the whole indexed collection of subsets by giving just the name of the collection:

display POW;

You can also exhibit each of the indexed sets separately, by using the iterated form of the `display`

command; it resembles the ordinary form, but with a colon after the index set:

display {k in SS}: POW[k];

This gives the same output as if you had typed a separate statement `display POW[k]`

for each member `k`

of `SS`

. Any set expression (or list of expressions) may follow the colon.

Add the keyword `ordered`

to the set’s declaration, after the set name. It can be useful to declare a set `ordered`

for purposes of ordering the output, even when the ordering plays no role in the model.

AMPL provides the following built-in timing parameters such as `_ampl_time`

and `_total_solve_time`

. You’ll find the complete list in Table A-14 in the reference appendix of the AMPL book. These timing parameters can be used in all the same ways as ordinary AMPL parameters defined through param statements. Thus in particular you can show their values (or the values of expressions involving them) by use of `display`

or `printf`

commands.

© 2013 AMPL Optimization inc. All rights reserved.
Web Development by Baytech Web Design