Line: 1 to 1 | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters in AMPL | |||||||||||||||||||||||||||||||
Line: 8 to 8 | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | |||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
DescriptionParameters hold "hard" values in AMPL. The values of parameters can be defined and changed in AMPL, but a solver will not change them while looking for an optimal solution. | |||||||||||||||||||||||||||||||
Line: 174 to 174 | |||||||||||||||||||||||||||||||
... ; | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | ??? Up to here ???
Defining Multiple ParametersUsing the {\tt :} operator, multiple parameters may be defined at once. Simply state the names of the parameters and the {\tt :=} operator. Then list the set elements and values on the following rows.\begin{verbatim}
param:
If a parameter is not defined or the default value is sufficient, use the {\tt .} operator.
\begin{verbatim} | ||||||||||||||||||||||||||||||
> > | Defining Multiple ParametersUsing the: operator, multiple parameters may be defined at once. Simply state the names of the parameters and the := operator. Then list the set elements and values on the following rows.
param: <name1> <name2> ... : <element1> <value1,1> <value1,2> ... <element2> <value2,1> <value2,2> ... ;If a parameter is not defined or the default value is sufficient, use the . operator.
| ||||||||||||||||||||||||||||||
model; # The lower and upper bounds on the requirements | |||||||||||||||||||||||||||||||
Line: 199 to 197 | |||||||||||||||||||||||||||||||
FIBRE . 2.0 SALT . 0.4 ; | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | \end{verbatim} This approach also works for 2-dimensional parameters and lists, for the American Steel problem this allows us to "cut-and-paste" the list of arc properties \begin{verbatim} From node To node Cost Minimum Maximum Youngstown Albany 500 - 1000 Youngstown Cincinnati 350 - 3000 Youngstown Kansas City 450 1000 5000 Youngstown Chicago 375 - 5000 etc \end{verbatim} | ||||||||||||||||||||||||||||||
> > |
This approach also works for 2-dimensional parameters and lists, for the American Steel problem this allows us to "cut-and-paste" the list of arc properties
| ||||||||||||||||||||||||||||||
becomes | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | \begin{verbatim} | ||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
param: Cost Min Max:= Youngstown Cincinnati 350 0 3000 Youngstown 'Kansas City' 450 1000 5000 ... Chicago Gary 120 0 4000 ; | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | \end{verbatim} | ||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Accessing a ParameterParameter values are accessed by specifying the indices of the parameter you want to access within {\tt [} and {\tt ]}.ExamplesSee {\tt Cost} and {\tt Contributes} below.\begin{verbatim} | ||||||||||||||||||||||||||||||
> > | Return to top
Accessing a ParameterParameter values are accessed by specifying the indices of the parameter you want to access within[ and ] .
ExamplesSeeCost and Contributes below.
| ||||||||||||||||||||||||||||||
# Objective: minimise the cost per (100g) can | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | minimize TotalCost: sum {i in INGREDIENTS} Cost[i] * Percentage[i]; | ||||||||||||||||||||||||||||||
> > | minimize TotalCost: sum {i in INGREDIENTS} Cost[i] * Amount[i]; | ||||||||||||||||||||||||||||||
# Constraints: Meet the nutritional requirements subject to MeetRequirement {r in REQUIREMENTS}: | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Min[r] <= sum {i in INGREDIENTS} Contributes[i, r] * Percentage[i] <= Max[r]; \end{verbatim} | ||||||||||||||||||||||||||||||
> > | Min[r] <= sum {i in INGREDIENTS} Contributes[i, r] * Amount[i] <= Max[r]; Return to top -- MichaelOSullivan - 02 Mar 2008 |