14#ifndef OR_TOOLS_SAT_OPTIMIZATION_H_
15#define OR_TOOLS_SAT_OPTIMIZATION_H_
20#include "absl/random/bit_gen_ref.h"
21#include "ortools/sat/boolean_problem.pb.h"
28#include "ortools/sat/sat_parameters.pb.h"
45 std::vector<Literal>* core);
72 const LinearBooleanProblem& problem,
74 std::vector<bool>* solution);
85 const LinearBooleanProblem& problem,
86 SatSolver* solver, std::vector<bool>* solution);
93 LogBehavior log,
const LinearBooleanProblem& problem,
int num_times,
94 absl::BitGenRef random, SatSolver* solver, std::vector<bool>* solution);
104 const LinearBooleanProblem& problem,
106 std::vector<bool>* solution);
112 LogBehavior log,
const LinearBooleanProblem& problem, SatSolver* solver,
113 std::vector<bool>* solution);
118 LogBehavior log,
const LinearBooleanProblem& problem, SatSolver* solver,
119 std::vector<bool>* solution);
131 IntegerVariable objective_var,
132 const std::function<
void()>& feasible_solution_observer, Model*
model);
137 IntegerVariable objective_var,
138 const std::function<
void()>& feasible_solution_observer, Model*
model);
151 const std::vector<IntegerVariable>& variables,
153 std::function<
void()> feasible_solution_observer,
171 const std::vector<Literal>& literals,
178 struct ObjectiveTerm {
182 IntegerValue old_var_lb;
186 IntegerValue cover_ub;
192 bool ProcessSolution();
196 bool PropagateObjectiveBounds();
200 bool CoverOptimization();
204 void ComputeNextStratificationThreshold();
218 void PresolveObjectiveWithAtMostOne(std::vector<Literal>* literals,
222 SatParameters* parameters_;
230 IntegerVariable objective_var_;
231 std::vector<ObjectiveTerm> terms_;
232 IntegerValue stratification_threshold_;
233 std::function<void()> feasible_solution_observer_;
237 bool already_switched_to_linear_scan_ =
false;
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
CoreBasedOptimizer(IntegerVariable objective_var, const std::vector< IntegerVariable > &variables, const std::vector< IntegerValue > &coefficients, std::function< void()> feasible_solution_observer, Model *model)
SatSolver::Status Optimize()
SatSolver::Status OptimizeWithSatEncoding(const std::vector< Literal > &literals, const std::vector< Coefficient > &coefficients, Coefficient offset)
Class that owns everything related to a particular optimization model.
absl::Span< const double > coefficients
std::tuple< int64_t, int64_t, const double > Coefficient
void RestrictObjectiveDomainWithBinarySearch(IntegerVariable objective_var, const std::function< void()> &feasible_solution_observer, Model *model)
SatSolver::Status SolveWithCardinalityEncodingAndCore(LogBehavior log, const LinearBooleanProblem &problem, SatSolver *solver, std::vector< bool > *solution)
SatSolver::Status SolveWithLinearScan(LogBehavior log, const LinearBooleanProblem &problem, SatSolver *solver, std::vector< bool > *solution)
SatSolver::Status SolveWithRandomParameters(LogBehavior log, const LinearBooleanProblem &problem, int num_times, absl::BitGenRef random, SatSolver *solver, std::vector< bool > *solution)
SatSolver::Status SolveWithWPM1(LogBehavior log, const LinearBooleanProblem &problem, SatSolver *solver, std::vector< bool > *solution)
void MinimizeCoreWithPropagation(TimeLimit *limit, SatSolver *solver, std::vector< Literal > *core)
SatSolver::Status SolveWithFuMalik(LogBehavior log, const LinearBooleanProblem &problem, SatSolver *solver, std::vector< bool > *solution)
SatSolver::Status SolveWithCardinalityEncoding(LogBehavior log, const LinearBooleanProblem &problem, SatSolver *solver, std::vector< bool > *solution)
SatSolver::Status MinimizeIntegerVariableWithLinearScanAndLazyEncoding(IntegerVariable objective_var, const std::function< void()> &feasible_solution_observer, Model *model)
Collection of objects used to extend the Constraint Solver library.