14#ifndef OR_TOOLS_SAT_MAX_HS_H_
15#define OR_TOOLS_SAT_MAX_HS_H_
24#include "absl/container/flat_hash_map.h"
26#include "ortools/linear_solver/linear_solver.pb.h"
27#include "ortools/sat/cp_model.pb.h"
35#include "ortools/sat/sat_parameters.pb.h"
62 const std::function<
void()>& feasible_solution_observer,
68 const int kUnextracted = -1;
71 std::vector<Literal> assumptions,
72 std::vector<std::vector<Literal>>* core);
75 void ExtractObjectiveVariables();
79 void ExtractAdditionalVariables(
80 const std::vector<IntegerVariable>& to_extract);
85 std::vector<IntegerVariable> ComputeAdditionalVariablesToExtract();
92 int GetExtractedIndex(IntegerVariable
var)
const;
95 bool ComputeInitialMpModel();
98 void ProjectAndAddAtMostOne(
const std::vector<Literal>& literals);
114 void TightenMpModel();
117 void AddCoresToTheMpModel(
const std::vector<std::vector<Literal>>& cores);
120 std::vector<Literal> BuildAssumptions(
121 IntegerValue stratified_threshold,
122 IntegerValue* next_stratified_threshold);
125 bool ProcessSolution();
128 bool ImportFromOtherWorkers();
131 const CpModelProto& model_proto_;
133 const std::function<void()> feasible_solution_observer_;
139 const SatParameters& parameters_;
146 MPConstraintProto* obj_constraint_ =
nullptr;
147 MPModelRequest request_;
148 MPSolutionResponse response_;
156 absl::flat_hash_map<LiteralIndex, std::vector<int>> assumption_to_indices_;
160 absl::flat_hash_map<std::pair<int, int64_t>,
int> mp_integer_literals_;
170 std::vector<std::pair<IntegerVariable, MPVariableProto*>>
171 extracted_variables_info_;
173 int num_extracted_at_most_ones_ = 0;
174 std::vector<std::pair<int, MPConstraintProto*>> linear_extract_info_;
177 std::vector<IntegerVariable> normalized_objective_variables_;
178 std::vector<IntegerValue> normalized_objective_coefficients_;
181 std::vector<std::vector<Literal>> temp_cores_;
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
SatSolver::Status Optimize()
HittingSetOptimizer(const CpModelProto &model_proto, const ObjectiveDefinition &objective_definition, const std::function< void()> &feasible_solution_observer, Model *model)
Class that owns everything related to a particular optimization model.
CpModelProto const * model_proto
Collection of objects used to extend the Constraint Solver library.