xor
xor |
Purpose
Synopsis
function xor(c1:log_or_linctr,c2:log_or_linctr):logctr
Arguments
c1
|
A linear constraint (
linctr) or logical expression (
logctr)
|
c2
|
A linear constraint (
linctr) or logical expression (
logctr)
|
Return value
A new
logctr representing the expression.
Example
This example shows how to state an exclusive 'or' constraint that expresses the disjunction between two tasks with start time
sj and fixed duration
Dj. A non-exclusive 'or' relation can be stated by using the
or operator as shown in the last line (constraint
L).
declarations R=1..2 C: array(range) of linctr ! Linear constraints L: logctr ! Logical constraint s: array(R) of mpvar ! Decision variables (start times) D: array(R) of real ! Data (durations) end-declarations C(1):= s(1)+D(1)>=s(2) ! Define (temporary) linear constraints C(2):= s(2)+D(2)>=s(1) xor(C(1), C(2)) ! State an exclusive 'or' forall(j in 1..2) C(j):=0 ! Delete the auxiliary constraints ! The same 'xor' constraint can be stated by: xor(s(1)+D(1)>=s(2), s(2)+D(2)>=s(1)) ! A non-exclusive 'or' relation is stated by using the 'or' operator: L:= s(1)+D(1)>=s(2) or s(2)+D(2)>=s(1)
Further information
1. This function creates a
logctr constraint representing an
exclusive or condition:
either c1 or c2 is valid, not both.
2. The helper package 'advmod' must be loaded if this function is used:
uses 'advmod'
Related topics
Module