Page
Library
Module
Module type
Parameter
Class
Class type
Source
Ortools.SatSourceBuild a model for CP-SAT
A CP-SAT model.
Create an empty model. The nvars argument optionally specifies the expected number of variables, which determines the size and growth of internal data structures. The optional name argument is useful for debugging and logging applications with multiple models.
Linear expressions are used in linear constraints and to specify objectives.
include module type of LinearExpr.LAn empty linear expression.
A single variable.
A single term.
Concatenatation of two linear expressions.
Concatenatation of the left expression with the negation of the right expression.
Multiplication of a linear expression by a constant.
A constant linear expression.
Complement a boolean literal. Same as Var.not.
Logical, linear, and other constraints.
Add 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.
Adds 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.LinearA linear constraint: lhs <= rhs.
A linear constraint: lhs >= rhs.
A linear constraint: lhs < rhs.
A linear constraint: lhs > rhs.
A linear constraint: lhs == rhs.
A Linear constraint: lhs != rhs.
The linear expression to maximize. Any existing objective is replaced.
The linear expression to minimize. Any existing objective is replaced.
Suggest an initial solution for the given variable.
Suggest initial solutions for the given variables.
Add 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.
Encode a set of parameters as a protocol buffer.
type raw_solver =
?observer_pb:(string -> unit) ->
parameters_pb:string ->
model_pb:string ->
unit ->
stringAn 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 ->
?observer:(Response.t -> unit) ->
?parameters:Parameters.t ->
model ->
Response.tCalls a raw_solver with encoded versions of the parameters and model and returns the decoded response. If a (feasible solution) observer is given, it will be invoked for each feasible solution. Set Sat_parameters.sat_parameters.enumerate_all_solutions, to observe them all.
Converts 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.
Send the model to the output channel as a protocol buffer.
Encode a model.