14#ifndef OR_TOOLS_BOP_BOP_BASE_H_
15#define OR_TOOLS_BOP_BOP_BASE_H_
23#include "absl/base/thread_annotations.h"
24#include "absl/strings/string_view.h"
25#include "absl/synchronization/mutex.h"
28#include "ortools/bop/bop_parameters.pb.h"
32#include "ortools/sat/boolean_problem.pb.h"
137 assignment_preference_ =
a;
140 return assignment_preference_;
192 return fixed_values_[
var];
195 return fixed_values_;
211 return original_problem_;
223 return (
lower_bound() + original_problem_.objective().offset()) *
224 original_problem_.objective().scaling_factor();
235 const sat::LinearBooleanProblem& original_problem_;
236 BopParameters parameters_;
237 int64_t update_stamp_;
242 std::vector<bool> assignment_preference_;
244 int64_t lower_bound_;
245 int64_t upper_bound_;
Base class to print a nice summary of a group of statistics.
virtual ~BopOptimizerBase()
BopOptimizerBase(absl::string_view name)
virtual Status Optimize(const BopParameters ¶meters, const ProblemState &problem_state, LearnedInfo *learned_info, TimeLimit *time_limit)=0
@ ABORT
There is no need to call this optimizer again on the same problem state.
virtual bool ShouldBeRun(const ProblemState &problem_state) const =0
const std::string & name() const
Returns the name given at construction.
static std::string GetStatusString(Status status)
Returns a string describing the status.
bool IsVariableFixed(VariableIndex var) const
void set_assignment_preference(const std::vector< bool > &a)
int64_t update_stamp() const
void MarkAsInfeasible()
Marks the problem state as infeasible.
const BopSolution & solution() const
void SynchronizationDone()
const util_intops::StrongVector< VariableIndex, bool > & fixed_values() const
void SetParameters(const BopParameters ¶meters)
Sets parameters, used for instance to get the tolerance, the gap limit...
int64_t lower_bound() const
const std::vector< sat::BinaryClause > & NewlyAddedBinaryClauses() const
Returns the newly added binary clause since the last SynchronizationDone().
LearnedInfo GetLearnedInfo() const
std::vector< bool > assignment_preference() const
bool MergeLearnedInfo(const LearnedInfo &learned_info, BopOptimizerBase::Status optimization_status)
ProblemState(const ProblemState &)=delete
This type is neither copyable nor movable.
const glop::DenseRow & lp_values() const
void MarkAsOptimal()
Marks the problem state as optimal.
ProblemState(const sat::LinearBooleanProblem &problem)
ProblemState & operator=(const ProblemState &)=delete
const BopParameters & GetParameters() const
static const int64_t kInitialStampValue
double GetScaledLowerBound() const
Returns the scaled lower bound of the original problem.
const util_intops::StrongVector< VariableIndex, bool > & is_fixed() const
bool IsInfeasible() const
Returns true when the problem is proved to be infeasible.
const sat::LinearBooleanProblem & original_problem() const
bool GetVariableFixedValue(VariableIndex var) const
int64_t upper_bound() const
A simple class to manage a set of binary clauses.
std::ostream & operator<<(std::ostream &os, BopOptimizerBase::Status status)
In SWIG mode, we don't want anything besides these top-level includes.
int64_t lower_bound
A lower bound (for multi-threading purpose).
BopSolution solution
New solution. Note that the solution might be infeasible.
LearnedInfo(const sat::LinearBooleanProblem &problem)
std::vector< sat::BinaryClause > binary_clauses
New binary clauses.
std::vector< sat::Literal > fixed_literals
Vector of all literals that have been fixed.