Difference: LogicInAMPL (2 vs. 3)

Revision 32008-03-18 - TWikiAdminUser

Line: 1 to 1
 
META TOPICPARENT name="AMPLSyntax"

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:
Expression Meaning
< Less than
Changed:
<
<
< Less than or equal to
>
>
<= Less than or equal to
 
> Greater than
>= Greater than or equal to
>= Equal to
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:

  1. {\tt <e> in <SET>} is true if {\tt <e>} is a member of {\tt <SET>};
  2. {\tt <e> not in <SET>} is false if {\tt <e>} is a member of {\tt <SET>};
  3. exists { in } is true if some in has being true;
  4. forall { in } is true if all in have being true;
  5. within is true if all the elements in are in ;
  6. not within is true if some element in is 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:

  1. <e> in <SET> is true if <e> is a member of <SET>;
  2. {\tt <e> not in <SET>} is false if <e> is a member of <SET>;
  3. exists {<e> in <SET>} <expression> is true if some <e> in <SET> has <expression> being true;
  4. forall {<e> in <SET>} <expression> is true if all <e> in <SET> have <expression> being true;
  5. <SUBSET> within <SET> is true if all the elements in <SUBSET> are in <SET>;
  6. <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;

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback