package ortools
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=2dfa5a221f07e7756afda6f23d066aae8ebb73254e201a44921f24e0491c5f7b
sha512=be451a999703a032444c632e0c87b4e391449cee0daa9f4837b0798fc7b8b1ce10abf7bc11dc7439a381a9281a7fb02b9239c75c3df0e4e70d2c690eeb8ae78c
doc/ortools/Ortools/Sat/index.html
Module Ortools.SatSource
Build a model for CP-SAT
Models
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
Linear expressions are used in linear constraints and to specify objectives.
include module type of LinearExpr.L
An 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.
Constraints
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.Linear
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.
A Linear constraint: lhs != rhs.
Objectives
The linear expression to maximize. Any existing objective is replaced.
The linear expression to minimize. Any existing objective is replaced.
Hints
Suggest an initial solution for the given variable.
Suggest initial solutions for the given variables.
Assumptions
Add assumptions on boolean literals.
Decision Strategies
type variable_selection_strategy = | ChooseFirst(*The first variable in the list that is not fixed.
*)| ChooseLowestMin(*The variable that might take the lowest value.
*)| ChooseHighestMax(*The variable that might take the highest value.
*)| ChooseMinDomainSize(*The variable having the fewest feasible assignments.
*)| ChooseMaxDomainSize(*The variable having the most feasible assignments.
*)
Specifies branching decisions on variables.
type domain_reduction_strategy = | SelectMinValue(*Try to assign the smallest value.
*)| SelectMaxValue(*Try to assign the largest value.
*)| SelectLowerHalf(*Branch to the lower half of the domain.
*)| SelectUpperHalf(*Branch to the upper half of the domain.
*)| SelectMedianValue(*Try to assign the median value.
*)| SelectRandomHalf(*Randomly 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.
Solutions
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.
val proto_solve :
raw_solver ->
?observer:(Cp_model.cp_solver_response -> unit) ->
?parameters:Sat_parameters.sat_parameters ->
Cp_model.cp_model_proto ->
Cp_model.cp_solver_responseAs for solve, but works directly with protocol buffers rather than through the structured interface.
Output
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.