14#ifndef OR_TOOLS_SAT_BOOLEAN_PROBLEM_H_
15#define OR_TOOLS_SAT_BOOLEAN_PROBLEM_H_
21#include "absl/status/status.h"
24#include "ortools/sat/boolean_problem.pb.h"
25#include "ortools/sat/cp_model.pb.h"
40 const LinearBooleanProblem& problem, Coefficient v) {
41 return (
static_cast<double>(v.value()) + problem.objective().offset()) *
42 problem.objective().scaling_factor();
55 const SatSolver& solver, std::vector<bool>* assignment);
89 const std::vector<bool>& assignment);
93 const std::vector<bool>& assignment);
99 const LinearBooleanProblem& problem);
105 BooleanAssignment* output);
109 const std::vector<int>& constraint_indices,
110 LinearBooleanProblem* subproblem);
121 const LinearBooleanProblem& problem,
122 std::vector<std::unique_ptr<SparsePermutation>>* generators);
133 LinearBooleanProblem* problem);
140 LinearBooleanProblem* problem);
bool AddObjectiveConstraint(const LinearBooleanProblem &problem, bool use_lower_bound, Coefficient lower_bound, bool use_upper_bound, Coefficient upper_bound, SatSolver *solver)
bool LoadBooleanProblem(const LinearBooleanProblem &problem, SatSolver *solver)
Loads a BooleanProblem into a given SatSolver instance.
void ApplyLiteralMappingToBooleanProblem(const util_intops::StrongVector< LiteralIndex, LiteralIndex > &mapping, LinearBooleanProblem *problem)
double AddOffsetAndScaleObjectiveValue(const LinearBooleanProblem &problem, Coefficient v)
Adds the offset and returns the scaled version of the given objective value.
std::string LinearBooleanProblemToCnfString(const LinearBooleanProblem &problem)
void StoreAssignment(const VariablesAssignment &assignment, BooleanAssignment *output)
bool LoadAndConsumeBooleanProblem(LinearBooleanProblem *problem, SatSolver *solver)
void ExtractAssignment(const LinearBooleanProblem &problem, const SatSolver &solver, std::vector< bool > *assignment)
void MakeAllLiteralsPositive(LinearBooleanProblem *problem)
void ExtractSubproblem(const LinearBooleanProblem &problem, const std::vector< int > &constraint_indices, LinearBooleanProblem *subproblem)
Constructs a sub-problem formed by the constraints with given indices.
bool AddObjectiveUpperBound(const LinearBooleanProblem &problem, Coefficient upper_bound, SatSolver *solver)
Adds the constraint that the objective is smaller than the given upper bound.
void ProbeAndSimplifyProblem(SatPostsolver *postsolver, LinearBooleanProblem *problem)
void ChangeOptimizationDirection(LinearBooleanProblem *problem)
void FindLinearBooleanProblemSymmetries(const LinearBooleanProblem &problem, std::vector< std::unique_ptr< SparsePermutation > > *generators)
CpModelProto BooleanProblemToCpModelproto(const LinearBooleanProblem &problem)
absl::Status ValidateBooleanProblem(const LinearBooleanProblem &problem)
bool IsAssignmentValid(const LinearBooleanProblem &problem, const std::vector< bool > &assignment)
Checks that an assignment is valid for the given BooleanProblem.
Coefficient ComputeObjectiveValue(const LinearBooleanProblem &problem, const std::vector< bool > &assignment)
Returns the objective value under the current assignment.
void UseObjectiveForSatAssignmentPreference(const LinearBooleanProblem &problem, SatSolver *solver)
In SWIG mode, we don't want anything besides these top-level includes.