 |
OR-Tools
8.0
|
Go to the documentation of this file.
14 #ifndef OR_TOOLS_SAT_CP_MODEL_LOADER_H_
15 #define OR_TOOLS_SAT_CP_MODEL_LOADER_H_
20 #include "absl/container/flat_hash_set.h"
47 std::vector<IntegerVariable>
vars;
78 bool view_all_booleans_as_integers,
Model* m);
123 CHECK_LT(i, intervals_.size());
125 return intervals_[i];
128 template <
typename List>
129 std::vector<IntegerVariable>
Integers(
const List& list)
const {
130 std::vector<IntegerVariable> result;
131 for (
const auto i : list) result.push_back(
Integer(i));
135 template <
typename ProtoIndices>
136 std::vector<sat::Literal>
Literals(
const ProtoIndices& indices)
const {
137 std::vector<sat::Literal> result;
142 template <
typename ProtoIndices>
143 std::vector<IntervalVariable>
Intervals(
const ProtoIndices& indices)
const {
144 std::vector<IntervalVariable> result;
145 for (
const int i : indices) result.push_back(
Interval(i));
154 return already_loaded_ct_.contains(
ct);
163 return is_half_encoding_ct_.contains(
ct);
168 if (
var.value() >= reverse_boolean_map_.
size())
return -1;
169 return reverse_boolean_map_[
var];
172 if (
var.value() >= reverse_integer_map_.
size())
return -1;
173 return reverse_integer_map_[
var];
183 for (
const IntegerVariable
var : integers_) {
190 for (
const BooleanVariable
var : booleans_) {
201 const auto& it = variables_to_encoded_values_.find(
var);
202 if (it != variables_to_encoded_values_.end()) {
211 std::vector<IntegerVariable> integers_;
212 std::vector<IntervalVariable> intervals_;
213 std::vector<BooleanVariable> booleans_;
223 absl::flat_hash_set<const ConstraintProto*> already_loaded_ct_;
224 absl::flat_hash_set<const ConstraintProto*> is_half_encoding_ct_;
226 absl::flat_hash_map<int, absl::flat_hash_set<int64>>
227 variables_to_encoded_values_;
228 const absl::flat_hash_set<int64> empty_set_;
275 #endif // OR_TOOLS_SAT_CP_MODEL_LOADER_H_
int GetProtoVariableFromBooleanVariable(BooleanVariable var) const
int NumIntegerVariables() const
void LoadIntProdConstraint(const ConstraintProto &ct, Model *m)
const IntegerVariable kNoIntegerVariable(-1)
void LoadElementConstraint(const ConstraintProto &ct, Model *m)
sat::Literal Literal(int ref) const
void CreateVariables(const CpModelProto &model_proto, bool view_all_booleans_as_integers, Model *m)
void LoadRoutesConstraint(const ConstraintProto &ct, Model *m)
void LoadElementConstraintBounds(const ConstraintProto &ct, Model *m)
void LoadCircuitCoveringConstraint(const ConstraintProto &ct, Model *m)
absl::flat_hash_set< IntegerVariable > objective_impacting_variables
bool IsInteger(int ref) const
CpModelProto const * model_proto
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
std::vector< IntegerVariable > NegationOf(const std::vector< IntegerVariable > &vars)
bool ConstraintIsAlreadyLoaded(const ConstraintProto *ct) const
std::vector< sat::Literal > Literals(const ProtoIndices &indices) const
void LoadIntDivConstraint(const ConstraintProto &ct, Model *m)
void LoadCircuitConstraint(const ConstraintProto &ct, Model *m)
Class that owns everything related to a particular optimization model.
IntervalVariable Interval(int i) const
void LoadBoolAndConstraint(const ConstraintProto &ct, Model *m)
void LoadLinMaxConstraint(const ConstraintProto &ct, Model *m)
void LoadAtMostOneConstraint(const ConstraintProto &ct, Model *m)
void LoadBoolOrConstraint(const ConstraintProto &ct, Model *m)
std::vector< IntegerVariable > Integers(const List &list) const
bool LoadConstraint(const ConstraintProto &ct, Model *m)
double ScaleIntegerObjective(IntegerValue value) const
std::vector< IntervalVariable > Intervals(const ProtoIndices &indices) const
std::vector< IntegerValue > coeffs
void LoadAllDiffConstraint(const ConstraintProto &ct, Model *m)
int GetProtoVariableFromIntegerVariable(IntegerVariable var) const
void DetectOptionalVariables(const CpModelProto &model_proto, Model *m)
const std::vector< IntegerVariable > & GetVariableMapping() const
void LoadLinearConstraint(const ConstraintProto &ct, Model *m)
bool IsHalfEncodingConstraint(const ConstraintProto *ct) const
const BooleanVariable kNoBooleanVariable(-1)
void PropagateEncodingFromEquivalenceRelations(const CpModelProto &model_proto, Model *m)
IntegerVariable objective_var
IntegerVariable Integer(int ref) const
void LoadIntMinConstraint(const ConstraintProto &ct, Model *m)
void LoadNoOverlap2dConstraint(const ConstraintProto &ct, Model *m)
void LoadNoOverlapConstraint(const ConstraintProto &ct, Model *m)
double ToDouble(IntegerValue value)
void LoadBoolXorConstraint(const ConstraintProto &ct, Model *m)
bool RefIsPositive(int ref)
int NumBooleanVariables() const
void LoadElementConstraintAC(const ConstraintProto &ct, Model *m)
void MaybeFullyEncodeMoreVariables(const CpModelProto &model_proto, Model *m)
void LoadTableConstraint(const ConstraintProto &ct, Model *m)
void ExtractEncoding(const CpModelProto &model_proto, Model *m)
void LoadCumulativeConstraint(const ConstraintProto &ct, Model *m)
const absl::flat_hash_set< int64 > & PotentialEncodedValues(int var)
LinearExpression GetExprFromProto(const LinearExpressionProto &expr_proto, const CpModelMapping &mapping)
void LoadAutomatonConstraint(const ConstraintProto &ct, Model *m)
void LoadInverseConstraint(const ConstraintProto &ct, Model *m)
void LoadIntMaxConstraint(const ConstraintProto &ct, Model *m)
std::vector< IntegerVariable > vars
bool IsBoolean(int ref) const
const IntervalVariable kNoIntervalVariable(-1)