This is a hand-in written by **Group 60** (FIRE) for the weekly **module #6** in the mathematical modelling course (**DAT026**) at Chalmers University of Technology.

Group 60 consists of:

**Mazdak Farrokhzad**901011-0279

twingoow@gmail.com

Program: IT

Time spent: 16 hours, 57 minutes

**Niclas Alexandersson**920203-0111

nicale@student.chalmers.se

Program: IT

Time spent: 10 hours, 36 minutes

**We hereby declare that we have both actively participated in solving every exercise, and all solutions are entirely our own work.**

**Disclaimer:** Please do note that the numbering of the sections in the TOC and elsewhere are not intended to follow the numbering of the problem. The problem referred to is always explicitly stated in the title itself (e.g: Problem 1...)

A quick, but relatively unimportant analysis of the AMPL syntax structure: Looking at the **diet2.mod** file, we quickly see that all statements in `AMPL`

are **;** (semicolon) terminated, just like `C`

family languages. In any line where a **#** character is encountered, the rest of the line is treated as a comment, just like Perl. Assignment is done with the **:=** operator, like in ALGOL 1958 and Pascal.

**The keyword:**

`set`

<name> [<O>] [:= <A>] declares a set with optional parts enclosed in [..].`param`

<name> [<S>] [<C>] [<T>] declares parameter(s) (values given in advance) of name with with optional constraints <C> of optional type <T> for each element in optional set indexing <S>.`var`

works like param, but instead of giving a value in advance, the value of a variable is to be determined during trough optimization.`minimize`

<name> [<S>] : <O> states an objective function <O> to minimize with <name> given optional sets <S> to iterate over (or no set to iterate over).`minimize`

<name> [S] : <C> states a constraint <C> with <name> to honour given optional sets <S> to iterate over (or no set to iterate over).

**We do an expression-for-expression analysis of the file:**

`set NUTR ordered;`

declares an ordered set NUTR, henceforth known as \({{\mathbb{N}}}\).`set FOOD ordered;`

declares an ordered set FOOD, henceforth known as \({{\mathbb{F}}}\).`param cost[...];`

declares a parameter \(c_j = cost_j \geq 0, \forall j \in {{\mathbb{F}}}\). This cost is the dollar cost of each food item.`param f_min[...];`

declares \(fl_j = f_{min_j} \geq 0, \forall j \in {{\mathbb{F}}}\) defaulting to \(0\) (if not provided).`param f_max[...];`

declares \(fu_j = f_{max_j} \geq fl_j, \forall j \in {{\mathbb{F}}}\) defaulting to \(2\). \([fl_j, fu_j]\) seems to be the lower and upper limits on the number of packages in the diet.`param n_min[...];`

declares \(nl_i = n_{min_i} \geq 0, \forall i \in {{\mathbb{N}}}\) defa

## Share on Social Media