Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
<-- Under Construction --> | ||||||||
Line: 24 to 24 | ||||||||
} | ||||||||
Added: | ||||||||
> > | Examples coming soon! Return to top | |||||||
let Loops | ||||||||
Deleted: | ||||||||
< < | Coming soon! | |||||||
Changed: | ||||||||
< < | Under Construction> | |||||||
> > | In AMPL you can display and/or print over specified subsets and you can also "loop" over a let statement. To assign values for an entire set you use the let keyword, the set and the := operator:
let {e in SET} <parameter, usually involving e> := <expression, often involving e>; | |||||||
Changed: | ||||||||
< < | “Looping” let Statements In the same way you can printf over specified subsets, you can use a let statement to “loop” over a set and change the data. Syntax: To change data values for a set you use the let keyword, the set and the := operator let {e in SET} <parameter, usually involving e> := <expression, often involving e>; Consider the following possibility for American Steel. American Steel can get a 5% discount with their transportation provider out of Chicago as long as they commit to at least 1000 tonnes along each route. This change can be easily incorporated using two “looping” let statements. | |||||||
> > | Consider the following possibility for the American Steel . American Steel can get a 5% discount with their transportation provider out of Chicago as long as they commit to at least 1000 tonnes along each route. This change can be easily incorporated using two “looping” let statements. | |||||||
let {n in NODES : (‘Chicago’, n) in ARCS} Cost[‘Chicago’, n] := 0.95 * Cost[‘Chicago’, n]; let {n in NODES : (‘Chicago’, n) in ARCS} |