Expression | Meaning |
---|---|
< | Less than |
< | Less than or equal to |
> | Greater than |
>= | Greater than or equal to |
>= | Equal to |
<> | Not equal to |
\begin{verbatim} sum {i in INGREDIENTS} FatPercent[i] * Percentage[i] >= MinFat \end{verbatim}
\begin{verbatim} sum {i in INGREDIENTS} FibrePercent[i] * Percentage[i] <= MaxFibre; \end{verbatim}
However, there are some special logical expressions in AMPL for use with sets:
\begin{verbatim} param stillSearching binary; \end{verbatim}
Binary parameters are used in a similar way to boolean variables (in Matlab, C, etc) and logical variables (Fortran). If a binary parameter has the value 0 this is equivalent to false, and 1 is equivalent to true. Binary parameters can be used with conditional expressions to hold a true/false result from a logical expression:
\begin{verbatim} param isGreater binary;
let isGreater := if 4 > 5 then 1 else 0; # isGreater = 0 (false) let isGreater := if 6 > 5 then 1; # else 0 is the default, isGreater = 1 (true) \end{verbatim}so the syntax is
\begin{verbatim} \end{verbatim} or as the condition in a conditional statement or conditional structure. They are very useful for building complex conditional statements or structures:
\begin{verbatim} Some example from depth first searching or column generation \end{verbatim}
and controlling loops.