Sat.ConstraintLogical, linear, and other constraints.
This is the raw form of constraints accepted by CP-SAT. See below for more convenient functions.
An equality between a target linear expression and an operation, given externally, applied to multiple linear expression arguments. The target must be a (scaled) variable or constant, otherwise add raises Invalid_argument.
An equality between a target linear expression and a operation, given externally, applied to a linear expression and a constant argument. The target must be a (scaled) variable or constant, otherwise add raises Invalid_argument. Similarly, arg2 must be a (scaled) constant, but this cannot always be fully checked.
type t = | Or of Var.t_bool listAt least one of the literals must be true.
*)| And of Var.t_bool listAll literals must be true.
*)| At_most_one of Var.t_bool listAt most one literal is true. Sum literals <= 1.
*)| Exactly_one of Var.t_bool listExactly one literal is true. Sum literals == 1.
*)| Xor of Var.t_bool listAn odd number of literals is true.
*)| Div of equality2Integer division by a constant.
*)| Mod of equality2Integer modulo a constant.
*)| Prod of equalityConstrain a variable to equal the product of linear expressions.
*)| Max of equalityConstrain a variable to equal the maximum of a list of linear expressions.
*)| Linear of LinearExpr.t * Domain.tConstrains a linear expression to a domain. Values of type Linear of lt are created by the (<=), (==), and similar operators.
| All_diff of LinearExpr.t listRequire that a list of (scaled) variables and constants have different values from each other.
*)The primitive constraints treated by CP-SAT.
val bool_or : Var.t_bool list -> tAt least one of the literals must be true. Same as Or.
val bool_and : Var.t_bool list -> tAll literals must be true. Same as And.
val bool_xor : Var.t_bool list -> tAn odd number of literals is true. Same as Xor.
val at_most_one : Var.t_bool list -> tAt most one literal is true. Sum literals <= 1. Same as At_most_one.
val exactly_one : Var.t_bool list -> tExactly one literal is true. Sum literals == 1. Same as Exactly_one.
val at_least_one : Var.t_bool list -> tAt least one of the literals must be true. Same as Or.
module WithArray : sig ... endConstraints with arrays as arguments .
val implication : Var.t_bool -> Var.t_bool -> tLogical implication between two literals. (implication a b is the same as Or [(Var.not a); b] .)
val multiplication_equality : 'a Var.t -> LinearExpr.t list -> tConstrain a variable to equal the product of linear expressions. Slightly less general than Prod since the left-hand-side may also be a scaled variable or a constant. multiplication_equality v [x y z] means v = x * y * z.
val division_equality : 'a Var.t -> LinearExpr.t -> int -> tInteger division by a constant. Slightly less general than Div, since the left-hand-side may also be a scaled variable or a constant. division_equality x e c means x = e // c.
val modulo_equality : 'a Var.t -> LinearExpr.t -> int -> tInteger modulo a constant. Slightly less general than Mod, since the left-hand-side may also be a scaled variable or a constant. modulo_equality x e c means x = e % c.
val max_equality : 'a Var.t -> LinearExpr.t list -> tConstrain a variable to equal the maximum of a list of linear expressions. Slightly less general than Max since the left-hand-side may also be a scaled variable or a constant.
val min_equality : 'a Var.t -> LinearExpr.t list -> tSlightly less general than min since the left-hand-side may also be a scaled variable or a constant.
val abs_equality : 'a Var.t -> LinearExpr.t list -> tSlightly less general than abs since the left-hand-side may also be a scaled variable or a constant.
val all_different : LinearExpr.t list -> tRequire that a list of (scaled) variables and constants have different values from each other. Same as All_diff.
val of_expr : LinearExpr.t -> lb:int -> ub:int -> tA linear constraint: of_expr e lb ub means lb <= e <= ub.
val in_domain : LinearExpr.t -> Domain.t -> tinclude module type of LinearExpr.Lval zero : LinearExpr.tAn empty linear expression.
val var : 'a Var.t -> LinearExpr.tA single variable.
val (*) : int -> 'a Var.t -> LinearExpr.tA single term.
val (+) : LinearExpr.t -> LinearExpr.t -> LinearExpr.tConcatenatation of two linear expressions.
val (-) : LinearExpr.t -> LinearExpr.t -> LinearExpr.tConcatenatation of the left expression with the negation of the right expression.
val scale : int -> LinearExpr.t -> LinearExpr.tMultiplication of a linear expression by a constant.
val of_int : int -> LinearExpr.tA constant linear expression.
val not : Var.t_bool -> Var.t_boolComplement a boolean literal. Same as Var.not.
module Linear : sig ... endval to_string : t -> stringReturn a string representing the linear expression.
val pp : Stdlib.Format.formatter -> t -> unitPretty-printer for linear expressions.