14#ifndef OR_TOOLS_SAT_FEASIBILITY_PUMP_H_
15#define OR_TOOLS_SAT_FEASIBILITY_PUMP_H_
22#include "absl/container/flat_hash_map.h"
33#include "ortools/sat/sat_parameters.pb.h"
50 max_fp_iterations_ =
std::max(1, max_iter);
75 return integer_solution_objective_;
78 return integer_solution_is_feasible_;
95 bool NearestIntegerRounding();
106 bool LockBasedRounding();
110 bool ActiveLockBasedRounding();
122 bool PropagationRounding();
124 void FillIntegerSolutionStats();
127 void InitializeWorkingLP();
131 void L1DistanceMinimize();
135 void MaybePushToRepo();
140 double GetVariableValueAtCpScale(glop::ColIndex
var);
143 using LinearExpression = std::vector<std::pair<glop::ColIndex, IntegerValue>>;
147 glop::ColIndex GetOrCreateMirrorVariable(IntegerVariable positive_variable);
150 void UpdateBoundsOfLpVariables();
155 static const double kCpEpsilon;
159 struct LinearConstraintInternal {
164 LinearExpression integer_objective_;
165 IntegerValue objective_infinity_norm_ = IntegerValue(0);
166 double objective_normalization_factor_ = 0.0;
167 double mixing_factor_ = 1.0;
170 int model_vars_size_ = 0;
187 std::vector<IntegerVariable> integer_variables_;
188 absl::flat_hash_map<IntegerVariable, glop::ColIndex> mirror_lp_variable_;
191 std::vector<bool> var_is_binary_;
196 std::vector<int> var_up_locks_;
197 std::vector<int> var_down_locks_;
201 bool objective_is_defined_ =
false;
204 const SatParameters& sat_parameters_;
206 IntegerTrail* integer_trail_;
208 IntegerEncoder* integer_encoder_;
209 SharedIncompleteSolutionManager* incomplete_solutions_;
210 SatSolver* sat_solver_;
211 IntegerDomains* domains_;
212 const CpModelMapping* mapping_;
215 bool lp_solution_is_set_ =
false;
216 bool lp_solution_is_integer_ =
false;
217 double lp_objective_;
218 std::vector<double> lp_solution_;
219 std::vector<double> best_lp_solution_;
221 double lp_solution_fractionality_;
224 bool integer_solution_is_set_ =
false;
225 bool integer_solution_is_feasible_ =
false;
226 int64_t integer_solution_objective_;
227 std::vector<int64_t> integer_solution_;
228 std::vector<int64_t> best_integer_solution_;
229 int num_infeasible_constraints_;
231 int64_t integer_solution_infeasibility_;
235 int64_t total_num_simplex_iterations_ = 0;
238 int max_fp_iterations_ = 20;
240 bool model_is_unsat_ =
false;
A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...
bool HasIntegerSolution() const
double LPSolutionFractionality() const
void SetMaxFPIterations(int max_iter)
FeasibilityPump(Model *model)
double LPSolutionObjectiveValue() const
int64_t IntegerSolutionObjectiveValue() const
glop::RowIndex ConstraintIndex
double GetLPSolutionValue(IntegerVariable variable) const
int64_t GetIntegerSolutionValue(IntegerVariable variable) const
void AddLinearConstraint(const LinearConstraint &ct)
bool IntegerSolutionIsFeasible() const
bool HasLPSolution() const
void SetObjectiveCoefficient(IntegerVariable ivar, IntegerValue coeff)
bool LPSolutionIsInteger() const
Class that owns everything related to a particular optimization model.
Collection of objects used to extend the Constraint Solver library.