Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

<-- Ready to Review - done - Lauren--> ## The AMPL Syntax Guide | ||||||||

Line: 16 to 16 | ||||||||

Changed: | ||||||||

< < | - Miscellaneous AMPL Commands Coming soon!
| |||||||

> > | ||||||||

## Commenting |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

<-- Ready to Review - done - Lauren--> ## The AMPL Syntax Guide | ||||||||

Line: 23 to 23 | ||||||||

The `#` is used for commenting, any characters on a line after the `#` are ignored by AMPL.
## Examples | ||||||||

Changed: | ||||||||

< < | The Whiskas Cat Food Problem # The set of all possible ingredients for the cat food set INGREDIENTS; | |||||||

> > | The Whiskas Cat Food Problem
# The set of all possible ingredients for the cat food set INGREDIENTS; | |||||||

The Surfboard Production Problem | ||||||||

Added: | ||||||||

> > | ||||||||

Changed: | ||||||||

< < | param Resin {SURFBOARDS} >= 0; # Amount of resin (in kilos) needed for a board param TotalResin >= 0; # Total amount of resin available | |||||||

> > | param Supply {MATERIALS}; # The supply of each raw material
param Recipe {MATERIALS, SURFBOARDS}; # The "recipe" for making surfboards | |||||||

## Using =symbolic |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

<-- Ready to Review - done - Lauren--> ## The AMPL Syntax Guide | ||||||||

Line: 13 to 13 | ||||||||

Changed: | ||||||||

< < | - Logical Statements Coming soon!
| |||||||

> > | ||||||||

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

<-- Ready to Review - done - Lauren--> ## The AMPL Syntax Guide | ||||||||

Line: 13 to 13 | ||||||||

Changed: | ||||||||

< < | - Logical Statements Fix this link - Lauren
- Looping Statements Fix this link - Lauren
| |||||||

> > | - Logical Statements Coming soon!
- Looping Statements
| |||||||

Changed: | ||||||||

< < | - Miscellaneous AMPL Commands Fix this link - Lauren
| |||||||

> > | - Miscellaneous AMPL Commands Coming soon!
| |||||||

## Commenting |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

<-- Ready to Review - done - Lauren--> ## The AMPL Syntax Guide | ||||||||

Line: 18 to 18 | ||||||||

- Displaying and Printing
- Miscellaneous AMPL Commands Fix this link - Lauren
| ||||||||

Changed: | ||||||||

< < | ## Commenting Fix stacking on this page - Lauren | |||||||

> > | ## Commenting | |||||||

The `#` is used for commenting, any characters on a line after the `#` are ignored by AMPL. | ||||||||

Line: 26 to 26 | ||||||||

The Whiskas Cat Food Problem # The set of all possible ingredients for the cat food set INGREDIENTS; | ||||||||

Changed: | ||||||||

< < | param Resin {SURFBOARDS} >= 0; # Amount of resin (in kilos) needed for a board param TotalResin >= 0; # Total amount of resin available | |||||||

> > | param Resin {SURFBOARDS} >= 0; # Amount of resin (in kilos) needed for a board param TotalResin >= 0; # Total amount of resin available | |||||||

## Using =symbolic
The
## Example. Searching a 1-Dimensional set | ||||||||

Changed: | ||||||||

< < | param gotcha symbolic within SET; for {s in SET} { if then let gotcha := s; } # gotcha now contains the (last) element in SET that satisfies the condition | |||||||

> > | param gotcha symbolic within SET; for {s in SET} { if then let gotcha := s; } # gotcha now contains the (last) element in SET that satisfies the condition | |||||||

## Example. Searching a 2-Dimensional Set | ||||||||

Changed: | ||||||||

< < | set SET1; set SET2; set TWO_D_SET within SET1 cross SET2; param got_one symbolic within SET1; param got_two symbolic within SET2; for {(s, t) in TWO_D_SET} { if then { let got_one := s; let got_two := t; } } # (got_one, got_two) now contains the (last) element in TWO_D_SET # that satisfies the condition | |||||||

> > | set SET1; set SET2; set TWO_D_SET within SET1 cross SET2; param got_one symbolic within SET1; param got_two symbolic within SET2; for {(s, t) in TWO_D_SET} { if then { let got_one := s; let got_two := t; } } # (got_one, got_two) now contains the (last) element in TWO_D_SET # that satisfies the condition | |||||||

To build labels for set elements you need a `symbolic` parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within `(` and `)` and joining the parts with `&` . The parts can be set elements, strings or numbers. Numbers are converted to strings using the %g format from printf . | ||||||||

Added: | ||||||||

> > | ||||||||

## Example. Dynamically Building a Set | ||||||||

Changed: | ||||||||

< < | param name symbolic; let SUPPLY_NODES := {}; for {s in SUPPLY_LOCATIONS} { let name := (s & '-Woodchips'); let SUPPLY_NODES := SUPPLY_NODES union {name}; let Supply[name] := MaterialSupply[s, 'Woodchips']; let {d in DEMAND_NODES} Cost[name, d] := TransportationCost[s, d]; let dummyDemandCost[name] := DisposalCost['Woodchips']; } | |||||||

> > | param name symbolic; let SUPPLY_NODES := {}; for {s in SUPPLY_LOCATIONS} { let name := (s & '-Woodchips'); let SUPPLY_NODES := SUPPLY_NODES union {name}; let Supply[name] := MaterialSupply[s, 'Woodchips']; let {d in DEMAND_NODES} Cost[name, d] := TransportationCost[s, d]; let dummyDemandCost[name] := DisposalCost['Woodchips']; } | |||||||

-- MichaelOSullivan - 27 Feb 2008 |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

| ||||||||

Changed: | ||||||||

< < | <-- Ready to Review --> | |||||||

> > | <-- Ready to Review - done - Lauren--> | |||||||

## The AMPL Syntax Guide
| ||||||||

Changed: | ||||||||

< < | ||||||||

> > | ||||||||

Changed: | ||||||||

< < | ||||||||

> > | - Logical Statements Fix this link - Lauren
- Looping Statements Fix this link - Lauren
| |||||||

Changed: | ||||||||

< < | ||||||||

> > | - Miscellaneous AMPL Commands Fix this link - Lauren
| |||||||

Changed: | ||||||||

< < | ## Commenting | |||||||

> > | ## Commenting Fix stacking on this page - Lauren | |||||||

The `#` is used for commenting, any characters on a line after the `#` are ignored by AMPL.
## Examples | ||||||||

Changed: | ||||||||

< < | The Whiskas Cat Food Problem
# The set of all possible ingredients for the cat food set INGREDIENTS; The Surfboard Production Problem | |||||||

> > | The Whiskas Cat Food Problem # The set of all possible ingredients for the cat food set INGREDIENTS; The Surfboard Production Problem | |||||||

## Using =symbolic
The
## Example. Searching a 1-Dimensional set | ||||||||

Changed: | ||||||||

< < | param gotcha symbolic within SET; for {s in SET} { if | |||||||

> > | ||||||||

## Example. Searching a 2-Dimensional Set | ||||||||

Changed: | ||||||||

< < | set SET1; set SET2; set TWO_D_SET within SET1 cross SET2; param got_one symbolic within SET1; param got_two symbolic within SET2; for {(s, t) in TWO_D_SET} { if | |||||||

> > | ||||||||

Changed: | ||||||||

< < | To build labels for set elements you need a `symbolic` parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within `(` and `)` and joining the parts with `&` . The parts can be set elements, strings or numbers. Numbers are converted to strings using the %g format from printf
. | |||||||

> > | To build labels for set elements you need a `symbolic` parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within `(` and `)` and joining the parts with `&` . The parts can be set elements, strings or numbers. Numbers are converted to strings using the %g format from printf . | |||||||

## Example. Dynamically Building a Set | ||||||||

Changed: | ||||||||

< < | param name symbolic; let SUPPLY_NODES := {}; for {s in SUPPLY_LOCATIONS} { let name := (s & '-Woodchips'); let SUPPLY_NODES := SUPPLY_NODES union {name}; let Supply[name] := MaterialSupply[s, 'Woodchips']; let {d in DEMAND_NODES} Cost[name, d] := TransportationCost[s, d]; let dummyDemandCost[name] := DisposalCost['Woodchips']; } | |||||||

> > | ||||||||

-- MichaelOSullivan - 27 Feb 2008 |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

| ||||||||

Added: | ||||||||

> > | <-- Ready to Review --> | |||||||

## The AMPL Syntax Guide | ||||||||

Changed: | ||||||||

< < | Disclaimer This is a to the AMPL syntax only. For a comprehensive reference to the AMPL language see AMPL: A Modeling Language for Mathematical Programming.guide | |||||||

> > | Disclaimer This is a to the AMPL syntax only. For a comprehensive reference to the AMPL language see AMPL: A Modeling Language for Mathematical Programming.guide | |||||||

Changed: | ||||||||

< < | ||||||||

> > | ||||||||

## Commenting | ||||||||

Line: 22 to 23 | ||||||||

The `#` is used for commenting, any characters on a line after the `#` are ignored by AMPL.
## Examples | ||||||||

Changed: | ||||||||

< < | The Whiskas Cat Food Problem # The set of all possible ingredients for the cat food set INGREDIENTS;The Surfboard Production Problem | |||||||

> > | The Whiskas Cat Food Problem
# The set of all possible ingredients for the cat food set INGREDIENTS; The Surfboard Production Problem | |||||||

## Using =symbolic
The
## Example. Searching a 1-Dimensional set | ||||||||

Changed: | ||||||||

< < | | |||||||

> > |
| |||||||

## Example. Searching a 2-Dimensional Set | ||||||||

Changed: | ||||||||

< < | | |||||||

> > |
| |||||||

Changed: | ||||||||

< < | To build labels for set elements you need a `symbolic` parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within `(` and `)` and joining the parts with `&` . The parts can be set elements, strings or numbers. Numbers are converted to strings using the =%g= format from =printf= . | |||||||

> > | To build labels for set elements you need a `symbolic` parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within `(` and `)` and joining the parts with `&` . The parts can be set elements, strings or numbers. Numbers are converted to strings using the %g format from printf
. | |||||||

## Example. Dynamically Building a Set | ||||||||

Changed: | ||||||||

< < | | |||||||

> > | param name symbolic; | |||||||

Changed: | ||||||||

< < | ## Sets in AMPL | |||||||

> > | let SUPPLY_NODES := {}; for {s in SUPPLY_LOCATIONS} { let name := (s & '-Woodchips'); let SUPPLY_NODES := SUPPLY_NODES union {name}; let Supply[name] := MaterialSupply[s, 'Woodchips']; let {d in DEMAND_NODES} Cost[name, d] := TransportationCost[s, d]; let dummyDemandCost[name] := DisposalCost['Woodchips']; } | |||||||

-- MichaelOSullivan - 27 Feb 2008 |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

## The AMPL Syntax Guide | ||||||||

Changed: | ||||||||

< < | Disclaimer This is a *guide* to the AMPL syntax only. For a comprehensive reference to the AMPL language see AMPL: A Modeling Language for Mathematical Programming. | |||||||

> > | Disclaimer This is a to the AMPL syntax only. For a comprehensive reference to the AMPL language see AMPL: A Modeling Language for Mathematical Programming.guide | |||||||

Changed: | ||||||||

< < | - Commenting
- Using {\tt symbolic}
- Sets
- Variables
- Parameters
- Expressions
- Objective Functions
- Constraints
- Logical Statements
- Looping Statements
- Displaying and Printing
- Miscellaneous AMPL Commands
## CommentingThe {\tt #} is used for commenting, any characters after the {\tt #} are ignored by AMPL.
## ExamplesThe Whiskas Cat Food Problem\begin{verbatim} var x1 >= 0; # Percentage chicken meat used in 100g of cat food (= g) \end{verbatim}
The Surfboard Production Problem \begin{verbatim} param Resin {SURFBOARDS} >= 0; # Amount of resin (in kilos) needed for a board param TotalResin >= 0; # Total amount of resin available \end{verbatim}
## Using {\tt symbolic}
The {\tt symbolic} keyword is used to create parameters that represent character strings. Usually they are used to represent members of 1-dimensional sets or part of a
## Example. Searching a 1-Dimensional set\begin{verbatim}
param gotcha symbolic within SET;
for {s in SET} {
if
## Example. Searching a 2-Dimensional Set\begin{verbatim} set SET1; set SET2; set TWO_D_SET within SET1 cross SET2; param got_one symbolic within SET1; param got_two symbolic within SET2;
for {(s, t) in TWO_D_SET} {
if
To build labels for set elements you need a {\tt symbolic} parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within {\tt (} and {\tt )} and joining the parts with {\tt &}. The parts can be set elements, strings or numbers. Numbers are converted to strings using the {\tt %g} format from {\tt printf}. ## Example. Dynamically Building a Set\begin{verbatim} param name symbolic; let SUPPLY_NODES := {}; for {s in SUPPLY_LOCATIONS} { let name := (s & '-Woodchips'); let SUPPLY_NODES := SUPPLY_NODES union {name}; let Supply[name] := MaterialSupply[s, 'Woodchips']; let {d in DEMAND_NODES} Cost[name, d] := TransportationCost[s, d]; let dummyDemandCost[name] := DisposalCost['Woodchips']; } \end{verbatim}
| |||||||

> > | ||||||||

Changed: | ||||||||

< < | Logical Statements | |||||||

> > | ## Commenting | |||||||

Changed: | ||||||||

< < | Looping Statements | |||||||

> > | The `#` is used for commenting, any characters on a line after the `#` are ignored by AMPL. | |||||||

Changed: | ||||||||

< < | Displaying and Printing | |||||||

> > | ## ExamplesThe Whiskas Cat Food Problem# The set of all possible ingredients for the cat food set INGREDIENTS;The Surfboard Production Problem | |||||||

Changed: | ||||||||

< < | Miscellaneous AMPL Commands | |||||||

> > | ## Using =symbolic
## Example. Searching a 1-Dimensional set
## Example. Searching a 2-Dimensional Set
To build labels for set elements you need a ## Example. Dynamically Building a Set
## Sets in AMPL | |||||||

-- MichaelOSullivan - 27 Feb 2008 |

Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

Added: | ||||||||

> > |
## The AMPL Syntax Guide
- Commenting
- Using {\tt symbolic}
- Sets
- Variables
- Parameters
- Expressions
- Objective Functions
- Constraints
- Logical Statements
- Looping Statements
- Displaying and Printing
- Miscellaneous AMPL Commands
## CommentingThe {\tt #} is used for commenting, any characters after the {\tt #} are ignored by AMPL.
## ExamplesThe Whiskas Cat Food Problem\begin{verbatim} var x1 >= 0; # Percentage chicken meat used in 100g of cat food (= g) \end{verbatim}
The Surfboard Production Problem \begin{verbatim} param Resin {SURFBOARDS} >= 0; # Amount of resin (in kilos) needed for a board param TotalResin >= 0; # Total amount of resin available \end{verbatim}
## Using {\tt symbolic}
The {\tt symbolic} keyword is used to create parameters that represent character strings. Usually they are used to represent members of 1-dimensional sets or part of a
## Example. Searching a 1-Dimensional set\begin{verbatim}
param gotcha symbolic within SET;
for {s in SET} {
if
## Example. Searching a 2-Dimensional Set\begin{verbatim} set SET1; set SET2; set TWO_D_SET within SET1 cross SET2; param got_one symbolic within SET1; param got_two symbolic within SET2;
for {(s, t) in TWO_D_SET} {
if
To build labels for set elements you need a {\tt symbolic} parameter and the parts of the label. You can then "glue" the parts of the label together by enclosing the label within {\tt (} and {\tt )} and joining the parts with {\tt &}. The parts can be set elements, strings or numbers. Numbers are converted to strings using the {\tt %g} format from {\tt printf}. ## Example. Dynamically Building a Set\begin{verbatim} param name symbolic; let SUPPLY_NODES := {}; for {s in SUPPLY_LOCATIONS} { let name := (s & '-Woodchips'); let SUPPLY_NODES := SUPPLY_NODES union {name}; let Supply[name] := MaterialSupply[s, 'Woodchips']; let {d in DEMAND_NODES} Cost[name, d] := TransportationCost[s, d]; let dummyDemandCost[name] := DisposalCost['Woodchips']; } \end{verbatim}
-- MichaelOSullivan - 27 Feb 2008 |

View topic | History: r9 < r8 < r7 < r6 | More topic actions...

Copyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding TWiki? Send feedback

Ideas, requests, problems regarding TWiki? Send feedback