Ortools.SatBuild a model for CP-SAT
val make : ?nvars:int -> ?name:string -> unit -> modelCreate an empty model with an optional name. The nvars argument optionally specifies the expected number of variables, which determines the size and growth of internal data structures.
module Domain : sig ... endA subset of the integers.
module Var : sig ... endRepresentation of integer variables and boolean literals.
module LinearExpr : sig ... endLinear expressions are used in linear constraints and to specify objectives.
include 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 Constraint : sig ... endLogical, linear, and other constraints.
val add :
model ->
?name:string ->
?only_enforce_if:Var.t_bool list ->
Constraint.t ->
unitAdd a constraint to the model, with an optional name. The constraint is conditional if the only_enforce_if argument is a non-empty list of boolean literals.
val add_implication :
model ->
?name:string ->
Var.t_bool list ->
Var.t_bool list ->
unitAdds an implication constraint to the model. add_implication m lhs rhs = add m ~only_enforce_if:lhs (Constraint.And rhs)
include module type of Constraint.Linearval (<=) : LinearExpr.t -> LinearExpr.t -> Constraint.tA linear constraint: lhs <= rhs.
val (>=) : LinearExpr.t -> LinearExpr.t -> Constraint.tA linear constraint: lhs >= rhs.
val (<) : LinearExpr.t -> LinearExpr.t -> Constraint.tA linear constraint: lhs < rhs.
val (>) : LinearExpr.t -> LinearExpr.t -> Constraint.tA linear constraint: lhs > rhs.
val (==) : LinearExpr.t -> LinearExpr.t -> Constraint.tA linear constraint: lhs == rhs.
val (!=) : LinearExpr.t -> LinearExpr.t -> Constraint.tA Linear constraint: lhs != rhs.
val maximize : model -> LinearExpr.t -> unitThe linear expression to maximize. Any existing objective is replaced.
val minimize : model -> LinearExpr.t -> unitThe linear expression to minimize. Any existing objective is replaced.
Suggest initial solutions for the given variables.
val clear_hints : model -> unitRemove any initial solutions.
val add_assumptions : model -> Var.t_bool list -> unitAdd assumptions on boolean literals.
val clear_assumptions : model -> unitClear any assumptions on boolean literals.
type variable_selection_strategy = | ChooseFirstThe first variable in the list that is not fixed.
*)| ChooseLowestMinThe variable that might take the lowest value.
*)| ChooseHighestMaxThe variable that might take the highest value.
*)| ChooseMinDomainSizeThe variable having the fewest feasible assignments.
*)| ChooseMaxDomainSizeThe variable having the most feasible assignments.
*)Specifies branching decisions on variables.
type domain_reduction_strategy = | SelectMinValueTry to assign the smallest value.
*)| SelectMaxValueTry to assign the largest value.
*)| SelectLowerHalfBranch to the lower half of the domain.
*)| SelectUpperHalfBranch to the upper half of the domain.
*)| SelectMedianValueTry to assign the median value.
*)| SelectRandomHalfRandomly select either the lower or the upper half of the domain.
*)Specifies branching decisions on domains.
val add_decision_strategy :
model ->
'a Var.t list ->
variable_selection_strategy ->
domain_reduction_strategy ->
unitControls how the solver branches when no further deductions are possible. The selection and reduction strategies are applied to the given list of variables in order. Adding a new decision strategy replaces any existing one.
val add_decision_strategy_with_exprs :
model ->
LinearExpr.t list ->
variable_selection_strategy ->
domain_reduction_strategy ->
unitControls how the solver branches when no further deductions are possible. The selection and reduction strategies are applied to the given list of expressions. Adding a new decision strategy replaces any existing one.
module Parameters : sig ... endEncode a set of parameters as a protocol buffer.
module Response : sig ... endA response from CP-SAT for a given problem.
An interface for invoking CP-SAT. This function is passed protocol buffers for the parameters and the model and should return a protocol buffer for the response.
val solve : raw_solver -> ?parameters:Parameters.t -> model -> Response.tCalls a raw_solver with encoded versions of the parameters and model and returns the decoded response.
val to_proto : model -> Cp_model.cp_model_protoConverts a model to a protocol buffer. NB: copying is minimized, so the returned data structure shares some (mutable) data structures with the model. I.e., it becomes invalid if the model is changed.
val pb_output : model -> Stdlib.out_channel -> unitSend the model to the output channel as a protocol buffer.
val pb_encode : model -> Pbrt.Encoder.t -> unitEncode a model.