Skip to content

Commit

Permalink
Adding comment to AND as it is only truely useful in combination with…
Browse files Browse the repository at this point in the history
… reification.
  • Loading branch information
d-krupke committed Jul 17, 2024
1 parent 57f38bd commit 1f148e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions 04_modelling.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,16 @@ model.add_bool_and(b1, b2.Not(), b3.Not()) # b1 and not b2 and not b3 must all
model.add_bool_and(b1, ~b2, ~b3) # Alternative notation using '~' for negation
```

The `add_bool_and` method is most effective when used with the `only_enforce_if`
method. For cases not utilizing `only_enforce_if` a simple AND-clause such as
$\left( b_1 \land \neg b_2 \land \neg b_3 \right)$ becomes redundant by simply
substituting $b_1$ with `1` and $b_2`, $b_3` with `0`. In straightforward
scenarios, consider substituting these variables with their constant values to
reduce unnecessary complexity, especially in larger models where size and
manageability are concerns. In smaller or simpler models, CP-SAT efficiently
handles these redundancies, allowing you to focus on maintaining clarity and
readability in your model.

#### Adding Logical XOR Constraints

The logical XOR (exclusive OR) operation ensures that an odd number of operands
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,16 @@ model.add_bool_and(b1, b2.Not(), b3.Not()) # b1 and not b2 and not b3 must all
model.add_bool_and(b1, ~b2, ~b3) # Alternative notation using '~' for negation
```

The `add_bool_and` method is most effective when used with the `only_enforce_if`
method. For cases not utilizing `only_enforce_if` a simple AND-clause such as
$\left( b_1 \land \neg b_2 \land \neg b_3 \right)$ becomes redundant by simply
substituting $b_1$ with `1` and $b_2`, $b_3` with `0`. In straightforward
scenarios, consider substituting these variables with their constant values to
reduce unnecessary complexity, especially in larger models where size and
manageability are concerns. In smaller or simpler models, CP-SAT efficiently
handles these redundancies, allowing you to focus on maintaining clarity and
readability in your model.

#### Adding Logical XOR Constraints

The logical XOR (exclusive OR) operation ensures that an odd number of operands
Expand Down

0 comments on commit 1f148e7

Please sign in to comment.