true
Returns a true Boolean expression.
Syntax
boolExpr true()
Parameters
None
Description
This function returns a true Boolean expression (boolExpr). CP Optimizer
usually eliminates true() from expressions using partial evaluation.
The function true() does not have any particular purpose except for being a
filler.
Example
When models are program-generated, it may be useful to use true() instead
of a missing boolean expression. Consider the following code:
// Variables a:
"a[1]" = intVar(0..20);
"a[2]" = intVar(0..20);
"a[3]" = intVar(0..20);
// Variables b (notice that b[2] does not exist):
"b[1]" = intVar(0..20);
"b[3]" = intVar(0..20);
// Automatically generated constraints between a[i] and b[i]:
("a[1]" > 5) => ("b[1]" > 7);
("a[2]" > 5) => true();
("a[3]" > 5) => ("b[3]" > 7);
There are several constraints in the form ("a[i]">5) => ("b[i]">7). However
variable b[2] does not exist, therefore the case i=2 must be treated in a
special way. Depending on the complexity of the problem the simplest and
convenient solution could be to use true() as replacement for the missing
condition and rely on CP Optimizer's partial evaluation to handle the rest.
In the example above the condition ("a[2]" > 5) => true() always holds and
therefore CP Optimizer eliminates it during the preprocessing (presolve).