misc improvements in the code

This commit is contained in:
Laurent Perron
2016-12-13 15:49:57 +01:00
parent 9712afbb64
commit c0a5987ff5
18 changed files with 211 additions and 151 deletions

View File

@@ -27,7 +27,7 @@ void ParseFileByLines(const std::string& filename, std::vector<std::string>* lin
CHECK_NOTNULL(lines);
std::string result;
CHECK(file::GetContents(filename, &result, file::Defaults()).ok());
*lines = strings::Split(result, "\n", strings::SkipEmpty());
*lines = strings::Split(result, '\n', strings::SkipEmpty());
}
// VariableParser Implementation
@@ -41,7 +41,7 @@ void VariableParser::Parse() {
ParseFileByLines(filename_, &lines);
for (const std::string& line : lines) {
std::vector<std::string> tokens =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
if (tokens.empty()) {
continue;
}
@@ -68,7 +68,7 @@ void DomainParser::Parse() {
ParseFileByLines(filename_, &lines);
for (const std::string& line : lines) {
std::vector<std::string> tokens =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
if (tokens.empty()) {
continue;
}
@@ -99,7 +99,7 @@ void ConstraintParser::Parse() {
ParseFileByLines(filename_, &lines);
for (const std::string& line : lines) {
std::vector<std::string> tokens =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
if (tokens.empty()) {
continue;
}
@@ -158,7 +158,7 @@ void ParametersParser::Parse() {
objective = false;
if (line.find("=") != std::string::npos) {
std::vector<std::string> tokens =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
CHECK_GE(tokens.size(), 3);
coefficients.push_back(atoi32(tokens[2].c_str()));
}
@@ -275,8 +275,8 @@ void FindComponents(const std::vector<FapConstraint>& constraints,
int EvaluateConstraintImpact(const std::map<int, FapVariable>& variables,
const int max_weight_cost,
const FapConstraint constraint) {
const FapVariable variable1 = FindOrDie(variables, constraint.variable1);
const FapVariable variable2 = FindOrDie(variables, constraint.variable2);
const FapVariable& variable1 = FindOrDie(variables, constraint.variable1);
const FapVariable& variable2 = FindOrDie(variables, constraint.variable2);
const int degree1 = variable1.degree;
const int degree2 = variable2.degree;
const int max_degree = std::max(degree1, degree2);

View File

@@ -48,6 +48,7 @@
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include "base/commandlineflags.h"
@@ -95,7 +96,7 @@ class OrderingDecision : public Decision {
: variable1_(variable1),
variable2_(variable2),
value_(value),
operator_(operation) {}
operator_(std::move(operation)) {}
~OrderingDecision() override {}
// Apply will be called first when the decision is executed.

View File

@@ -121,7 +121,7 @@ class JobShopData {
void ProcessNewLine(const std::string& line) {
// TODO(user): more robust logic to support single-task jobs.
const std::vector<std::string> words =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
switch (problem_type_) {
case UNDEFINED: {
if (words.size() == 2 && words[0] == "instance") {

View File

@@ -99,7 +99,8 @@ void Solve(const std::vector<std::vector<Task>>& tasks_per_job, int horizon) {
// Chain the task belonging to the same job.
if (previous_interval != kNoIntervalVariable) {
model.Add(EndBeforeStart(previous_interval, interval));
model.Add(LowerOrEqual(model.Get(EndVar(previous_interval)),
model.Get(StartVar(interval))));
}
previous_interval = interval;
@@ -119,7 +120,7 @@ void Solve(const std::vector<std::vector<Task>>& tasks_per_job, int horizon) {
}
// The makespan will be greater than the end of each job.
model.Add(EndBefore(previous_interval, makespan));
model.Add(LowerOrEqual(model.Get(EndVar(previous_interval)), makespan));
}
// Add all the potential precedences between tasks on the same machine.

View File

@@ -91,7 +91,7 @@ class MultiDimKnapsackData {
// Used internally.
void ProcessNewLine(const std::string& line) {
const std::vector<std::string> words =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
line_read_++;
if (problem_type_ == -1) {
if (words.size() == 1) {

View File

@@ -65,7 +65,7 @@ class OpbReader {
void ProcessNewLine(LinearBooleanProblem* problem, const std::string& line) {
const std::vector<std::string> words =
strings::Split(line, " ", strings::SkipEmpty());
strings::Split(line, ' ', strings::SkipEmpty());
if (words.size() == 0 || words[0].empty() || words[0][0] == '*') {
return;
}

View File

@@ -177,7 +177,7 @@ bool LoadAndSolve(const std::string& pdp_file) {
<< kMaxInputFileSize << " bytes).";
return false;
}
lines = strings::Split(contents, "\n", strings::SkipEmpty());
lines = strings::Split(contents, '\n', strings::SkipEmpty());
}
// Reading header.
if (lines.empty()) {

View File

@@ -96,8 +96,8 @@ void Solve(const std::vector<int>& durations, const std::vector<int>& due_dates,
} else {
tardiness_vars[i] =
model.Add(NewIntegerVariable(0, horizon - due_dates[i]));
model.Add(
EndBeforeWithOffset(tasks[i], tardiness_vars[i], -due_dates[i]));
model.Add(LowerOrEqualWithOffset(model.Get(EndVar(tasks[i])),
tardiness_vars[i], -due_dates[i]));
}
// Experiments showed that the heuristic of choosing first the task that
@@ -149,7 +149,8 @@ void Solve(const std::vector<int>& durations, const std::vector<int>& due_dates,
}
++num_added_precedences;
model.Add(EndBeforeStart(tasks[i], tasks[j]));
model.Add(LowerOrEqual(model.Get(EndVar(tasks[i])),
model.Get(StartVar(tasks[j]))));
}
}
}

View File

@@ -1460,6 +1460,7 @@ SAT_LIB_OBJS = \
$(OBJ_DIR)/sat/boolean_problem.$O \
$(OBJ_DIR)/sat/clause.$O \
$(OBJ_DIR)/sat/cp_constraints.$O \
$(OBJ_DIR)/sat/cumulative.$O \
$(OBJ_DIR)/sat/disjunctive.$O \
$(OBJ_DIR)/sat/drat.$O \
$(OBJ_DIR)/sat/encoding.$O \
@@ -1476,7 +1477,7 @@ SAT_LIB_OBJS = \
$(OBJ_DIR)/sat/simplification.$O \
$(OBJ_DIR)/sat/symmetry.$O \
$(OBJ_DIR)/sat/table.$O \
$(OBJ_DIR)/sat/timetabling.$O \
$(OBJ_DIR)/sat/timetable.$O \
$(OBJ_DIR)/sat/util.$O \
$(OBJ_DIR)/sat/boolean_problem.pb.$O \
$(OBJ_DIR)/sat/sat_parameters.pb.$O
@@ -1507,6 +1508,12 @@ $(SRC_DIR)/sat/cp_constraints.h: \
$(SRC_DIR)/sat/model.h \
$(SRC_DIR)/util/sorted_interval_list.h
$(SRC_DIR)/sat/cumulative.h: \
$(SRC_DIR)/sat/integer.h \
$(SRC_DIR)/sat/intervals.h \
$(SRC_DIR)/sat/model.h \
$(SRC_DIR)/sat/sat_base.h
$(SRC_DIR)/sat/disjunctive.h: \
$(SRC_DIR)/sat/integer.h \
$(SRC_DIR)/sat/intervals.h \
@@ -1635,7 +1642,7 @@ $(SRC_DIR)/sat/table.h: \
$(SRC_DIR)/sat/integer.h \
$(SRC_DIR)/sat/model.h
$(SRC_DIR)/sat/timetabling.h: \
$(SRC_DIR)/sat/timetable.h: \
$(SRC_DIR)/sat/integer.h \
$(SRC_DIR)/sat/intervals.h \
$(SRC_DIR)/sat/model.h \
@@ -1676,6 +1683,14 @@ $(OBJ_DIR)/sat/cp_constraints.$O: \
$(SRC_DIR)/util/sort.h
$(CCC) $(CFLAGS) -c $(SRC_DIR)/sat/cp_constraints.cc $(OBJ_OUT)$(OBJ_DIR)$Ssat$Scp_constraints.$O
$(OBJ_DIR)/sat/cumulative.$O: \
$(SRC_DIR)/sat/cumulative.cc \
$(SRC_DIR)/sat/cumulative.h \
$(SRC_DIR)/sat/overload_checker.h \
$(SRC_DIR)/sat/sat_solver.h \
$(SRC_DIR)/sat/timetable.h
$(CCC) $(CFLAGS) -c $(SRC_DIR)/sat/cumulative.cc $(OBJ_OUT)$(OBJ_DIR)$Ssat$Scumulative.$O
$(OBJ_DIR)/sat/disjunctive.$O: \
$(SRC_DIR)/sat/disjunctive.cc \
$(SRC_DIR)/sat/disjunctive.h \
@@ -1788,13 +1803,13 @@ $(OBJ_DIR)/sat/table.$O: \
$(SRC_DIR)/base/stl_util.h
$(CCC) $(CFLAGS) -c $(SRC_DIR)/sat/table.cc $(OBJ_OUT)$(OBJ_DIR)$Ssat$Stable.$O
$(OBJ_DIR)/sat/timetabling.$O: \
$(SRC_DIR)/sat/timetabling.cc \
$(OBJ_DIR)/sat/timetable.$O: \
$(SRC_DIR)/sat/timetable.cc \
$(SRC_DIR)/sat/overload_checker.h \
$(SRC_DIR)/sat/precedences.h \
$(SRC_DIR)/sat/sat_solver.h \
$(SRC_DIR)/sat/timetabling.h
$(CCC) $(CFLAGS) -c $(SRC_DIR)/sat/timetabling.cc $(OBJ_OUT)$(OBJ_DIR)$Ssat$Stimetabling.$O
$(SRC_DIR)/sat/timetable.h
$(CCC) $(CFLAGS) -c $(SRC_DIR)/sat/timetable.cc $(OBJ_OUT)$(OBJ_DIR)$Ssat$Stimetable.$O
$(OBJ_DIR)/sat/util.$O: \
$(SRC_DIR)/sat/util.cc \
@@ -3127,3 +3142,4 @@ $(GEN_DIR)/constraint_solver/solver_parameters.pb.h: $(GEN_DIR)/constraint_solve
$(OBJ_DIR)/constraint_solver/solver_parameters.pb.$O: $(GEN_DIR)/constraint_solver/solver_parameters.pb.cc
$(CCC) $(CFLAGS) -c $(GEN_DIR)/constraint_solver/solver_parameters.pb.cc $(OBJ_OUT)$(OBJ_DIR)$Sconstraint_solver$Ssolver_parameters.pb.$O

View File

@@ -29,24 +29,31 @@ namespace {
// Note: For multi-character delimiters, this routine will split on *ANY* of
// the characters in the std::string, not the entire std::string as a single delimiter.
// ----------------------------------------------------------------------
template <typename ITR>
static inline void InternalSplitStringUsingChar(const std::string& full,
char c, ITR* result) {
const char* p = full.data();
const char* end = p + full.size();
while (p != end) {
if (*p == c) {
++p;
} else {
const char* start = p;
while (++p != end && *p != c) {
}
result->emplace_back(start, p - start);
}
}
return;
}
template <typename ITR>
static inline void InternalSplitStringUsing(const std::string& full,
const char* delim, ITR* result) {
// Optimize the common case where delim is a single character.
if (delim[0] != '\0' && delim[1] == '\0') {
char c = delim[0];
const char* p = full.data();
const char* end = p + full.size();
while (p != end) {
if (*p == c) {
++p;
} else {
const char* start = p;
while (++p != end && *p != c) {
}
result->emplace_back(start, p - start);
}
}
InternalSplitStringUsingChar(full, c, result);
return;
}
@@ -66,6 +73,13 @@ static inline void InternalSplitStringUsing(const std::string& full,
} // namespace
std::vector<std::string> Split(const std::string& full, char delim, int flags) {
CHECK_EQ(SkipEmpty(), flags);
std::vector<std::string> out;
InternalSplitStringUsingChar(full, delim, &out);
return out;
}
std::vector<std::string> Split(const std::string& full, const char* delim, int flags) {
CHECK_EQ(SkipEmpty(), flags);
std::vector<std::string> out;

View File

@@ -26,6 +26,8 @@
namespace strings {
std::vector<std::string> Split(const std::string& full, const char* delim, int flags);
std::vector<std::string> Split(const std::string& full, char delim, int flags);
// StringPiece version. Its advantages is that it avoids creating a lot of
// small strings. Note however that the full std::string must outlive the usage
// of the result.

View File

@@ -27,7 +27,7 @@ namespace {
// Helpers
int64 Eval(const Argument& arg,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
switch (arg.type) {
case Argument::INT_VALUE: {
return arg.Value();
@@ -47,7 +47,7 @@ int Size(const Argument& arg) {
}
int64 EvalAt(const Argument& arg, int pos,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
switch (arg.type) {
case Argument::INT_LIST: {
return arg.ValueAt(pos);
@@ -64,8 +64,9 @@ int64 EvalAt(const Argument& arg, int pos,
// Checkers
bool CheckAllDifferentInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckAllDifferentInt(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
std::unordered_set<int64> visited;
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
const int64 value = EvalAt(ct.arguments[0], i, evaluator);
@@ -79,7 +80,8 @@ bool CheckAllDifferentInt(const Constraint& ct,
}
bool CheckAlldifferentExcept0(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
std::unordered_set<int64> visited;
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
const int64 value = EvalAt(ct.arguments[0], i, evaluator);
@@ -93,7 +95,7 @@ bool CheckAlldifferentExcept0(
}
bool CheckAmong(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 expected = Eval(ct.arguments[0], evaluator);
int64 count = 0;
for (int i = 0; i < Size(ct.arguments[1]); ++i) {
@@ -104,8 +106,9 @@ bool CheckAmong(const Constraint& ct,
return count == expected;
}
bool CheckArrayBoolAnd(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckArrayBoolAnd(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 result = 1;
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
@@ -117,7 +120,7 @@ bool CheckArrayBoolAnd(const Constraint& ct,
}
bool CheckArrayBoolOr(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 result = 0;
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
@@ -128,8 +131,9 @@ bool CheckArrayBoolOr(const Constraint& ct,
return result == Eval(ct.arguments[1], evaluator);
}
bool CheckArrayBoolXor(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckArrayBoolXor(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 result = 0;
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
@@ -139,8 +143,9 @@ bool CheckArrayBoolXor(const Constraint& ct,
return result % 2 == 1;
}
bool CheckArrayIntElement(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckArrayIntElement(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
if (ct.arguments[0].variables.size() == 2) {
// TODO(user): Check 2D element.
return true;
@@ -152,8 +157,9 @@ bool CheckArrayIntElement(const Constraint& ct,
return element == target;
}
bool CheckArrayVarIntElement(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckArrayVarIntElement(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
if (ct.arguments[0].variables.size() == 2) {
// TODO(user): Check 2D element.
return true;
@@ -166,7 +172,7 @@ bool CheckArrayVarIntElement(const Constraint& ct,
}
bool CheckAtMostInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 expected = Eval(ct.arguments[0], evaluator);
const int64 value = Eval(ct.arguments[2], evaluator);
@@ -178,7 +184,7 @@ bool CheckAtMostInt(const Constraint& ct,
}
bool CheckBoolAnd(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -186,7 +192,7 @@ bool CheckBoolAnd(const Constraint& ct,
}
bool CheckBoolClause(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 result = 0;
// Positive variables.
@@ -204,14 +210,14 @@ bool CheckBoolClause(const Constraint& ct,
}
bool CheckBoolNot(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left == 1 - right;
}
bool CheckBoolOr(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -219,7 +225,7 @@ bool CheckBoolOr(const Constraint& ct,
}
bool CheckBoolXor(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 target = Eval(ct.arguments[2], evaluator);
@@ -227,7 +233,7 @@ bool CheckBoolXor(const Constraint& ct,
}
bool CheckCircuit(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
// There are two versions of the constraint. 0 based and 1 based.
// Let's try to detect which one we have.
const int size = Size(ct.arguments[0]);
@@ -254,7 +260,7 @@ bool CheckCircuit(const Constraint& ct,
}
int64 ComputeCount(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 result = 0;
const int64 value = Eval(ct.arguments[1], evaluator);
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
@@ -264,49 +270,49 @@ int64 ComputeCount(const Constraint& ct,
}
bool CheckCountEq(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
return count == expected;
}
bool CheckCountGeq(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
return count >= expected;
}
bool CheckCountGt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
return count > expected;
}
bool CheckCountLeq(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
return count <= expected;
}
bool CheckCountLt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
return count < expected;
}
bool CheckCountNeq(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
return count != expected;
}
bool CheckCountReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = ComputeCount(ct, evaluator);
const int64 expected = Eval(ct.arguments[2], evaluator);
const int64 status = Eval(ct.arguments[3], evaluator);
@@ -314,7 +320,7 @@ bool CheckCountReif(const Constraint& ct,
}
bool CheckCumulative(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
// TODO(user): Improve complexity for large durations.
const int64 capacity = Eval(ct.arguments[3], evaluator);
const int size = Size(ct.arguments[0]);
@@ -336,42 +342,47 @@ bool CheckCumulative(const Constraint& ct,
}
bool CheckDiffn(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckDiffnK(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckDiffnNonStrict(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckDiffnNonStrict(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckDiffnNonStrictK(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckDiffnNonStrictK(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckDisjunctive(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckDisjunctiveStrict(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckDisjunctiveStrict(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckFalseConstraint(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckFalseConstraint(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
return false;
}
std::vector<int64> ComputeGlobalCardinalityCards(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
std::vector<int64> cards(Size(ct.arguments[1]), 0);
std::unordered_map<int64, int> positions;
for (int i = 0; i < ct.arguments[1].values.size(); ++i) {
@@ -388,8 +399,9 @@ std::vector<int64> ComputeGlobalCardinalityCards(
return cards;
}
bool CheckGlobalCardinality(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckGlobalCardinality(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const std::vector<int64> cards = ComputeGlobalCardinalityCards(ct, evaluator);
CHECK_EQ(cards.size(), Size(ct.arguments[2]));
for (int i = 0; i < Size(ct.arguments[2]); ++i) {
@@ -402,7 +414,8 @@ bool CheckGlobalCardinality(const Constraint& ct,
}
bool CheckGlobalCardinalityClosed(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const std::vector<int64> cards = ComputeGlobalCardinalityCards(ct, evaluator);
CHECK_EQ(cards.size(), Size(ct.arguments[2]));
for (int i = 0; i < Size(ct.arguments[2]); ++i) {
@@ -419,7 +432,8 @@ bool CheckGlobalCardinalityClosed(
}
bool CheckGlobalCardinalityLowUp(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const std::vector<int64> cards = ComputeGlobalCardinalityCards(ct, evaluator);
CHECK_EQ(cards.size(), ct.arguments[2].values.size());
CHECK_EQ(cards.size(), ct.arguments[3].values.size());
@@ -433,7 +447,8 @@ bool CheckGlobalCardinalityLowUp(
}
bool CheckGlobalCardinalityLowUpClosed(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const std::vector<int64> cards = ComputeGlobalCardinalityCards(ct, evaluator);
CHECK_EQ(cards.size(), ct.arguments[2].values.size());
CHECK_EQ(cards.size(), ct.arguments[3].values.size());
@@ -451,7 +466,8 @@ bool CheckGlobalCardinalityLowUpClosed(
}
bool CheckGlobalCardinalityOld(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int size = Size(ct.arguments[1]);
std::vector<int64> cards(size, 0);
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
@@ -470,14 +486,14 @@ bool CheckGlobalCardinalityOld(
}
bool CheckIntAbs(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return std::abs(left) == right;
}
bool CheckIntDiv(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 target = Eval(ct.arguments[2], evaluator);
@@ -485,14 +501,14 @@ bool CheckIntDiv(const Constraint& ct,
}
bool CheckIntEq(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left == right;
}
bool CheckIntEqReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -500,14 +516,14 @@ bool CheckIntEqReif(const Constraint& ct,
}
bool CheckIntGe(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left >= right;
}
bool CheckIntGeReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -515,14 +531,14 @@ bool CheckIntGeReif(const Constraint& ct,
}
bool CheckIntGt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left > right;
}
bool CheckIntGtReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -530,14 +546,14 @@ bool CheckIntGtReif(const Constraint& ct,
}
bool CheckIntLe(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left <= right;
}
bool CheckIntLeReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -545,14 +561,14 @@ bool CheckIntLeReif(const Constraint& ct,
}
bool CheckIntLt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left < right;
}
bool CheckIntLtReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -560,7 +576,7 @@ bool CheckIntLtReif(const Constraint& ct,
}
int64 ComputeIntLin(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 result = 0;
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
result += EvalAt(ct.arguments[0], i, evaluator) *
@@ -570,14 +586,15 @@ int64 ComputeIntLin(const Constraint& ct,
}
bool CheckIntLinEq(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
return left == right;
}
bool CheckIntLinEqReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckIntLinEqReif(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
const int64 status = Eval(ct.arguments[3], evaluator);
@@ -585,14 +602,15 @@ bool CheckIntLinEqReif(const Constraint& ct,
}
bool CheckIntLinGe(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
return left >= right;
}
bool CheckIntLinGeReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckIntLinGeReif(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
const int64 status = Eval(ct.arguments[3], evaluator);
@@ -600,14 +618,15 @@ bool CheckIntLinGeReif(const Constraint& ct,
}
bool CheckIntLinLe(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
return left <= right;
}
bool CheckIntLinLeReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckIntLinLeReif(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
const int64 status = Eval(ct.arguments[3], evaluator);
@@ -615,14 +634,15 @@ bool CheckIntLinLeReif(const Constraint& ct,
}
bool CheckIntLinNe(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
return left != right;
}
bool CheckIntLinNeReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckIntLinNeReif(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = ComputeIntLin(ct, evaluator);
const int64 right = Eval(ct.arguments[2], evaluator);
const int64 status = Eval(ct.arguments[3], evaluator);
@@ -630,7 +650,7 @@ bool CheckIntLinNeReif(const Constraint& ct,
}
bool CheckIntMax(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -638,7 +658,7 @@ bool CheckIntMax(const Constraint& ct,
}
bool CheckIntMin(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -646,7 +666,7 @@ bool CheckIntMin(const Constraint& ct,
}
bool CheckIntMinus(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 target = Eval(ct.arguments[2], evaluator);
@@ -654,7 +674,7 @@ bool CheckIntMinus(const Constraint& ct,
}
bool CheckIntMod(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 target = Eval(ct.arguments[2], evaluator);
@@ -662,14 +682,14 @@ bool CheckIntMod(const Constraint& ct,
}
bool CheckIntNe(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left != right;
}
bool CheckIntNeReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
@@ -677,14 +697,14 @@ bool CheckIntNeReif(const Constraint& ct,
}
bool CheckIntNegate(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
return left == -right;
}
bool CheckIntPlus(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 target = Eval(ct.arguments[2], evaluator);
@@ -692,7 +712,7 @@ bool CheckIntPlus(const Constraint& ct,
}
bool CheckIntTimes(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 left = Eval(ct.arguments[0], evaluator);
const int64 right = Eval(ct.arguments[1], evaluator);
const int64 target = Eval(ct.arguments[2], evaluator);
@@ -700,7 +720,7 @@ bool CheckIntTimes(const Constraint& ct,
}
bool CheckInverse(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
CHECK_EQ(Size(ct.arguments[0]), Size(ct.arguments[1]));
const int size = Size(ct.arguments[0]);
// Check all bounds.
@@ -724,7 +744,7 @@ bool CheckInverse(const Constraint& ct,
}
bool CheckLexLessInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
CHECK_EQ(Size(ct.arguments[0]), Size(ct.arguments[1]));
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
const int64 x = EvalAt(ct.arguments[0], i, evaluator);
@@ -740,8 +760,9 @@ bool CheckLexLessInt(const Constraint& ct,
return false;
}
bool CheckLexLesseqInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckLexLesseqInt(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
CHECK_EQ(Size(ct.arguments[0]), Size(ct.arguments[1]));
for (int i = 0; i < Size(ct.arguments[0]); ++i) {
const int64 x = EvalAt(ct.arguments[0], i, evaluator);
@@ -757,8 +778,9 @@ bool CheckLexLesseqInt(const Constraint& ct,
return true;
}
bool CheckMaximumArgInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckMaximumArgInt(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 max_index = Eval(ct.arguments[1], evaluator) - 1;
const int64 max_value = EvalAt(ct.arguments[0], max_index, evaluator);
// Checks that all value before max_index are < max_value.
@@ -778,7 +800,7 @@ bool CheckMaximumArgInt(const Constraint& ct,
}
bool CheckMaximumInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 max_value = kint64min;
for (int i = 0; i < Size(ct.arguments[1]); ++i) {
max_value = std::max(max_value, EvalAt(ct.arguments[1], i, evaluator));
@@ -786,8 +808,9 @@ bool CheckMaximumInt(const Constraint& ct,
return max_value == Eval(ct.arguments[0], evaluator);
}
bool CheckMinimumArgInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
bool CheckMinimumArgInt(
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 min_index = Eval(ct.arguments[1], evaluator) - 1;
const int64 min_value = EvalAt(ct.arguments[0], min_index, evaluator);
// Checks that all value before min_index are > min_value.
@@ -807,7 +830,7 @@ bool CheckMinimumArgInt(const Constraint& ct,
}
bool CheckMinimumInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
int64 min_value = kint64max;
for (int i = 0; i < Size(ct.arguments[1]); ++i) {
min_value = std::min(min_value, EvalAt(ct.arguments[1], i, evaluator));
@@ -816,7 +839,7 @@ bool CheckMinimumInt(const Constraint& ct,
}
bool CheckNvalue(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 count = Eval(ct.arguments[0], evaluator);
std::unordered_set<int64> all_values;
for (int i = 0; i < Size(ct.arguments[1]); ++i) {
@@ -827,36 +850,36 @@ bool CheckNvalue(const Constraint& ct,
}
bool CheckRegular(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckRegularNfa(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckSetIn(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 value = Eval(ct.arguments[0], evaluator);
return ct.arguments[1].Contains(value);
}
bool CheckSetNotIn(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 value = Eval(ct.arguments[0], evaluator);
return !ct.arguments[1].Contains(value);
}
bool CheckSetInReif(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 value = Eval(ct.arguments[0], evaluator);
const int64 status = Eval(ct.arguments[2], evaluator);
return status == ct.arguments[1].Contains(value);
}
bool CheckSlidingSum(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
const int64 low = Eval(ct.arguments[0], evaluator);
const int64 up = Eval(ct.arguments[1], evaluator);
const int64 length = Eval(ct.arguments[2], evaluator);
@@ -879,7 +902,7 @@ bool CheckSlidingSum(const Constraint& ct,
}
bool CheckSort(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
CHECK_EQ(Size(ct.arguments[0]), Size(ct.arguments[1]));
std::unordered_map<int64, int> init_count;
std::unordered_map<int64, int> sorted_count;
@@ -900,7 +923,7 @@ bool CheckSort(const Constraint& ct,
}
bool CheckSubCircuit(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
std::unordered_set<int64> visited;
// Find inactive nodes (pointing to themselves).
int64 current = -1;
@@ -929,12 +952,13 @@ bool CheckSubCircuit(const Constraint& ct,
}
bool CheckTableInt(const Constraint& ct,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
return true;
}
bool CheckSymmetricAllDifferent(
const Constraint& ct, std::function<int64(IntegerVariable*)> evaluator) {
const Constraint& ct,
const std::function<int64(IntegerVariable*)>& evaluator) {
const int size = Size(ct.arguments[0]);
for (int i = 0; i < size; ++i) {
const int64 value = EvalAt(ct.arguments[0], i, evaluator) - 1;
@@ -1073,7 +1097,7 @@ CallMap CreateCallMap() {
} // namespace
bool CheckSolution(const Model& model,
std::function<int64(IntegerVariable*)> evaluator) {
const std::function<int64(IntegerVariable*)>& evaluator) {
bool ok = true;
const CallMap call_map = CreateCallMap();
for (Constraint* ct : model.constraints()) {

View File

@@ -25,7 +25,7 @@ namespace fz {
// feasible solution of the given model. Returns true iff this is the
// case.
bool CheckSolution(const Model& model,
std::function<int64(IntegerVariable*)> evaluator);
const std::function<int64(IntegerVariable*)>& evaluator);
} // namespace fz
} // namespace operations_research

View File

@@ -153,8 +153,9 @@ bool OverlapsAt(const Argument& array, int pos, const Argument& other) {
// ----- Rule helpers -----
bool Presolver::ApplyRule(Constraint* ct, const std::string& rule_name,
std::function<bool(Constraint* ct, std::string*)> rule) {
bool Presolver::ApplyRule(
Constraint* ct, const std::string& rule_name,
const std::function<bool(Constraint* ct, std::string*)>& rule) {
const std::string before = HASVLOG ? ct->DebugString() : "";
std::string log;
const bool modified = rule(ct, &log);
@@ -3093,7 +3094,7 @@ CliqueResponse StoreClique(const std::vector<int>& vec, std::vector<int>* out) {
}
}
void PrintGraph(const std::vector<std::vector<bool>> neighbors,
void PrintGraph(const std::vector<std::vector<bool>>& neighbors,
int num_variables) {
for (int i = 0; i < num_variables; ++i) {
std::string out = StringPrintf("%i : [", i);

View File

@@ -168,7 +168,7 @@ class Presolver {
// This method wraps each rule, calls it and log its effect.
bool ApplyRule(Constraint* ct, const std::string& rule_name,
std::function<bool(Constraint* ct, std::string*)> rule);
const std::function<bool(Constraint* ct, std::string*)>& rule);
// The presolver will discover some equivalence classes of variables [two
// variable are equivalent when replacing one by the other leads to the same

View File

@@ -19,6 +19,7 @@
#include "flatzinc/checker.h"
#include "flatzinc/logging.h"
#include "sat/cp_constraints.h"
#include "sat/cumulative.h"
#include "sat/disjunctive.h"
#include "sat/integer.h"
#include "sat/integer_expr.h"
@@ -27,7 +28,6 @@
#include "sat/optimization.h"
#include "sat/sat_solver.h"
#include "sat/table.h"
#include "sat/timetabling.h"
#include "util/sorted_interval_list.h"
namespace operations_research {

View File

@@ -29,7 +29,7 @@ namespace fz {
// objects.
class SolverData {
public:
SolverData(const std::string& name) : solver_(name), sat_(nullptr) {}
explicit SolverData(const std::string& name) : solver_(name), sat_(nullptr) {}
// ----- Methods that deals with expressions and variables -----
IntExpr* GetOrCreateExpression(const Argument& argument);

View File

@@ -842,10 +842,10 @@ class SVector {
void grow(const T& left = T(), const T& right = T()) {
if (size_ == capacity_) {
// We have to copy the elements because they are allowed to be element
// of *this.
T left_copy(left);
T right_copy(right);
// We have to copy the elements because they are allowed to be element of
// *this.
T left_copy(left); // NOLINT
T right_copy(right); // NOLINT
reserve(NewCapacity(1));
new (base_ + size_) T(right_copy);
new (base_ - size_ - 1) T(left_copy);