To make a listing or a test that applies to all variables, constraints, or objectives, AMPL now also offers "generic" names for these components. New built-in sets and functions let AMPL also access additional information about model components, such as their names and dimensions.

ampl:This display may be restricted to components of one or more types:ampl:model multmip3.mod;parameters: demand fcost limit maxserve minload supply vcost sets: DEST ORIG PROD variables: Trans Use constraints: Demand Max_Serve Min_Ship Multi Supply objective: total_cost checks: one, called check 1.show;

ampl:Thevariables: Trans Use ampl:show vars;objective: total_cost constraints: Demand Max_Serve Min_Ship Multi Supplyshow obj, constr;

ampl:If an item followingminimize total_cost: sum{i in ORIG, j in DEST, p in PROD} vcost[i,j,p]*Trans[i,j,p] + sum{i in ORIG, j in DEST} fcost[i,j]*Use[i,j]; ampl:show total_cost;param vcost{ORIG, DEST, PROD} >= 0; param fcost{ORIG, DEST} >= 0; var Trans{ORIG, DEST, PROD} >= 0;show vcost, fcost, Trans;

c constraintschcheckseenvironmentsffunctionsoobjectivespparametersprproblemsssetsvvariables

Since the `check` statements in a model do not have
names, AMPL numbers them in the order that they appear. Thus to see
the third check statement you would type

ampl:By itself,check{p in PROD} : sum{i in ORIG} supply[i,p] == sum{j in DEST} demand[j,p];show check 1;

ampl:In general, the form of the command is# 2 entities depend on demand: check 1 Demand # 5 entities depend on Trans: total_cost Supply Demand Multi Min_Shipxref demand, Trans;

xrefcomponent-list;

ampl:or specific constraints that you identify:ampl:model multmip3.mod;ampl:data multmip3.dat;s.t. Max_Serve['GARY']: Use['GARY','FRA'] + Use['GARY','DET'] + Use['GARY','LAN'] + Use['GARY','WIN'] + Use['GARY','STL'] + Use['GARY','FRE'] + Use['GARY','LAF'] <= 5; s.t. Max_Serve['CLEV']: Use['CLEV','FRA'] + Use['CLEV','DET'] + Use['CLEV','LAN'] + Use['CLEV','WIN'] + Use['CLEV','STL'] + Use['CLEV','FRE'] + Use['CLEV','LAF'] <= 5; s.t. Max_Serve['PITT']: Use['PITT','FRA'] + Use['PITT','DET'] + Use['PITT','LAN'] + Use['PITT','WIN'] + Use['PITT','STL'] + Use['PITT','FRE'] + Use['PITT','LAF'] <= 5;expand Max_Serve;

ampl:The ordering of terms in an expanded constraint does not necessarily correspond to the order of the symbolic terms in the constraint's declaration.s.t. Min_Ship['GARY','DET']: Trans['GARY','DET','bands'] + Trans['GARY','DET','coils'] + Trans['GARY','DET','plate'] - 375*Use['GARY','DET'] >= 0; s.t. Min_Ship['CLEV','DET']: Trans['CLEV','DET','bands'] + Trans['CLEV','DET','coils'] + Trans['CLEV','DET','plate'] - 375*Use['CLEV','DET'] >= 0; s.t. Min_Ship['PITT','DET']: Trans['PITT','DET','bands'] + Trans['PITT','DET','coils'] + Trans['PITT','DET','plate'] - 375*Use['PITT','DET'] >= 0; ampl:expand {i in ORIG} Min_Ship[i,'DET'];s.t. Multi['CLEV','DET']: Trans['CLEV','DET','bands'] + Trans['CLEV','DET','coils'] + Trans['CLEV','DET','plate'] - 625*Use['CLEV','DET'] <= 0;expand Multi['CLEV','DET'];

Objectives may be expanded in the same way.

When `expand` is applied to a variable, it lists all of
the nonzero coefficients of that variable in the linear terms of
objectives and constraints:

ampl:Coefficients of Use['GARY','DET']: Max_Serve['GARY'] 1 Multi['GARY','DET'] -625 Min_Ship['GARY','DET'] -375 total_cost 1200 Coefficients of Use['CLEV','DET']: Max_Serve['CLEV'] 1 Multi['CLEV','DET'] -625 Min_Ship['CLEV','DET'] -375 total_cost 1000 Coefficients of Use['PITT','DET']: Max_Serve['PITT'] 1 Multi['PITT','DET'] -625 Min_Ship['PITT','DET'] -375 total_cost 1200expand {i in ORIG} Use[i,'DET'];

To produce an expansion of all variables, objectives and
constraints in a model, you can simply type `expand` without
any arguments. Since a single `expand` command can produce a
very long listing, you may want to redirect its output to a file by
placing `>` *filename* at the end.

The formatting of numbers in the expanded output is governed
by the options `expand_precision` and `expand_round`,
which work the same as the `display` command's
`display_precision` and `display_round` (Section
10.5).

The output of `expand` reflects the "modeler's view" of
the problem; it is based on the model and data as they were initially
read and translated. AMPL's presolve phase (Section 10.2) may make
significant simplifications to the problem before it is sent to the
solver, however. To see the expansion of the "solver's view" of the
problem following presolve, use the keyword `solexpand` in
place of `expand`.

_nvarsnumber of variables in the current problem_nconsnumber of constraints in current problem_nobjsnumber of objectives in current problem

_varname{1.._nvars}names of variables in the current problem_conname{1.._ncons}names of constraints in the current problem_objname{1.._nobjs}names of objectives in the current problem

_var{1.._nvars}synonyms for variables in the current problem_con{1.._ncons}synonyms for constraints in the current problem_obj{1.._nobjs}synonyms for objectives in the current problem

Generic names are useful for tabulating properties of all variables, where the variables have been defined in several different var declarations:

ampl:Another use is to list all variables having some property, such as being positive in the optimal solution:modelampl:net3.modampl:data net3.datMINOS 5.4: optimal solution found. 3 iterations, objective 1819 ampl:solve;ampl?display {j in 1.._nvars}: _varname[j] _var[j] _var[j].ub _var[j].rc := 1 "PD_Ship['NE']" 250 250 -0.5 2 "PD_Ship['SE']" 200 250 -1.11022e-16 3 "DW_Ship['NE','BOS']" 90 90 0 4 "DW_Ship['NE','EWR']" 100 100 -1.1 5 "DW_Ship['NE','BWI']" 60 100 0 6 "DW_Ship['SE','EWR']" 20 100 2.22045e-16 7 "DW_Ship['SE','BWI']" 60 100 2.22045e-16 8 "DW_Ship['SE','ATL']" 70 70 0 9 "DW_Ship['SE','MCO']" 50 50 0 ;(_varname[j],_var[j],_var[j].ub,_var[j].rc);

ampl:The same comments apply to constraints and objectives. More precise formatting of this information can be obtained by using theampl?display {j in 1.._nvars:_varname[j] [*] := 2 "PD_Ship['SE']" 5 "DW_Ship['NE','BWI']" 6 "DW_Ship['SE','EWR']" 7 "DW_Ship['SE','BWI']" ;_var[j] < _var[j].ub - 0.00001} _varname[j];

As in the case of the `expand` command, these
parameters and generic synonyms reflect the "modeler's view" of the
problem; their values are determined from the model and data as they
were initially read and translated. AMPL's presolve phase (Section
10.2) may make significant simplifications to the problem before it is
sent to the solver, however. To work with parameters and generic
synonyms that reflect the "solver's view" of the problem following
presolve, replace `_` by `_s` in the names given above;
for example in the case of variables, use `_snvars`,
`_svarname` and `_svar`.

Two new functions,

Set: Contains names of all declared: _SETSsets _PARSparameters _VARSvariables _OBJSobjectives _CONSconstraints _FUNCSuser-defined functions _PROBSproblems _ENVSenvironments

Used together, these features can provide a summary of model components and their dimensions:

arity(s)

- the dimension of
s, or number of components in each member ofs, providedsis a set; otherwise 0

indexarity(s)

- the dimension of the set over which
sis indexed, or 0 ifsis not indexed over a set, or -1 ifshas not been declared

ampl:arity(i) [*] := DEST 1 ORIG 1 PROD 1 ; ampl:display {i in _SETS} arity(i);indexarity(i) [*] := Trans 3 Use 2 ;display {i in _VARS} indexarity(i);

Write to

*Return to the AMPL update page.*

LAST MODIFIED 30 JULY 1998 BY 4er.