20#ifndef OR_TOOLS_SAT_ENCODING_H_ 
   21#define OR_TOOLS_SAT_ENCODING_H_ 
   29#include "absl/log/check.h" 
   30#include "absl/types/span.h" 
   72                                  std::function<
Literal(
int x)> create_lit,
 
  100  int size()
 const { 
return literals_.size(); }
 
  103    CHECK_LT(
i, literals_.size());
 
 
  110    return depth_ > other.depth_ ||
 
  111           (depth_ == other.depth_ && other.for_sorting_ > for_sorting_);
 
 
  142  Coefficient 
weight()
 const { 
return weight_; }
 
  147  int depth()
 const { 
return depth_; }
 
  149  int lb()
 const { 
return lb_; }
 
  152  int ub()
 const { 
return ub_; }
 
  163  BooleanVariable for_sorting_;
 
  173  std::function<
Literal(
int x)> create_lit_ = 
nullptr;
 
  176  std::vector<Literal> literals_;
 
 
  182EncodingNode 
LazyMerge(EncodingNode* a, EncodingNode* 
b, SatSolver* solver);
 
  193EncodingNode 
FullMerge(Coefficient upper_bound, EncodingNode* a,
 
  194                       EncodingNode* 
b, SatSolver* solver);
 
  199                                     const std::vector<EncodingNode*>& nodes,
 
  201                                     std::deque<EncodingNode>* repository);
 
  207    Coefficient weight, 
const std::vector<EncodingNode*>& nodes,
 
  208    SatSolver* solver, std::deque<EncodingNode>* repository);
 
  213void ReduceNodes(Coefficient upper_bound, Coefficient* lower_bound,
 
  214                 std::vector<EncodingNode*>* nodes, SatSolver* solver);
 
  216                                        const std::vector<EncodingNode*>& nodes,
 
  222                                 absl::Span<const Literal> core);
 
  228                                     Coefficient upper_bound);
 
  236        sat_solver_(model->GetOrCreate<
SatSolver>()),
 
 
  242  bool ProcessCore(absl::Span<const Literal> core, Coefficient min_weight,
 
  243                   Coefficient gap, std::string* info);
 
  246    repository_.push_back(std::move(node));
 
  247    nodes_.push_back(&repository_.back());
 
 
  251  const std::vector<EncodingNode*>& 
nodes()
 const { 
return nodes_; }
 
  267  const bool alternative_encoding_ = 
false;
 
  270  std::vector<EncodingNode*> nodes_;
 
  271  std::deque<EncodingNode> repository_;
 
 
void InitializeLazyCoreNode(Coefficient weight, EncodingNode *a, EncodingNode *b)
Literal GreaterThan(int i) const
bool AssumptionIs(Literal other) const
GetAssumption() might need to create new literals.
void set_depth(int depth)
void InitializeFullNode(int n, EncodingNode *a, EncodingNode *b, SatSolver *solver)
Coefficient Reduce(const SatSolver &solver)
void InitializeLazyNode(EncodingNode *a, EncodingNode *b, SatSolver *solver)
int size() const
Accessors to size() and literals in [lb, current_ub).
std::string DebugString(const VariablesAssignment &assignment) const
We use the solver to display the current values of the literals.
static EncodingNode GenericNode(int lb, int ub, std::function< Literal(int x)> create_lit, Coefficient weight)
static EncodingNode ConstantNode(Coefficient weight)
void set_weight(Coefficient w)
void ApplyWeightUpperBound(Coefficient gap, SatSolver *solver)
bool IncreaseCurrentUB(SatSolver *solver)
static EncodingNode LiteralNode(Literal l, Coefficient weight)
Coefficient weight() const
void TransformToBoolean(SatSolver *solver)
Indicate that the node cannot grow further than its current assumption.
EncodingNode * child_b() const
Literal literal(int i) const
EncodingNode * child_a() const
void InitializeAmoNode(absl::Span< EncodingNode *const > nodes, SatSolver *solver)
bool operator<(const EncodingNode &other) const
Literal GetAssumption(SatSolver *solver)
std::vector< EncodingNode * > * mutable_nodes()
ObjectiveEncoder(Model *model)
void AddBaseNode(EncodingNode node)
const std::vector< EncodingNode * > & nodes() const
bool ProcessCore(absl::Span< const Literal > core, Coefficient min_weight, Coefficient gap, std::string *info)
EncodingNode * MergeAllNodesWithDeque(Coefficient upper_bound, const std::vector< EncodingNode * > &nodes, SatSolver *solver, std::deque< EncodingNode > *repository)
std::vector< Literal > ExtractAssumptions(Coefficient stratified_lower_bound, const std::vector< EncodingNode * > &nodes, SatSolver *solver)
void ReduceNodes(Coefficient upper_bound, Coefficient *lower_bound, std::vector< EncodingNode * > *nodes, SatSolver *solver)
Coefficient ComputeCoreMinWeight(const std::vector< EncodingNode * > &nodes, absl::Span< const Literal > core)
EncodingNode LazyMerge(EncodingNode *a, EncodingNode *b, SatSolver *solver)
EncodingNode FullMerge(Coefficient upper_bound, EncodingNode *a, EncodingNode *b, SatSolver *solver)
EncodingNode * LazyMergeAllNodeWithPQAndIncreaseLb(Coefficient weight, const std::vector< EncodingNode * > &nodes, SatSolver *solver, std::deque< EncodingNode > *repository)
void IncreaseNodeSize(EncodingNode *node, SatSolver *solver)
Coefficient MaxNodeWeightSmallerThan(const std::vector< EncodingNode * > &nodes, Coefficient upper_bound)
In SWIG mode, we don't want anything besides these top-level includes.
trees with all degrees equal w the current value of w