dotnet: Remove reference to dotnet release command
- Currently not implemented... Add abseil patch - Add patches/absl-config.cmake Makefile: Add abseil-cpp on unix - Force abseil-cpp SHA1 to 45221cc note: Just before the PR #136 which break all CMake Makefile: Add abseil-cpp on windows - Force abseil-cpp SHA1 to 45221cc note: Just before the PR #136 which break all CMake CMake: Add abseil-cpp - Force abseil-cpp SHA1 to 45221cc note: Just before the PR #136 which break all CMake port to absl: C++ Part - Fix warning with the use of ABSL_MUST_USE_RESULT > The macro must appear as the very first part of a function declaration or definition: ... Note: past advice was to place the macro after the argument list. src: dependencies/sources/abseil-cpp-master/absl/base/attributes.h:418 - Rename enum after windows clash - Remove non compact table constraints - Change index type from int64 to int in routing library - Fix file_nonport compilation on windows - Fix another naming conflict with windows (NO_ERROR is a macro) - Cleanup hash containers; work on sat internals - Add optional_boolean sub-proto Sync cpp examples with internal code - reenable issue173 after reducing number of loops port to absl: Python Part - Add back cp_model.INT32_MIN|MAX for examples Update Python examples - Add random_tsp.py - Run words_square example - Run magic_square in python tests port to absl: Java Part - Fix compilation of the new routing parameters in java - Protect some code from SWIG parsing Update Java Examples port to absl: .Net Part Update .Net examples work on sat internals; Add C++ CP-SAT CpModelBuilder API; update sample code and recipes to use the new API; sync with internal code Remove VS 2015 in Appveyor-CI - abseil-cpp does not support VS 2015... improve tables upgrade C++ sat examples to use the new API; work on sat internals update license dates rewrite jobshop_ft06_distance.py to use the CP-SAT solver rename last example revert last commit more work on SAT internals fix
This commit is contained in:
@@ -19,15 +19,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_join.h"
|
||||
#include "ortools/base/integral_types.h"
|
||||
#include "ortools/base/join.h"
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/base/mathutil.h"
|
||||
#include "ortools/base/stringprintf.h"
|
||||
#include "ortools/constraint_solver/constraint_solver.h"
|
||||
#include "ortools/constraint_solver/constraint_solveri.h"
|
||||
|
||||
#include "ortools/base/join.h"
|
||||
#include "ortools/util/saturated_arithmetic.h"
|
||||
#include "ortools/util/string_array.h"
|
||||
|
||||
@@ -58,9 +56,9 @@ class TreeArrayConstraint : public CastConstraint {
|
||||
}
|
||||
|
||||
std::string DebugStringInternal(const std::string& name) const {
|
||||
return StringPrintf("%s(%s) == %s", name.c_str(),
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("%s(%s) == %s", name,
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void AcceptInternal(const std::string& name,
|
||||
@@ -395,9 +393,9 @@ class SmallSumConstraint : public Constraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("SmallSum(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("SmallSum(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -635,7 +633,7 @@ class SafeSumConstraint : public TreeArrayConstraint {
|
||||
|
||||
// ---------- Min Array ----------
|
||||
|
||||
// This constraint implements std::min(vars) == min_var.
|
||||
// This constraint implements min(vars) == min_var.
|
||||
class MinConstraint : public TreeArrayConstraint {
|
||||
public:
|
||||
MinConstraint(Solver* const solver, const std::vector<IntVar*>& vars,
|
||||
@@ -833,9 +831,9 @@ class SmallMinConstraint : public Constraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("SmallMin(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("SmallMin(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -916,7 +914,7 @@ class SmallMinConstraint : public Constraint {
|
||||
|
||||
// ---------- Max Array ----------
|
||||
|
||||
// This constraint implements std::max(vars) == max_var.
|
||||
// This constraint implements max(vars) == max_var.
|
||||
class MaxConstraint : public TreeArrayConstraint {
|
||||
public:
|
||||
MaxConstraint(Solver* const solver, const std::vector<IntVar*>& vars,
|
||||
@@ -1113,9 +1111,9 @@ class SmallMaxConstraint : public Constraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("SmallMax(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("SmallMax(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -1286,9 +1284,8 @@ class ArrayBoolAndEq : public CastConstraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("And(%s) == %s",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("And(%s) == %s", JoinDebugStringPtr(vars_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -1417,8 +1414,8 @@ class ArrayBoolOrEq : public CastConstraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("Or(%s) == %s", JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("Or(%s) == %s", JoinDebugStringPtr(vars_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -1467,8 +1464,7 @@ class BaseSumBooleanConstraint : public Constraint {
|
||||
|
||||
protected:
|
||||
std::string DebugStringInternal(const std::string& name) const {
|
||||
return StringPrintf("%s(%s)", name.c_str(),
|
||||
JoinDebugStringPtr(vars_, ", ").c_str());
|
||||
return absl::StrFormat("%s(%s)", name, JoinDebugStringPtr(vars_, ", "));
|
||||
}
|
||||
|
||||
const std::vector<IntVar*> vars_;
|
||||
@@ -1835,8 +1831,8 @@ class SumBooleanEqualToVar : public BaseSumBooleanConstraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("%s == %s", DebugStringInternal("SumBoolean").c_str(),
|
||||
sum_var_->DebugString().c_str());
|
||||
return absl::StrFormat("%s == %s", DebugStringInternal("SumBoolean"),
|
||||
sum_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -1989,9 +1985,9 @@ class BooleanScalProdLessConstant : public Constraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("BooleanScalProd([%s], [%s]) <= %" GG_LL_FORMAT "d)",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
absl::StrJoin(coefs_, ", ").c_str(), upper_bound_);
|
||||
return absl::StrFormat("BooleanScalProd([%s], [%s]) <= %" GG_LL_FORMAT "d)",
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
absl::StrJoin(coefs_, ", "), upper_bound_);
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -2110,10 +2106,10 @@ class PositiveBooleanScalProdEqVar : public CastConstraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("PositiveBooleanScal([%s], [%s]) == %s",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
absl::StrJoin(coefs_, ", ").c_str(),
|
||||
target_var_->DebugString().c_str());
|
||||
return absl::StrFormat("PositiveBooleanScal([%s], [%s]) == %s",
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
absl::StrJoin(coefs_, ", "),
|
||||
target_var_->DebugString());
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -2225,9 +2221,9 @@ class PositiveBooleanScalProd : public BaseIntExpr {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("PositiveBooleanScalProd([%s], [%s])",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
absl::StrJoin(coefs_, ", ").c_str());
|
||||
return absl::StrFormat("PositiveBooleanScalProd([%s], [%s])",
|
||||
JoinDebugStringPtr(vars_, ", "),
|
||||
absl::StrJoin(coefs_, ", "));
|
||||
}
|
||||
|
||||
void WhenRange(Demon* d) override {
|
||||
@@ -2355,10 +2351,10 @@ class PositiveBooleanScalProdEqCst : public Constraint {
|
||||
}
|
||||
|
||||
std::string DebugString() const override {
|
||||
return StringPrintf("PositiveBooleanScalProd([%s], [%s]) == %" GG_LL_FORMAT
|
||||
"d",
|
||||
JoinDebugStringPtr(vars_, ", ").c_str(),
|
||||
absl::StrJoin(coefs_, ", ").c_str(), constant_);
|
||||
return absl::StrFormat(
|
||||
"PositiveBooleanScalProd([%s], [%s]) == %" GG_LL_FORMAT "d",
|
||||
JoinDebugStringPtr(vars_, ", "), absl::StrJoin(coefs_, ", "),
|
||||
constant_);
|
||||
}
|
||||
|
||||
void Accept(ModelVisitor* const visitor) const override {
|
||||
@@ -2388,7 +2384,7 @@ class PositiveBooleanScalProdEqCst : public Constraint {
|
||||
class ExprLinearizer : public ModelParser {
|
||||
public:
|
||||
explicit ExprLinearizer(
|
||||
std::unordered_map<IntVar*, int64>* const variables_to_coefficients)
|
||||
absl::flat_hash_map<IntVar*, int64>* const variables_to_coefficients)
|
||||
: variables_to_coefficients_(variables_to_coefficients), constant_(0) {}
|
||||
|
||||
~ExprLinearizer() override {}
|
||||
@@ -2650,7 +2646,7 @@ class ExprLinearizer : public ModelParser {
|
||||
|
||||
// We do need a IntVar* as key, and not const IntVar*, because clients of this
|
||||
// class typically iterate over the map keys and use them as mutable IntVar*.
|
||||
std::unordered_map<IntVar*, int64>* const variables_to_coefficients_;
|
||||
absl::flat_hash_map<IntVar*, int64>* const variables_to_coefficients_;
|
||||
std::vector<int64> multipliers_;
|
||||
int64 constant_;
|
||||
};
|
||||
@@ -2688,7 +2684,7 @@ void DeepLinearize(Solver* const solver, const std::vector<IntVar*>& pre_vars,
|
||||
}
|
||||
if (need_linearization) {
|
||||
// Instrospect the variables to simplify the sum.
|
||||
std::unordered_map<IntVar*, int64> variables_to_coefficients;
|
||||
absl::flat_hash_map<IntVar*, int64> variables_to_coefficients;
|
||||
ExprLinearizer linearizer(&variables_to_coefficients);
|
||||
for (int i = 0; i < pre_vars.size(); ++i) {
|
||||
linearizer.Visit(pre_vars[i], pre_coefs[i]);
|
||||
@@ -3062,7 +3058,7 @@ IntExpr* MakeSumArrayAux(Solver* const solver, const std::vector<IntVar*>& vars,
|
||||
return solver->MakeSum(cache, constant);
|
||||
} else {
|
||||
const std::string name =
|
||||
StringPrintf("Sum([%s])", JoinNamePtr(vars, ", ").c_str());
|
||||
absl::StrFormat("Sum([%s])", JoinNamePtr(vars, ", "));
|
||||
IntVar* const sum_var = solver->MakeIntVar(new_min, new_max, name);
|
||||
if (AreAllBooleans(vars)) {
|
||||
solver->AddConstraint(
|
||||
@@ -3212,7 +3208,7 @@ IntExpr* MakeScalProdFct(Solver* solver, const std::vector<IntVar*>& pre_vars,
|
||||
}
|
||||
|
||||
IntExpr* MakeSumFct(Solver* solver, const std::vector<IntVar*>& pre_vars) {
|
||||
std::unordered_map<IntVar*, int64> variables_to_coefficients;
|
||||
absl::flat_hash_map<IntVar*, int64> variables_to_coefficients;
|
||||
ExprLinearizer linearizer(&variables_to_coefficients);
|
||||
for (int i = 0; i < pre_vars.size(); ++i) {
|
||||
linearizer.Visit(pre_vars[i], 1);
|
||||
@@ -3260,7 +3256,7 @@ IntExpr* Solver::MakeSum(const std::vector<IntVar*>& vars) {
|
||||
const bool all_booleans = AreAllBooleans(vars);
|
||||
if (all_booleans) {
|
||||
const std::string name =
|
||||
StringPrintf("BooleanSum([%s])", JoinNamePtr(vars, ", ").c_str());
|
||||
absl::StrFormat("BooleanSum([%s])", JoinNamePtr(vars, ", "));
|
||||
sum_expr = MakeIntVar(new_min, new_max, name);
|
||||
AddConstraint(
|
||||
RevAlloc(new SumBooleanEqualToVar(this, vars, sum_expr->Var())));
|
||||
@@ -3268,7 +3264,7 @@ IntExpr* Solver::MakeSum(const std::vector<IntVar*>& vars) {
|
||||
sum_expr = MakeSumFct(this, vars);
|
||||
} else {
|
||||
const std::string name =
|
||||
StringPrintf("Sum([%s])", JoinNamePtr(vars, ", ").c_str());
|
||||
absl::StrFormat("Sum([%s])", JoinNamePtr(vars, ", "));
|
||||
sum_expr = MakeIntVar(new_min, new_max, name);
|
||||
AddConstraint(
|
||||
RevAlloc(new SafeSumConstraint(this, vars, sum_expr->Var())));
|
||||
|
||||
Reference in New Issue
Block a user