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

## Logic in AMPL | ||||||||

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

Relational operators are used to compare two expressions. They are most commonly used in constraints, but not exclusively. The relational operators are:
| ||||||||

Changed: | ||||||||

< < |
| |||||||

> > |
| |||||||

| ||||||||

Line: 24 to 24 | ||||||||

Return to top | ||||||||

Changed: | ||||||||

< < | ## Logical Expressions | |||||||

> > | ## Logical Expressions | |||||||

Logical expressions are expressions that will evaluate to either true or false. Logical expressions are usually defined in terms of the relational operators: | ||||||||

Changed: | ||||||||

< < | \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: - {\tt <e> in <SET>} is
*true*if {\tt <e>} is a member of {\tt <SET>}; - {\tt <e> not in <SET>} is
*false*if {\tt <e>} is a member of {\tt <SET>}; - exists {
in } is *true*if somein has being true; - forall {
in } is *true*if allin have being true; within is *true*if all the elements inare in ; not within is *true*if some element inis *not*in.
| |||||||

> > | Lower[r] <= sum {i in INGREDIENTS} Contributes[r, i] * Amount[i]
sum {s in SURFBOARDS} Recipe[m, s] * Production[s] <= Supply[m]; However, there are some special logical expressions in AMPL for use with sets: -
`<e> in <SET>` is*true*if`<e>` is a member of`<SET>` ; - {\tt <e> not in <SET>} is
*false*if`<e>` is a member of`<SET>` ; -
`exists {<e> in <SET>} <expression>` is*true*if some`<e>` in`<SET>` has`<expression>` being true; -
`forall {<e> in <SET>} <expression>` is*true*if all`<e>` in`<SET>` have`<expression>` being true; -
`<SUBSET> within <SET>` is*true*if all the elements in`<SUBSET>` are in`<SET>` ; -
`<SUBSET> not within <SET>` is*true*if some element in`<SUBSET>` is*not*in`<SET>` .
Logical expressions can be built up from other logical expressions, binary parameters and logical operators. | |||||||

Changed: | ||||||||

< < | Logical expressions can be built up from other logical expressions, binary parameters and logical operators. | |||||||

> > | Return to top | |||||||

Changed: | ||||||||

< < | ## Under Construction | |||||||

> > | ## Binary Parameters | |||||||

Deleted: | ||||||||

< < | ## Binary Parameters | |||||||

In AMPL we can create binary parameters by using the {\tt binary} keyword in the parameter declaration:
\begin{verbatim} param stillSearching binary; |

View topic | History: r7 < r6 < r5 < r4 | More topic actions...

Copyright © 2008-2021 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