Line: 1 to 1 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
<-- Ready to Review --> | |||||||||||
Line: 20 to 20 | |||||||||||
Declaring a ParameterAMPL parameters are created in a similar way to AMPL variables, using theparam keyword followed by a label. | |||||||||||
Changed: | |||||||||||
< < | param | ||||||||||
> > | param ; | ||||||||||
Example | |||||||||||
Changed: | |||||||||||
< < | param MinProtein;Like variables parameters are often defined over a set and may have several attributes: param | ||||||||||
> > | param MinProtein;Like variables parameters are often defined over a set and may have several attributes: param [{}] []; | ||||||||||
Exampleparam ProteinPercent {INGREDIENTS} >= 0 <= 100; | |||||||||||
Line: 49 to 49 | |||||||||||
Default parameter values can be used to quickly set a large number of parameter values automatically. If a parameter is used without being explicitly assigned a value the default value is used for that parameter. AMPL uses a default value of 0 if no default value is given.
Example | |||||||||||
Changed: | |||||||||||
< < | set DIGITS := 1..5; param isok {DIGITS} binary default 1; let isok[3] := 0; display {i in DIGITS} isok[i]; # Result # ====== # isok[i] [*] := # 1 1 # 2 1 # 3 0 # 4 1 # 5 1 # ; | ||||||||||
> > | set DIGITS := 1..5; param isok {DIGITS} binary default 1; let isok[3] := 0; display {i in DIGITS} isok[i]; # Result # ====== # isok[i] [*] := # 1 1 # 2 1 # 3 0 # 4 1 # 5 1 # ; | ||||||||||
The AMPL macros Infinity and -Infinity are useful as defaults for parameters that act as bounds ( Infinity as a default upper bound, 0 or -Infinity as a default lower bound). | |||||||||||
Line: 63 to 63 | |||||||||||
Defining 2-Dimensional Parameters | |||||||||||
Changed: | |||||||||||
< < | In a similar way to 2-dimensional sets, there are three different ways to define 2-dimensional sets. | ||||||||||
> > | In a similar way to 2-dimensional sets, there are three different ways to define 2-dimensional parameters. | ||||||||||
| |||||||||||
Changed: | |||||||||||
< < |
| ||||||||||
> > |
| ||||||||||
Defining Multi-Dimensional Parameters | |||||||||||
Line: 75 to 75 | |||||||||||
Defining Multiple Parameters | |||||||||||
Changed: | |||||||||||
< < | Using 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:If a parameter is not defined or the default value is sufficient, use the . operator. model; # The lower and upper bounds on the requirements param Min {REQUIREMENTS} default -Infinity; param Max {REQUIREMENTS} default Infinity; data; param: Min Max:= PROTEIN 8.0 . FAT 6.0 . FIBRE . 2.0 SALT . 0.4 ;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 | ||||||||||
> > | Using 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: ... : ... ... ;If a parameter is not defined or the default value is sufficient, use the . operator. model; # The lower and upper bounds on the requirements param Min {REQUIREMENTS} default -Infinity; param Max {REQUIREMENTS} default Infinity; data; param: Min Max:= PROTEIN 8.0 . FAT 6.0 . FIBRE . 2.0 SALT . 0.4 ;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 | ||||||||||
|