From 123280f98e0ed1a4d4cebbc869b1f22340bdbd99 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Sat, 1 Dec 2018 15:07:47 +0100 Subject: [PATCH] revamp integral type, fix int64 to be int64_t; remove GG_LL_FORMAT macros --- ortools/base/integral_types.h | 42 +------ ortools/constraint_solver/alldiff_cst.cc | 4 +- ortools/constraint_solver/assignment.cc | 16 +-- .../constraint_solver/constraint_solver.cc | 8 +- ortools/constraint_solver/count_cst.cc | 2 +- ortools/constraint_solver/demon_profiler.cc | 13 +-- ortools/constraint_solver/element.cc | 10 +- ortools/constraint_solver/expr_array.cc | 4 +- ortools/constraint_solver/expr_cst.cc | 30 +++-- ortools/constraint_solver/expressions.cc | 109 +++++++++--------- ortools/constraint_solver/interval.cc | 29 ++--- ortools/constraint_solver/resource.cc | 6 +- ortools/constraint_solver/routing.cc | 4 +- ortools/constraint_solver/sched_search.cc | 9 +- ortools/constraint_solver/search.cc | 73 +++++------- ortools/constraint_solver/table.cc | 6 +- ortools/constraint_solver/timetabling.cc | 2 +- ortools/constraint_solver/tree_monitor.cc | 4 +- ortools/flatzinc/flatzinc_constraints.cc | 7 +- ortools/flatzinc/model.cc | 12 +- ortools/flatzinc/presolve.cc | 12 +- ortools/flatzinc/reporting.cc | 8 +- ortools/flatzinc/solver.cc | 26 ++--- ortools/sat/sat_solver.cc | 31 +++-- ortools/util/piecewise_linear_function.cc | 9 +- ortools/util/sorted_interval_list.cc | 4 +- ortools/util/stats.cc | 2 +- 27 files changed, 201 insertions(+), 281 deletions(-) diff --git a/ortools/base/integral_types.h b/ortools/base/integral_types.h index 4541cfd4051..11e97c33984 100644 --- a/ortools/base/integral_types.h +++ b/ortools/base/integral_types.h @@ -14,7 +14,7 @@ #ifndef OR_TOOLS_BASE_INTEGRAL_TYPES_H_ #define OR_TOOLS_BASE_INTEGRAL_TYPES_H_ -#include // NOLINT +#include // Detect 64 bit. #undef ARCH_K8 @@ -32,11 +32,7 @@ typedef signed char schar; typedef signed char int8; typedef short int16; // NOLINT typedef int int32; -#ifdef COMPILER_MSVC -typedef __int64 int64; // NOLINT -#else -typedef long long int64; // NOLINT -#endif /* COMPILER_MSVC */ +typedef int64_t int64; // NOTE: unsigned types are DANGEROUS in loops and other arithmetical // places. Use the signed types unless your variable represents a bit @@ -47,11 +43,7 @@ typedef long long int64; // NOLINT typedef unsigned char uint8; typedef unsigned short uint16; // NOLINT typedef unsigned int uint32; -#ifdef COMPILER_MSVC -typedef unsigned __int64 uint64; -#else -typedef unsigned long long uint64; // NOLINT -#endif /* COMPILER_MSVC */ +typedef uint64_t uint64; // A type to represent a Unicode code-point value. As of Unicode 4.0, // such values require up to 21 bits. @@ -78,25 +70,15 @@ typedef long sword_t; // NOLINT // and different size specifiers in format strings #undef GG_LONGLONG #undef GG_ULONGLONG -#undef GG_LL_FORMAT #ifdef COMPILER_MSVC /* if Visual C++ */ // VC++ long long suffixes #define GG_LONGLONG(x) x##I64 #define GG_ULONGLONG(x) x##UI64 - -// Length modifier in printf format std::string for int64's (e.g. within %d) -#define GG_LL_FORMAT "I64" // As in printf("%I64d", ...) -#define GG_LL_FORMAT_W L"I64" - #else /* not Visual C++ */ - #define GG_LONGLONG(x) x##LL #define GG_ULONGLONG(x) x##ULL -#define GG_LL_FORMAT "ll" // As in "%lld". Note that "q" is poor form also. -#define GG_LL_FORMAT_W L"ll" - #endif // COMPILER_MSVC static const uint8 kuint8max = static_cast(0xFF); @@ -115,22 +97,4 @@ static const int64 kint64min = static const int64 kint64max = static_cast(GG_LONGLONG(0x7FFFFFFFFFFFFFFF)); -#ifdef STLPORT -#include -// int64 output not present in STL port. -inline std::ostream& operator<<(std::ostream& os, int64 i) { - char buffer[20]; - snprintf(buffer, sizeof(buffer), "%lld", i); - os << buffer; - return os; -} - -inline std::ostream& operator<<(std::ostream& os, uint64 i) { - char buffer[20]; - snprintf(buffer, sizeof(buffer), "%llu", i); - os << buffer; - return os; -} -#endif // STLPORT - #endif // OR_TOOLS_BASE_INTEGRAL_TYPES_H_ diff --git a/ortools/constraint_solver/alldiff_cst.cc b/ortools/constraint_solver/alldiff_cst.cc index ffcac29b1dd..93675dbdeec 100644 --- a/ortools/constraint_solver/alldiff_cst.cc +++ b/ortools/constraint_solver/alldiff_cst.cc @@ -572,7 +572,7 @@ class AllDifferentExcept : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("AllDifferentExcept([%s], %" GG_LL_FORMAT "d", + return absl::StrFormat("AllDifferentExcept([%s], %d", JoinDebugStringPtr(vars_, ", "), escape_value_); } @@ -664,7 +664,7 @@ class NullIntersectArrayExcept : public Constraint { std::string DebugString() const override { return absl::StrFormat( - "NullIntersectArray([%s], [%s], escape = %" GG_LL_FORMAT "d", + "NullIntersectArray([%s], [%s], escape = %d", JoinDebugStringPtr(first_vars_, ", "), JoinDebugStringPtr(second_vars_, ", "), escape_value_); } diff --git a/ortools/constraint_solver/assignment.cc b/ortools/constraint_solver/assignment.cc index e1fad8ebf18..a86d9caf48e 100644 --- a/ortools/constraint_solver/assignment.cc +++ b/ortools/constraint_solver/assignment.cc @@ -96,9 +96,9 @@ void IntVarElement::WriteToProto( std::string IntVarElement::DebugString() const { if (Activated()) { if (min_ == max_) { - return absl::StrFormat("(%" GG_LL_FORMAT "d)", min_); + return absl::StrFormat("(%d)", min_); } else { - return absl::StrFormat("(%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d)", min_, + return absl::StrFormat("(%d..%d)", min_, max_); } } else { @@ -201,19 +201,19 @@ void IntervalVarElement::WriteToProto( std::string IntervalVarElement::DebugString() const { if (Activated()) { std::string out; - absl::StrAppendFormat(&out, "(start = %" GG_LL_FORMAT "d", start_min_); + absl::StrAppendFormat(&out, "(start = %d", start_min_); if (start_max_ != start_min_) { - absl::StrAppendFormat(&out, "..%" GG_LL_FORMAT "d", start_max_); + absl::StrAppendFormat(&out, "..%d", start_max_); } - absl::StrAppendFormat(&out, ", duration = %" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, ", duration = %d", duration_min_); if (duration_max_ != duration_min_) { - absl::StrAppendFormat(&out, "..%" GG_LL_FORMAT "d", duration_max_); + absl::StrAppendFormat(&out, "..%d", duration_max_); } - absl::StrAppendFormat(&out, ", status = %" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, ", status = %d", performed_min_); if (performed_max_ != performed_min_) { - absl::StrAppendFormat(&out, "..%" GG_LL_FORMAT "d", performed_max_); + absl::StrAppendFormat(&out, "..%d", performed_max_); } out.append(")"); return out; diff --git a/ortools/constraint_solver/constraint_solver.cc b/ortools/constraint_solver/constraint_solver.cc index 23b9cb3920e..8308c03384f 100644 --- a/ortools/constraint_solver/constraint_solver.cc +++ b/ortools/constraint_solver/constraint_solver.cc @@ -1462,11 +1462,9 @@ std::string Solver::DebugString() const { } absl::StrAppendFormat( &out, - ", branches = %" GG_LL_FORMAT "d, fails = %" GG_LL_FORMAT - "d, decisions = %" GG_LL_FORMAT "d, delayed demon runs = %" GG_LL_FORMAT - "d, var demon runs = %" GG_LL_FORMAT - "d, normal demon runs = %" GG_LL_FORMAT "d, Run time = %" GG_LL_FORMAT - "d ms)", + ", branches = %d, fails = %d, decisions = %d, " + "delayed demon runs = %d, var demon runs = %d, normal demon runs = %d, " + "Run time = %d ms)", branches_, fails_, decisions_, demon_runs_[DELAYED_PRIORITY], demon_runs_[VAR_PRIORITY], demon_runs_[NORMAL_PRIORITY], wall_time()); return out; diff --git a/ortools/constraint_solver/count_cst.cc b/ortools/constraint_solver/count_cst.cc index f95574dc1b9..156ed6aaef9 100644 --- a/ortools/constraint_solver/count_cst.cc +++ b/ortools/constraint_solver/count_cst.cc @@ -126,7 +126,7 @@ class AtMost : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("AtMost(%s, %" GG_LL_FORMAT "d, %" GG_LL_FORMAT "d)", + return absl::StrFormat("AtMost(%s, %d, %d)", JoinDebugStringPtr(vars_, ", "), value_, max_count_); } diff --git a/ortools/constraint_solver/demon_profiler.cc b/ortools/constraint_solver/demon_profiler.cc index 4f2a79fc93e..4cd589386f5 100644 --- a/ortools/constraint_solver/demon_profiler.cc +++ b/ortools/constraint_solver/demon_profiler.cc @@ -256,14 +256,13 @@ class DemonProfiler : public PropagationMonitor { // Exports collected data as human-readable text. void PrintOverview(Solver* const solver, const std::string& filename) { const char* const kConstraintFormat = - " - Constraint: %s\n failures=%" GG_LL_FORMAT - "d, initial propagation runtime=%" GG_LL_FORMAT - "d us, demons=%d, demon invocations=%" GG_LL_FORMAT - "d, total demon runtime=%" GG_LL_FORMAT "d us\n"; + " - Constraint: %s\n" + " failures=%d, initial propagation runtime=%d us, " + "demons=%d, demon invocations=%d, total demon runtime=%d us\n"; const char* const kDemonFormat = - " --- Demon: %s\n invocations=%" GG_LL_FORMAT - "d, failures=%" GG_LL_FORMAT "d, total runtime=%" GG_LL_FORMAT - "d us, [average=%.2lf, median=%.2lf, stddev=%.2lf]\n"; + " --- Demon: %s\n" + "invocations=%d, failures=%d, total runtime=%d us, " + "[average=%.2lf, median=%.2lf, stddev=%.2lf]\n"; File* file; const std::string model = absl::StrFormat("Model %s:\n", solver->model_name()); diff --git a/ortools/constraint_solver/element.cc b/ortools/constraint_solver/element.cc index 266bb8d1a93..5f921d85047 100644 --- a/ortools/constraint_solver/element.cc +++ b/ortools/constraint_solver/element.cc @@ -1323,7 +1323,7 @@ std::string StringifyEvaluatorBare(const Solver::Int64ToIntVar& evaluator, if (i != range_start) { out += ", "; } - out += absl::StrFormat("%" GG_LL_FORMAT "d -> %s", i, + out += absl::StrFormat("%d -> %s", i, evaluator(i)->DebugString()); } return out; @@ -1390,7 +1390,7 @@ std::string IntExprArrayElementCt::DebugString() const { int64 size = vars_.size(); if (size > 10) { return absl::StrFormat( - "IntExprArrayElement(var array of size %" GG_LL_FORMAT "d, %s) == %s", + "IntExprArrayElement(var array of size %d, %s) == %s", size, index_->DebugString(), target_var_->DebugString()); } else { return absl::StrFormat("IntExprArrayElement([%s], %s) == %s", @@ -1459,7 +1459,7 @@ class IntExprArrayElementCstCt : public Constraint { std::string DebugString() const override { return absl::StrFormat( - "IntExprArrayElement([%s], %s) == %" GG_LL_FORMAT "d", + "IntExprArrayElement([%s], %s) == %d", JoinDebugStringPtr(vars_, ", "), index_->DebugString(), target_); } @@ -1551,7 +1551,7 @@ class IntExprIndexOfCt : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("IntExprIndexOf([%s], %s) == %" GG_LL_FORMAT "d", + return absl::StrFormat("IntExprIndexOf([%s], %s) == %d", JoinDebugStringPtr(vars_, ", "), index_->DebugString(), target_); } @@ -1752,7 +1752,7 @@ IntExpr* Solver::MakeIndexExpression(const std::vector& vars, if (cache != nullptr) { return cache->Var(); } else { - const std::string name = absl::StrFormat("Index(%s, %" GG_LL_FORMAT "d)", + const std::string name = absl::StrFormat("Index(%s, %d)", JoinNamePtr(vars, ", "), value); IntVar* const index = MakeIntVar(0, vars.size() - 1, name); AddConstraint(MakeIndexOfConstraint(vars, index, value)); diff --git a/ortools/constraint_solver/expr_array.cc b/ortools/constraint_solver/expr_array.cc index fc9b6f80d0a..57040b89477 100644 --- a/ortools/constraint_solver/expr_array.cc +++ b/ortools/constraint_solver/expr_array.cc @@ -1985,7 +1985,7 @@ class BooleanScalProdLessConstant : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("BooleanScalProd([%s], [%s]) <= %" GG_LL_FORMAT "d)", + return absl::StrFormat("BooleanScalProd([%s], [%s]) <= %d)", JoinDebugStringPtr(vars_, ", "), absl::StrJoin(coefs_, ", "), upper_bound_); } @@ -2352,7 +2352,7 @@ class PositiveBooleanScalProdEqCst : public Constraint { std::string DebugString() const override { return absl::StrFormat( - "PositiveBooleanScalProd([%s], [%s]) == %" GG_LL_FORMAT "d", + "PositiveBooleanScalProd([%s], [%s]) == %d", JoinDebugStringPtr(vars_, ", "), absl::StrJoin(coefs_, ", "), constant_); } diff --git a/ortools/constraint_solver/expr_cst.cc b/ortools/constraint_solver/expr_cst.cc index aef0716391f..4add3cb7125 100644 --- a/ortools/constraint_solver/expr_cst.cc +++ b/ortools/constraint_solver/expr_cst.cc @@ -77,7 +77,7 @@ void EqualityExprCst::Post() { void EqualityExprCst::InitialPropagate() { expr_->SetValue(value_); } std::string EqualityExprCst::DebugString() const { - return absl::StrFormat("(%s == %" GG_LL_FORMAT "d)", expr_->DebugString(), + return absl::StrFormat("(%s == %d)", expr_->DebugString(), value_); } } // namespace @@ -162,7 +162,7 @@ void GreaterEqExprCst::InitialPropagate() { } std::string GreaterEqExprCst::DebugString() const { - return absl::StrFormat("(%s >= %" GG_LL_FORMAT "d)", expr_->DebugString(), + return absl::StrFormat("(%s >= %d)", expr_->DebugString(), value_); } } // namespace @@ -260,7 +260,7 @@ void LessEqExprCst::InitialPropagate() { } std::string LessEqExprCst::DebugString() const { - return absl::StrFormat("(%s <= %" GG_LL_FORMAT "d)", expr_->DebugString(), + return absl::StrFormat("(%s <= %d)", expr_->DebugString(), value_); } } // namespace @@ -367,7 +367,7 @@ void DiffCst::BoundPropagate() { } std::string DiffCst::DebugString() const { - return absl::StrFormat("(%s != %" GG_LL_FORMAT "d)", var_->DebugString(), + return absl::StrFormat("(%s != %d)", var_->DebugString(), value_); } } // namespace @@ -434,7 +434,7 @@ class IsEqualCstCt : public CastConstraint { } } std::string DebugString() const override { - return absl::StrFormat("IsEqualCstCt(%s, %" GG_LL_FORMAT "d, %s)", + return absl::StrFormat("IsEqualCstCt(%s, %d, %s)", var_->DebugString(), cst_, target_var_->DebugString()); } @@ -475,7 +475,7 @@ IntVar* Solver::MakeIsEqualCstVar(IntExpr* const var, int64 value) { return var->Var()->IsEqual(value); } else { IntVar* const boolvar = MakeBoolVar(absl::StrFormat( - "Is(%s == %" GG_LL_FORMAT "d)", var->DebugString(), value)); + "Is(%s == %d)", var->DebugString(), value)); AddConstraint(MakeIsEqualCstCt(var, value, boolvar)); return boolvar; } @@ -553,7 +553,7 @@ class IsDiffCstCt : public CastConstraint { } std::string DebugString() const override { - return absl::StrFormat("IsDiffCstCt(%s, %" GG_LL_FORMAT "d, %s)", + return absl::StrFormat("IsDiffCstCt(%s, %d, %s)", var_->DebugString(), cst_, target_var_->DebugString()); } @@ -652,7 +652,7 @@ class IsGreaterEqualCstCt : public CastConstraint { } } std::string DebugString() const override { - return absl::StrFormat("IsGreaterEqualCstCt(%s, %" GG_LL_FORMAT "d, %s)", + return absl::StrFormat("IsGreaterEqualCstCt(%s, %d, %s)", expr_->DebugString(), cst_, target_var_->DebugString()); } @@ -685,7 +685,7 @@ IntVar* Solver::MakeIsGreaterOrEqualCstVar(IntExpr* const var, int64 value) { return var->Var()->IsGreaterOrEqual(value); } else { IntVar* const boolvar = MakeBoolVar(absl::StrFormat( - "Is(%s >= %" GG_LL_FORMAT "d)", var->DebugString(), value)); + "Is(%s >= %d)", var->DebugString(), value)); AddConstraint(MakeIsGreaterOrEqualCstCt(var, value, boolvar)); return boolvar; } @@ -752,7 +752,7 @@ class IsLessEqualCstCt : public CastConstraint { } std::string DebugString() const override { - return absl::StrFormat("IsLessEqualCstCt(%s, %" GG_LL_FORMAT "d, %s)", + return absl::StrFormat("IsLessEqualCstCt(%s, %d, %s)", expr_->DebugString(), cst_, target_var_->DebugString()); } @@ -785,7 +785,7 @@ IntVar* Solver::MakeIsLessOrEqualCstVar(IntExpr* const var, int64 value) { return var->Var()->IsLessOrEqual(value); } else { IntVar* const boolvar = MakeBoolVar(absl::StrFormat( - "Is(%s <= %" GG_LL_FORMAT "d)", var->DebugString(), value)); + "Is(%s <= %d)", var->DebugString(), value)); AddConstraint(MakeIsLessOrEqualCstCt(var, value, boolvar)); return boolvar; } @@ -842,8 +842,7 @@ class BetweenCt : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("BetweenCt(%s, %" GG_LL_FORMAT "d, %" GG_LL_FORMAT - "d)", + return absl::StrFormat("BetweenCt(%s, %d, %d)", expr_->DebugString(), min_, max_); } @@ -891,8 +890,7 @@ class NotBetweenCt : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("NotBetweenCt(%s, %" GG_LL_FORMAT "d, %" GG_LL_FORMAT - "d)", + return absl::StrFormat("NotBetweenCt(%s, %d, %d)", expr_->DebugString(), min_, max_); } @@ -1025,7 +1023,7 @@ class IsBetweenCt : public Constraint { std::string DebugString() const override { return absl::StrFormat( - "IsBetweenCt(%s, %" GG_LL_FORMAT "d, %" GG_LL_FORMAT "d, %s)", + "IsBetweenCt(%s, %d, %d, %s)", expr_->DebugString(), min_, max_, boolvar_->DebugString()); } diff --git a/ortools/constraint_solver/expressions.cc b/ortools/constraint_solver/expressions.cc index a84507462ea..b62b4feb80e 100644 --- a/ortools/constraint_solver/expressions.cc +++ b/ortools/constraint_solver/expressions.cc @@ -451,7 +451,7 @@ class DomainIntVar : public IntVar { ? variable_->name() : variable_->DebugString(); const std::string bname = - absl::StrFormat("Watch<%s == %" GG_LL_FORMAT "d>", vname, value); + absl::StrFormat("Watch<%s == %d>", vname, value); IntVar* const boolvar = solver()->MakeBoolVar(bname); watchers_.UnsafeRevInsert(value, boolvar); if (posted_.Switched()) { @@ -685,7 +685,7 @@ class DomainIntVar : public IntVar { ? variable_->name() : variable_->DebugString(); const std::string bname = - absl::StrFormat("Watch<%s == %" GG_LL_FORMAT "d>", vname, value); + absl::StrFormat("Watch<%s == %d>", vname, value); IntVar* const boolvar = solver()->MakeBoolVar(bname); RevInsert(index, boolvar); if (posted_.Switched()) { @@ -940,7 +940,7 @@ class DomainIntVar : public IntVar { ? variable_->name() : variable_->DebugString(); const std::string bname = - absl::StrFormat("Watch<%s >= %" GG_LL_FORMAT "d>", vname, value); + absl::StrFormat("Watch<%s >= %d>", vname, value); IntVar* const boolvar = solver()->MakeBoolVar(bname); watchers_.UnsafeRevInsert(value, boolvar); if (posted_.Switched()) { @@ -1180,7 +1180,7 @@ class DomainIntVar : public IntVar { ? variable_->name() : variable_->DebugString(); const std::string bname = - absl::StrFormat("Watch<%s >= %" GG_LL_FORMAT "d>", vname, value); + absl::StrFormat("Watch<%s >= %d>", vname, value); IntVar* const boolvar = solver()->MakeBoolVar(bname); RevInsert(value - offset_, boolvar); if (posted_.Switched()) { @@ -1726,7 +1726,7 @@ class SimpleBitSet : public DomainIntVar::BitSet { std::string DebugString() const override { std::string out; absl::StrAppendFormat( - &out, "SimpleBitSet(%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d : ", omin_, + &out, "SimpleBitSet(%d..%d : ", omin_, omax_); for (int i = 0; i < bsize_; ++i) { absl::StrAppendFormat(&out, "%x", bits_[i]); @@ -1763,14 +1763,14 @@ class SimpleBitSet : public DomainIntVar::BitSet { } else { if (cumul) { if (v == start_cumul + 1) { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d ", start_cumul); + absl::StrAppendFormat(&out, "%d ", start_cumul); } else if (v == start_cumul + 2) { absl::StrAppendFormat(&out, - "%" GG_LL_FORMAT "d %" GG_LL_FORMAT "d ", + "%d %d ", start_cumul, v - 1); } else { absl::StrAppendFormat(&out, - "%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d ", + "%d..%d ", start_cumul, v - 1); } cumul = false; @@ -1779,17 +1779,17 @@ class SimpleBitSet : public DomainIntVar::BitSet { } if (cumul) { if (max == start_cumul + 1) { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d %" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, "%d %d", start_cumul, max); } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, "%d..%d", start_cumul, max); } } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d", max); + absl::StrAppendFormat(&out, "%d", max); } } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d", min); + absl::StrAppendFormat(&out, "%d", min); } return out; } @@ -1943,8 +1943,7 @@ class SmallBitSet : public DomainIntVar::BitSet { uint64 Size() const override { return size_.Value(); } std::string DebugString() const override { - return absl::StrFormat("SmallBitSet(%" GG_LL_FORMAT "d..%" GG_LL_FORMAT - "d : %llx)", + return absl::StrFormat("SmallBitSet(%d..%d : %llx)", omin_, omax_, bits_); } @@ -1980,14 +1979,14 @@ class SmallBitSet : public DomainIntVar::BitSet { } else { if (cumul) { if (v == start_cumul + 1) { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d ", start_cumul); + absl::StrAppendFormat(&out, "%d ", start_cumul); } else if (v == start_cumul + 2) { absl::StrAppendFormat(&out, - "%" GG_LL_FORMAT "d %" GG_LL_FORMAT "d ", + "%d %d ", start_cumul, v - 1); } else { absl::StrAppendFormat(&out, - "%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d ", + "%d..%d ", start_cumul, v - 1); } cumul = false; @@ -1996,17 +1995,17 @@ class SmallBitSet : public DomainIntVar::BitSet { } if (cumul) { if (max == start_cumul + 1) { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d %" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, "%d %d", start_cumul, max); } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, "%d..%d", start_cumul, max); } } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d", max); + absl::StrAppendFormat(&out, "%d", max); } } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d", min); + absl::StrAppendFormat(&out, "%d", min); } return out; } @@ -2493,11 +2492,11 @@ std::string DomainIntVar::DebugString() const { out = "DomainIntVar("; } if (min_.Value() == max_.Value()) { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d", min_.Value()); + absl::StrAppendFormat(&out, "%d", min_.Value()); } else if (bits_ != nullptr) { out.append(bits_->pretty_DebugString(min_.Value(), max_.Value())); } else { - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d", + absl::StrAppendFormat(&out, "%d..%d", min_.Value(), max_.Value()); } out += ")"; @@ -2624,9 +2623,9 @@ class IntConst : public IntVar { std::string out; if (solver()->HasName(this)) { const std::string& var_name = name(); - absl::StrAppendFormat(&out, "%s(%" GG_LL_FORMAT "d)", var_name, value_); + absl::StrAppendFormat(&out, "%s(%d)", var_name, value_); } else { - absl::StrAppendFormat(&out, "IntConst(%" GG_LL_FORMAT "d)", value_); + absl::StrAppendFormat(&out, "IntConst(%d)", value_); } return out; } @@ -2690,10 +2689,10 @@ class PlusCstVar : public IntVar { std::string DebugString() const override { if (HasName()) { - return absl::StrFormat("%s(%s + %" GG_LL_FORMAT "d)", name(), + return absl::StrFormat("%s(%s + %d)", name(), var_->DebugString(), cst_); } else { - return absl::StrFormat("(%s + %" GG_LL_FORMAT "d)", var_->DebugString(), + return absl::StrFormat("(%s + %d)", var_->DebugString(), cst_); } } @@ -3005,7 +3004,7 @@ std::string SubCstIntVar::DebugString() const { if (cst_ == 1 && var_->VarType() == BOOLEAN_VAR) { return absl::StrFormat("Not(%s)", var_->DebugString()); } else { - return absl::StrFormat("(%" GG_LL_FORMAT "d - %s)", cst_, + return absl::StrFormat("(%d - %s)", cst_, var_->DebugString()); } } @@ -3016,7 +3015,7 @@ std::string SubCstIntVar::name() const { } else if (cst_ == 1 && var_->VarType() == BOOLEAN_VAR) { return absl::StrFormat("Not(%s)", var_->name()); } else { - return absl::StrFormat("(%" GG_LL_FORMAT "d - %s)", cst_, var_->name()); + return absl::StrFormat("(%d - %s)", cst_, var_->name()); } } @@ -3182,7 +3181,7 @@ class TimesCstIntVar : public IntVar { } std::string DebugString() const override { - return absl::StrFormat("(%s * %" GG_LL_FORMAT "d)", var_->DebugString(), + return absl::StrFormat("(%s * %d)", var_->DebugString(), cst_); } @@ -3745,10 +3744,10 @@ class PlusIntCstExpr : public BaseIntExpr { void SetMax(int64 m) override { expr_->SetMax(CapSub(m, value_)); } bool Bound() const override { return (expr_->Bound()); } std::string name() const override { - return absl::StrFormat("(%s + %" GG_LL_FORMAT "d)", expr_->name(), value_); + return absl::StrFormat("(%s + %d)", expr_->name(), value_); } std::string DebugString() const override { - return absl::StrFormat("(%s + %" GG_LL_FORMAT "d)", expr_->DebugString(), + return absl::StrFormat("(%s + %d)", expr_->DebugString(), value_); } void WhenRange(Demon* d) override { expr_->WhenRange(d); } @@ -3919,10 +3918,10 @@ class SubIntCstExpr : public BaseIntExpr { void SetMax(int64 m) override { expr_->SetMin(CapSub(value_, m)); } bool Bound() const override { return (expr_->Bound()); } std::string name() const override { - return absl::StrFormat("(%" GG_LL_FORMAT "d - %s)", value_, expr_->name()); + return absl::StrFormat("(%d - %s)", value_, expr_->name()); } std::string DebugString() const override { - return absl::StrFormat("(%" GG_LL_FORMAT "d - %s)", value_, + return absl::StrFormat("(%d - %s)", value_, expr_->DebugString()); } void WhenRange(Demon* d) override { expr_->WhenRange(d); } @@ -4002,11 +4001,11 @@ class TimesIntCstExpr : public BaseIntExpr { bool Bound() const override { return (expr_->Bound()); } std::string name() const override { - return absl::StrFormat("(%s * %" GG_LL_FORMAT "d)", expr_->name(), value_); + return absl::StrFormat("(%s * %d)", expr_->name(), value_); } std::string DebugString() const override { - return absl::StrFormat("(%s * %" GG_LL_FORMAT "d)", expr_->DebugString(), + return absl::StrFormat("(%s * %d)", expr_->DebugString(), value_); } @@ -4738,12 +4737,12 @@ class DivPosIntCstExpr : public BaseIntExpr { } std::string name() const override { - return absl::StrFormat("(%s div %" GG_LL_FORMAT "d)", expr_->name(), + return absl::StrFormat("(%s div %d)", expr_->name(), value_); } std::string DebugString() const override { - return absl::StrFormat("(%s div %" GG_LL_FORMAT "d)", expr_->DebugString(), + return absl::StrFormat("(%s div %d)", expr_->DebugString(), value_); } @@ -5387,12 +5386,12 @@ class BasePower : public BaseIntExpr { void WhenRange(Demon* d) override { expr_->WhenRange(d); } std::string name() const override { - return absl::StrFormat("IntPower(%s, %" GG_LL_FORMAT "d)", expr_->name(), + return absl::StrFormat("IntPower(%s, %d)", expr_->name(), pow_); } std::string DebugString() const override { - return absl::StrFormat("IntPower(%s, %" GG_LL_FORMAT "d)", + return absl::StrFormat("IntPower(%s, %d)", expr_->DebugString(), pow_); } @@ -5660,12 +5659,12 @@ class MinCstIntExpr : public BaseIntExpr { } std::string name() const override { - return absl::StrFormat("MinCstIntExpr(%s, %" GG_LL_FORMAT "d)", + return absl::StrFormat("MinCstIntExpr(%s, %d)", expr_->name(), value_); } std::string DebugString() const override { - return absl::StrFormat("MinCstIntExpr(%s, %" GG_LL_FORMAT "d)", + return absl::StrFormat("MinCstIntExpr(%s, %d)", expr_->DebugString(), value_); } @@ -5770,12 +5769,12 @@ class MaxCstIntExpr : public BaseIntExpr { } std::string name() const override { - return absl::StrFormat("MaxCstIntExpr(%s, %" GG_LL_FORMAT "d)", + return absl::StrFormat("MaxCstIntExpr(%s, %d)", expr_->name(), value_); } std::string DebugString() const override { - return absl::StrFormat("MaxCstIntExpr(%s, %" GG_LL_FORMAT "d)", + return absl::StrFormat("MaxCstIntExpr(%s, %d)", expr_->DebugString(), value_); } @@ -5884,15 +5883,13 @@ class SimpleConvexPiecewiseExpr : public BaseIntExpr { std::string name() const override { return absl::StrFormat( - "ConvexPiecewiseExpr(%s, ec = %" GG_LL_FORMAT "d, ed = %" GG_LL_FORMAT - "d, ld = %" GG_LL_FORMAT "d, lc = %" GG_LL_FORMAT "d)", + "ConvexPiecewiseExpr(%s, ec = %d, ed = %d, ld = %d, lc = %d)", expr_->name(), early_cost_, early_date_, late_date_, late_cost_); } std::string DebugString() const override { return absl::StrFormat( - "ConvexPiecewiseExpr(%s, ec = %" GG_LL_FORMAT "d, ed = %" GG_LL_FORMAT - "d, ld = %" GG_LL_FORMAT "d, lc = %" GG_LL_FORMAT "d)", + "ConvexPiecewiseExpr(%s, ec = %d, ed = %d, ld = %d, lc = %d)", expr_->DebugString(), early_cost_, early_date_, late_date_, late_cost_); } @@ -5969,14 +5966,12 @@ class SemiContinuousExpr : public BaseIntExpr { } std::string name() const override { - return absl::StrFormat("SemiContinuous(%s, fixed_charge = %" GG_LL_FORMAT - "d, step = %" GG_LL_FORMAT "d)", + return absl::StrFormat("SemiContinuous(%s, fixed_charge = %d, step = %d)", expr_->name(), fixed_charge_, step_); } std::string DebugString() const override { - return absl::StrFormat("SemiContinuous(%s, fixed_charge = %" GG_LL_FORMAT - "d, step = %" GG_LL_FORMAT "d)", + return absl::StrFormat("SemiContinuous(%s, fixed_charge = %d, step = %d)", expr_->DebugString(), fixed_charge_, step_); } @@ -6041,13 +6036,13 @@ class SemiContinuousStepOneExpr : public BaseIntExpr { std::string name() const override { return absl::StrFormat( - "SemiContinuousStepOne(%s, fixed_charge = %" GG_LL_FORMAT "d)", + "SemiContinuousStepOne(%s, fixed_charge = %d)", expr_->name(), fixed_charge_); } std::string DebugString() const override { return absl::StrFormat( - "SemiContinuousStepOne(%s, fixed_charge = %" GG_LL_FORMAT "d)", + "SemiContinuousStepOne(%s, fixed_charge = %d)", expr_->DebugString(), fixed_charge_); } @@ -6109,13 +6104,13 @@ class SemiContinuousStepZeroExpr : public BaseIntExpr { std::string name() const override { return absl::StrFormat( - "SemiContinuousStepZero(%s, fixed_charge = %" GG_LL_FORMAT "d)", + "SemiContinuousStepZero(%s, fixed_charge = %d)", expr_->name(), fixed_charge_); } std::string DebugString() const override { return absl::StrFormat( - "SemiContinuousStepZero(%s, fixed_charge = %" GG_LL_FORMAT "d)", + "SemiContinuousStepZero(%s, fixed_charge = %d)", expr_->DebugString(), fixed_charge_); } @@ -6263,7 +6258,7 @@ class ExprWithEscapeValue : public BaseIntExpr { } std::string DebugString() const override { - return absl::StrFormat("ConditionExpr(%s, %s, %" GG_LL_FORMAT "d)", + return absl::StrFormat("ConditionExpr(%s, %s, %d)", condition_->DebugString(), expression_->DebugString(), unperformed_value_); } diff --git a/ortools/constraint_solver/interval.cc b/ortools/constraint_solver/interval.cc index c47f34948ee..f3151cdfc4d 100644 --- a/ortools/constraint_solver/interval.cc +++ b/ortools/constraint_solver/interval.cc @@ -605,7 +605,7 @@ class RangeVar : public IntExpr { std::string DebugString() const override { std::string out = absl::StrCat(min_.Value()); if (!Bound()) { - absl::StrAppendFormat(&out, " .. %" GG_LL_FORMAT "d", max_.Value()); + absl::StrAppendFormat(&out, " .. %d", max_.Value()); } return out; } @@ -964,7 +964,7 @@ std::string FixedDurationIntervalVar::DebugString() const { out = "IntervalVar(start = "; } absl::StrAppendFormat( - &out, "%s, duration = %" GG_LL_FORMAT "d, performed = %s)", + &out, "%s, duration = %d, performed = %s)", start_.DebugString(), duration_, performed_.DebugString()); return out; } @@ -1158,7 +1158,7 @@ std::string FixedDurationPerformedIntervalVar::DebugString() const { out = "IntervalVar(start = "; } absl::StrAppendFormat(&out, - "%s, duration = %" GG_LL_FORMAT "d, performed = true)", + "%s, duration = %d, performed = true)", start_.DebugString(), duration_); return out; } @@ -1315,13 +1315,13 @@ std::string StartVarPerformedIntervalVar::DebugString() const { } else { out = "IntervalVar(start = "; } - absl::StrAppendFormat(&out, "%" GG_LL_FORMAT "d", start_var_->Min()); + absl::StrAppendFormat(&out, "%d", start_var_->Min()); if (!start_var_->Bound()) { - absl::StrAppendFormat(&out, " .. %" GG_LL_FORMAT "d", start_var_->Max()); + absl::StrAppendFormat(&out, " .. %d", start_var_->Max()); } absl::StrAppendFormat( - &out, ", duration = %" GG_LL_FORMAT "d, performed = true)", duration_); + &out, ", duration = %d, performed = true)", duration_); return out; } @@ -1553,7 +1553,7 @@ std::string StartVarIntervalVar::DebugString() const { out = "IntervalVar(start = "; } absl::StrAppendFormat( - &out, "%s, duration = %" GG_LL_FORMAT "d, performed = %s)", + &out, "%s, duration = %d, performed = %s)", start_->DebugString(), duration_, performed_->DebugString()); return out; } @@ -1737,8 +1737,7 @@ std::string FixedInterval::DebugString() const { out = "IntervalVar(start = "; } absl::StrAppendFormat(&out, - "%" GG_LL_FORMAT "d, duration = %" GG_LL_FORMAT - "d, performed = true)", + "%d, duration = %d, performed = true)", start_, duration_); return out; } @@ -2093,8 +2092,7 @@ class FixedDurationIntervalVarStartSyncedOnStart : FixedDurationSyncedIntervalVar( t, duration, offset, absl::StrFormat( - "IntervalStartSyncedOnStart(%s, duration = %" GG_LL_FORMAT - "d, offset = %" GG_LL_FORMAT "d)", + "IntervalStartSyncedOnStart(%s, duration = %d, offset = %d)", t->name(), duration, offset)) {} ~FixedDurationIntervalVarStartSyncedOnStart() override {} int64 StartMin() const override { return CapAdd(t_->StartMin(), offset_); } @@ -2138,8 +2136,7 @@ class FixedDurationIntervalVarStartSyncedOnStart } std::string DebugString() const override { return absl::StrFormat( - "IntervalStartSyncedOnStart(%s, duration = %" GG_LL_FORMAT - "d, offset = %" GG_LL_FORMAT "d)", + "IntervalStartSyncedOnStart(%s, duration = %d, offset = %d)", t_->DebugString(), duration_, offset_); } }; @@ -2154,8 +2151,7 @@ class FixedDurationIntervalVarStartSyncedOnEnd : FixedDurationSyncedIntervalVar( t, duration, offset, absl::StrFormat( - "IntervalStartSyncedOnEnd(%s, duration = %" GG_LL_FORMAT - "d, offset = %" GG_LL_FORMAT "d)", + "IntervalStartSyncedOnEnd(%s, duration = %d, offset = %d)", t->name(), duration, offset)) {} ~FixedDurationIntervalVarStartSyncedOnEnd() override {} int64 StartMin() const override { return CapAdd(t_->EndMin(), offset_); } @@ -2200,8 +2196,7 @@ class FixedDurationIntervalVarStartSyncedOnEnd } std::string DebugString() const override { return absl::StrFormat( - "IntervalStartSyncedOnEnd(%s, duration = %" GG_LL_FORMAT - "d, offset = %" GG_LL_FORMAT "d)", + "IntervalStartSyncedOnEnd(%s, duration = %d, offset = %d)", t_->DebugString(), duration_, offset_); } }; diff --git a/ortools/constraint_solver/resource.cc b/ortools/constraint_solver/resource.cc index 142cb05d76d..79afcfb9269 100644 --- a/ortools/constraint_solver/resource.cc +++ b/ortools/constraint_solver/resource.cc @@ -115,7 +115,7 @@ struct CumulativeTask { void WhenAnything(Demon* const demon) { interval->WhenAnything(demon); } std::string DebugString() const { - return absl::StrFormat("Task{ %s, demand: %" GG_LL_FORMAT "d }", + return absl::StrFormat("Task{ %s, demand: %d }", interval->DebugString(), demand); } @@ -1137,7 +1137,7 @@ class FullDisjunctiveConstraint : public DisjunctiveConstraint { const int64 duration_min = var->DurationMin(); time_slacks_[i + 1] = s->MakeIntVar( duration_min, horizon, - absl::StrFormat("time_slacks(%" GG_LL_FORMAT "d)", i + 1)); + absl::StrFormat("time_slacks(%d)", i + 1)); // TODO(user): Check SafeStartExpr(); time_cumuls_[i + 1] = var->SafeStartExpr(var->StartMin())->Var(); if (var->DurationMax() != duration_min) { @@ -1147,7 +1147,7 @@ class FullDisjunctiveConstraint : public DisjunctiveConstraint { } else { time_slacks_[i + 1] = s->MakeIntVar( 0, horizon, - absl::StrFormat("time_slacks(%" GG_LL_FORMAT "d)", i + 1)); + absl::StrFormat("time_slacks(%d)", i + 1)); time_cumuls_[i + 1] = s->MakeIntConst(horizon); } } diff --git a/ortools/constraint_solver/routing.cc b/ortools/constraint_solver/routing.cc index c042f057452..4424d959c75 100644 --- a/ortools/constraint_solver/routing.cc +++ b/ortools/constraint_solver/routing.cc @@ -3664,13 +3664,13 @@ std::string RoutingModel::DebugOutputAssignment( for (;;) { const IntVar* vehicle_var = VehicleVar(index); absl::StrAppendFormat(&output, - "%" GG_LL_FORMAT "d Vehicle(%" GG_LL_FORMAT "d) ", + "%d Vehicle(%d) ", index, solution_assignment.Value(vehicle_var)); for (const RoutingDimension* const dimension : dimensions_) { if (gtl::ContainsKey(dimension_names, dimension->name())) { const IntVar* const var = dimension->CumulVar(index); absl::StrAppendFormat( - &output, "%s(%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d) ", + &output, "%s(%d..%d) ", dimension->name(), solution_assignment.Min(var), solution_assignment.Max(var)); } diff --git a/ortools/constraint_solver/sched_search.cc b/ortools/constraint_solver/sched_search.cc index 20fcdf267c2..414553e4f43 100644 --- a/ortools/constraint_solver/sched_search.cc +++ b/ortools/constraint_solver/sched_search.cc @@ -61,9 +61,8 @@ std::string SequenceVar::DebugString() const { int ranked = 0; int not_ranked = 0; ComputeStatistics(&ranked, ¬_ranked, &unperformed); - return absl::StrFormat("%s(horizon = %" GG_LL_FORMAT "d..%" GG_LL_FORMAT - "d, duration = %" GG_LL_FORMAT "d..%" GG_LL_FORMAT - "d, not ranked = %d, ranked = %d, nexts = [%s])", + return absl::StrFormat("%s(horizon = %d..%d, duration = %d..%d, " + "not ranked = %d, ranked = %d, nexts = [%s])", name(), hmin, hmax, dmin, dmax, not_ranked, ranked, JoinDebugStringPtr(nexts_, ", ")); } @@ -408,7 +407,7 @@ class ScheduleOrPostpone : public Decision { } std::string DebugString() const override { - return absl::StrFormat("ScheduleOrPostpone(%s at %" GG_LL_FORMAT "d)", + return absl::StrFormat("ScheduleOrPostpone(%s at %d)", var_->DebugString(), est_.Value()); } @@ -518,7 +517,7 @@ class ScheduleOrExpedite : public Decision { } std::string DebugString() const override { - return absl::StrFormat("ScheduleOrExpedite(%s at %" GG_LL_FORMAT "d)", + return absl::StrFormat("ScheduleOrExpedite(%s at %d)", var_->DebugString(), est_.Value()); } diff --git a/ortools/constraint_solver/search.cc b/ortools/constraint_solver/search.cc index 26ba10af492..bb544279a98 100644 --- a/ortools/constraint_solver/search.cc +++ b/ortools/constraint_solver/search.cc @@ -91,9 +91,8 @@ void SearchLog::ExitSearch() { ms = 1; } const std::string buffer = absl::StrFormat( - "End search (time = %" GG_LL_FORMAT "d ms, branches = %" GG_LL_FORMAT - "d, failures = %" GG_LL_FORMAT "d, %s, speed = %" GG_LL_FORMAT - "d branches/s)", + "End search (time = %d ms, branches = %d, failures = %d, %s, " + "speed = %d branches/s)", ms, branches, solver()->failures(), MemoryUsage(), branches * 1000 / ms); OutputLine(buffer); } @@ -110,29 +109,27 @@ bool SearchLog::AtSolution() { objective_updated = true; } else if (var_ != nullptr) { current = var_->Value(); - absl::StrAppendFormat(&obj_str, "%" GG_LL_FORMAT "d, ", current); + absl::StrAppendFormat(&obj_str, "%d, ", current); objective_updated = true; } if (objective_updated) { if (current >= objective_min_) { absl::StrAppendFormat( - &obj_str, "objective minimum = %" GG_LL_FORMAT "d, ", objective_min_); + &obj_str, "objective minimum = %d, ", objective_min_); } else { objective_min_ = current; } if (current <= objective_max_) { absl::StrAppendFormat( - &obj_str, "objective maximum = %" GG_LL_FORMAT "d, ", objective_max_); + &obj_str, "objective maximum = %d, ", objective_max_); } else { objective_max_ = current; } } std::string log; absl::StrAppendFormat(&log, - "Solution #%d (%stime = %" GG_LL_FORMAT - "d ms, branches = %" GG_LL_FORMAT - "d," - " failures = %" GG_LL_FORMAT "d, depth = %d", + "Solution #%d (%stime = %d ms, branches = %d," + " failures = %d, depth = %d", nsol_++, obj_str, timer_->GetInMs(), solver()->branches(), solver()->failures(), depth); if (!solver()->SearchContext().empty()) { @@ -140,10 +137,8 @@ bool SearchLog::AtSolution() { } if (solver()->neighbors() != 0) { absl::StrAppendFormat(&log, - ", neighbors = %" GG_LL_FORMAT - "d, filtered neighbors = %" GG_LL_FORMAT - "d," - " accepted neighbors = %" GG_LL_FORMAT "d", + ", neighbors = %d, filtered neighbors = %d," + " accepted neighbors = %d", solver()->neighbors(), solver()->filtered_neighbors(), solver()->accepted_neighbors()); } @@ -164,17 +159,13 @@ void SearchLog::BeginFail() { Maintain(); } void SearchLog::NoMoreSolutions() { std::string buffer = absl::StrFormat( - "Finished search tree (time = %" GG_LL_FORMAT - "d ms, branches = %" GG_LL_FORMAT - "d," - " failures = %" GG_LL_FORMAT "d", + "Finished search tree (time = %d ms, branches = %d," + " failures = %d", timer_->GetInMs(), solver()->branches(), solver()->failures()); if (solver()->neighbors() != 0) { absl::StrAppendFormat(&buffer, - ", neighbors = %" GG_LL_FORMAT - "d, filtered neighbors = %" GG_LL_FORMAT - "d," - " accepted neigbors = %" GG_LL_FORMAT "d", + ", neighbors = %d, filtered neighbors = %d," + " accepted neigbors = %d", solver()->neighbors(), solver()->filtered_neighbors(), solver()->accepted_neighbors()); } @@ -197,8 +188,7 @@ void SearchLog::RefuteDecision(Decision* const decision) { void SearchLog::OutputDecision() { std::string buffer = absl::StrFormat( - "%" GG_LL_FORMAT "d branches, %" GG_LL_FORMAT "d ms, %" GG_LL_FORMAT - "d failures", + "%d branches, %d ms, %d failures", solver()->branches(), timer_->GetInMs(), solver()->failures()); if (min_right_depth_ != kint32max && max_depth_ != 0) { const int depth = solver()->SearchDepth(); @@ -211,9 +201,8 @@ void SearchLog::OutputDecision() { if (obj_ != nullptr && objective_min_ != kint64max && objective_max_ != kint64min) { absl::StrAppendFormat(&buffer, - ", objective minimum = %" GG_LL_FORMAT - "d" - ", objective maximum = %" GG_LL_FORMAT "d", + ", objective minimum = %d" + ", objective maximum = %d", objective_min_, objective_max_); } const int progress = solver()->TopProgressPercent(); @@ -235,9 +224,9 @@ void SearchLog::BeginInitialPropagation() { tick_ = timer_->GetInMs(); } void SearchLog::EndInitialPropagation() { const int64 delta = std::max(timer_->GetInMs() - tick_, int64{0}); const std::string buffer = - absl::StrFormat("Root node processed (time = %" GG_LL_FORMAT - "d ms, constraints = %d, %s)", - delta, solver()->constraints(), MemoryUsage()); + absl::StrFormat( + "Root node processed (time = %d ms, constraints = %d, %s)", + delta, solver()->constraints(), MemoryUsage()); OutputLine(buffer); } @@ -265,7 +254,7 @@ std::string SearchLog::MemoryUsage() { return absl::StrFormat("memory used = %2lf KB", memory_usage * 1.0 / kKiloByte); } else { - return absl::StrFormat("memory used = %" GG_LL_FORMAT "d", memory_usage); + return absl::StrFormat("memory used = %d", memory_usage); } } @@ -1524,7 +1513,7 @@ AssignOneVariableValue::AssignOneVariableValue(IntVar* const v, int64 val) : var_(v), value_(val) {} std::string AssignOneVariableValue::DebugString() const { - return absl::StrFormat("[%s == %" GG_LL_FORMAT "d]", var_->DebugString(), + return absl::StrFormat("[%s == %d]", var_->DebugString(), value_); } @@ -1563,7 +1552,7 @@ AssignOneVariableValueOrFail::AssignOneVariableValueOrFail(IntVar* const v, : var_(v), value_(value) {} std::string AssignOneVariableValueOrFail::DebugString() const { - return absl::StrFormat("[%s == %" GG_LL_FORMAT "d]", var_->DebugString(), + return absl::StrFormat("[%s == %d]", var_->DebugString(), value_); } @@ -1605,10 +1594,10 @@ SplitOneVariable::SplitOneVariable(IntVar* const v, int64 val, std::string SplitOneVariable::DebugString() const { if (start_with_lower_half_) { - return absl::StrFormat("[%s <= %" GG_LL_FORMAT "d]", var_->DebugString(), + return absl::StrFormat("[%s <= %d]", var_->DebugString(), value_); } else { - return absl::StrFormat("[%s >= %" GG_LL_FORMAT "d]", var_->DebugString(), + return absl::StrFormat("[%s >= %d]", var_->DebugString(), value_); } } @@ -1680,7 +1669,7 @@ AssignVariablesValues::AssignVariablesValues(const std::vector& vars, std::string AssignVariablesValues::DebugString() const { std::string out; for (int i = 0; i < vars_.size(); ++i) { - absl::StrAppendFormat(&out, "[%s == %" GG_LL_FORMAT "d]", + absl::StrAppendFormat(&out, "[%s == %d]", vars_[i]->DebugString(), values_[i]); } return out; @@ -2728,7 +2717,7 @@ bool OptimizeVar::AtSolution() { } std::string OptimizeVar::Print() const { - return absl::StrFormat("objective value = %" GG_LL_FORMAT "d, ", + return absl::StrFormat("objective value = %d, ", var_->Value()); } @@ -2740,7 +2729,7 @@ std::string OptimizeVar::DebugString() const { out = "MinimizeVar("; } absl::StrAppendFormat( - &out, "%s, step = %" GG_LL_FORMAT "d, best = %" GG_LL_FORMAT "d)", + &out, "%s, step = %d, best = %d)", var_->DebugString(), step_, best_); return out; } @@ -3981,11 +3970,9 @@ void RegularLimit::UpdateLimits(int64 time, int64 branches, int64 failures, } std::string RegularLimit::DebugString() const { - return absl::StrFormat("RegularLimit(crossed = %i, wall_time = %" GG_LL_FORMAT - "d, " - "branches = %" GG_LL_FORMAT - "d, failures = %" GG_LL_FORMAT - "d, solutions = %" GG_LL_FORMAT "d cumulative = %s", + return absl::StrFormat("RegularLimit(crossed = %i, wall_time = %d, " + "branches = %d, failures = %d, solutions = %d, " + "cumulative = %s", crossed(), wall_time_, branches_, failures_, solutions_, (cumulative_ ? "true" : "false")); } diff --git a/ortools/constraint_solver/table.cc b/ortools/constraint_solver/table.cc index da4afd272f0..ec8b52f64c6 100644 --- a/ortools/constraint_solver/table.cc +++ b/ortools/constraint_solver/table.cc @@ -64,7 +64,7 @@ struct AffineTransformation { // y == a*x + b. } std::string DebugString() const { - return absl::StrFormat("(%" GG_LL_FORMAT "d * x + %" GG_LL_FORMAT "d)", a, + return absl::StrFormat("(%d * x + %d)", a, b); } }; @@ -1226,8 +1226,8 @@ class TransitionConstraint : public Constraint { std::string DebugString() const override { return absl::StrFormat( - "TransitionConstraint([%s], %d transitions, initial = %" GG_LL_FORMAT - "d, final = [%s])", + "TransitionConstraint([%s], %d transitions, initial = %d, " + "final = [%s])", JoinDebugStringPtr(vars_, ", "), transition_table_.NumTuples(), initial_state_, absl::StrJoin(final_states_, ", ")); } diff --git a/ortools/constraint_solver/timetabling.cc b/ortools/constraint_solver/timetabling.cc index 3f21706d9f9..1b7e0cc936e 100644 --- a/ortools/constraint_solver/timetabling.cc +++ b/ortools/constraint_solver/timetabling.cc @@ -47,7 +47,7 @@ class IntervalUnaryRelation : public Constraint { void InitialPropagate() override; std::string DebugString() const override { - return absl::StrFormat("(%s %s %" GG_LL_FORMAT "d)", t_->DebugString(), + return absl::StrFormat("(%s %s %d)", t_->DebugString(), kUnaryNames[rel_], d_); } diff --git a/ortools/constraint_solver/tree_monitor.cc b/ortools/constraint_solver/tree_monitor.cc index 499be36c2bc..975e6882d76 100644 --- a/ortools/constraint_solver/tree_monitor.cc +++ b/ortools/constraint_solver/tree_monitor.cc @@ -370,14 +370,14 @@ class TreeNode { // Use %d .. %d format. visualization_writer->AddAttribute( "domain", - absl::StrFormat("%" GG_LL_FORMAT "d .. %" GG_LL_FORMAT "d", + absl::StrFormat("%d .. %d", current[0], current.back())); } else { // Use list of integers std::string domain; for (int j = 0; j < current.size(); ++j) { - absl::StrAppendFormat(&domain, " %" GG_LL_FORMAT "d", current[j]); + absl::StrAppendFormat(&domain, " %d", current[j]); } visualization_writer->AddAttribute( diff --git a/ortools/flatzinc/flatzinc_constraints.cc b/ortools/flatzinc/flatzinc_constraints.cc index 7be48ea69f5..6a01a36c986 100644 --- a/ortools/flatzinc/flatzinc_constraints.cc +++ b/ortools/flatzinc/flatzinc_constraints.cc @@ -152,7 +152,7 @@ class FixedModulo : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("(%s %% %s == %" GG_LL_FORMAT "d)", + return absl::StrFormat("(%s %% %s == %d)", var_->DebugString(), mod_->DebugString(), residual_); } @@ -303,8 +303,7 @@ class IsBooleanSumInRange : public Constraint { } std::string DebugString() const override { - return absl::StrFormat("Sum([%s]) in [%" GG_LL_FORMAT "d..%" GG_LL_FORMAT - "d] == %s", + return absl::StrFormat("Sum([%s]) in [%d..%d] == %s", JoinDebugStringPtr(vars_, ", "), range_min_, range_max_, target_->DebugString()); } @@ -423,7 +422,7 @@ class BooleanSumInRange : public Constraint { std::string DebugString() const override { return absl::StrFormat( - "Sum([%s]) in [%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d]", + "Sum([%s]) in [%d..%d]", JoinDebugStringPtr(vars_, ", "), range_min_, range_max_); } diff --git a/ortools/flatzinc/model.cc b/ortools/flatzinc/model.cc index 0c3c58feaf9..bc3ef45d57a 100644 --- a/ortools/flatzinc/model.cc +++ b/ortools/flatzinc/model.cc @@ -372,7 +372,7 @@ std::string Domain::DebugString() const { if (values.empty()) { return "int"; } else { - return absl::StrFormat("[%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d]", + return absl::StrFormat("[%d..%d]", values[0], values[1]); } } else if (values.size() == 1) { @@ -448,9 +448,9 @@ Argument Argument::FromDomain(const Domain& domain) { std::string Argument::DebugString() const { switch (type) { case INT_VALUE: - return absl::StrFormat("% " GG_LL_FORMAT "d", values[0]); + return absl::StrFormat("% d", values[0]); case INT_INTERVAL: - return absl::StrFormat("[%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d]", + return absl::StrFormat("[%d..%d]", values[0], values[1]); case INT_LIST: return absl::StrFormat("[%s]", absl::StrJoin(values, ", ")); @@ -619,7 +619,7 @@ bool IntegerVariable::Merge(const std::string& other_name, std::string IntegerVariable::DebugString() const { if (!domain.is_interval && domain.values.size() == 1) { - return absl::StrFormat("% " GG_LL_FORMAT "d", domain.values.back()); + return absl::StrFormat("% d", domain.values.back()); } else { return absl::StrFormat( "%s(%s%s%s)%s", name, domain.DebugString(), @@ -787,7 +787,7 @@ std::string Annotation::DebugString() const { return absl::StrFormat("%s(%s)", id, JoinDebugString(annotations, ", ")); } case INTERVAL: { - return absl::StrFormat("%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d", + return absl::StrFormat("%d..%d", interval_min, interval_max); } case INT_VALUE: { @@ -815,7 +815,7 @@ std::string Annotation::DebugString() const { // ----- SolutionOutputSpecs ----- std::string SolutionOutputSpecs::Bounds::DebugString() const { - return absl::StrFormat("%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d", min_value, + return absl::StrFormat("%d..%d", min_value, max_value); } diff --git a/ortools/flatzinc/presolve.cc b/ortools/flatzinc/presolve.cc index 7a071e94854..95c692fb907 100644 --- a/ortools/flatzinc/presolve.cc +++ b/ortools/flatzinc/presolve.cc @@ -1268,11 +1268,9 @@ Presolver::RuleStatus Presolver::PresolveArrayIntElement(Constraint* ct, if (last_index < ct->arguments[0].Var()->domain.Max() || first_index > ct->arguments[0].Var()->domain.Min()) { - absl::StrAppendFormat(log, - "filter index to [%" GG_LL_FORMAT - "d..%" GG_LL_FORMAT - "d] and reduce array to size %" GG_LL_FORMAT "d", - first_index, last_index, last_index); + absl::StrAppendFormat( + log, "filter index to [%d..%d] and reduce array to size %d", + first_index, last_index, last_index); IntersectVarWithInterval(ct->arguments[0].Var(), first_index, last_index); ct->arguments[1].values.resize(last_index); @@ -1547,7 +1545,7 @@ Presolver::RuleStatus Presolver::PropagatePositiveLinear(Constraint* ct, const int64 bound = rhs / coef; if (bound < var->domain.Max()) { absl::StrAppendFormat(log, - ", intersect %s with [0..%" GG_LL_FORMAT "d]", + ", intersect %s with [0..%d]", var->DebugString(), bound); IntersectVarWithInterval(var, 0, bound); } @@ -1561,7 +1559,7 @@ Presolver::RuleStatus Presolver::PropagatePositiveLinear(Constraint* ct, const int64 bound = (rhs + coef - 1) / coef; if (bound > var->domain.Min()) { absl::StrAppendFormat( - log, ", intersect %s with [%" GG_LL_FORMAT "d .. INT_MAX]", + log, ", intersect %s with [%d .. INT_MAX]", var->DebugString(), bound); IntersectVarWithInterval(var, bound, kint64max); return CONSTRAINT_ALWAYS_TRUE; diff --git a/ortools/flatzinc/reporting.cc b/ortools/flatzinc/reporting.cc index 73432cf721c..275b40820b0 100644 --- a/ortools/flatzinc/reporting.cc +++ b/ortools/flatzinc/reporting.cc @@ -133,7 +133,7 @@ class MtOptimizeVar : public OptimizeVar { if (verbose_) { report_->Log( thread_id_, - absl::StrFormat("Polling improved objective %" GG_LL_FORMAT "d", + absl::StrFormat("Polling improved objective %d", polled_best)); } best_ = polled_best; @@ -238,7 +238,7 @@ void MultiThreadReporting::OnOptimizeSolution( if (verbose_) { LogNoLock( thread_id, - absl::StrFormat("solution found with value %" GG_LL_FORMAT "d", + absl::StrFormat("solution found with value %d", value)); } if (ShouldPrintAllSolutions() || MaxNumSolutions() > 1) { @@ -257,7 +257,7 @@ void MultiThreadReporting::OnOptimizeSolution( if (verbose_) { LogNoLock( thread_id, - absl::StrFormat("solution found with value %" GG_LL_FORMAT "d", + absl::StrFormat("solution found with value %d", value)); } if (ShouldPrintAllSolutions() || MaxNumSolutions() > 1) { @@ -298,7 +298,7 @@ void MultiThreadReporting::OnSearchEnd(int thread_id, bool interrupted) { if (!last_solution_.empty()) { if (verbose_) { LogNoLock(last_thread_, - absl::StrFormat("solution found with value %" GG_LL_FORMAT "d", + absl::StrFormat("solution found with value %d", best_objective_)); } Print(thread_id, last_solution_); diff --git a/ortools/flatzinc/solver.cc b/ortools/flatzinc/solver.cc index 973173a937d..f05ea8e53a8 100644 --- a/ortools/flatzinc/solver.cc +++ b/ortools/flatzinc/solver.cc @@ -95,7 +95,7 @@ std::string Solver::SolutionString(const SolutionOutputSpecs& output) const { return absl::StrFormat("%s = %s;", output.name, value == 1 ? "true" : "false"); } else { - return absl::StrFormat("%s = %" GG_LL_FORMAT "d;", output.name, value); + return absl::StrFormat("%s = %d;", output.name, value); } } else { const int bound_size = output.bounds.size(); @@ -104,7 +104,7 @@ std::string Solver::SolutionString(const SolutionOutputSpecs& output) const { for (int i = 0; i < bound_size; ++i) { if (output.bounds[i].max_value != 0) { result.append(absl::StrFormat( - "%" GG_LL_FORMAT "d..%" GG_LL_FORMAT "d, ", + "%d..%d, ", output.bounds[i].min_value, output.bounds[i].max_value)); } else { result.append("{},"); @@ -854,27 +854,27 @@ void Solver::Solve(FlatzincParameters p, SearchReportingInterface* report) { proven = true; } solver_status.append( - absl::StrFormat("%%%% total runtime: %" GG_LL_FORMAT "d ms\n", + absl::StrFormat("%%%% total runtime: %d ms\n", solve_time + build_time)); solver_status.append(absl::StrFormat( - "%%%% build time: %" GG_LL_FORMAT "d ms\n", build_time)); + "%%%% build time: %d ms\n", build_time)); solver_status.append(absl::StrFormat( - "%%%% solve time: %" GG_LL_FORMAT "d ms\n", solve_time)); + "%%%% solve time: %d ms\n", solve_time)); solver_status.append( absl::StrFormat("%%%% solutions: %d\n", num_solutions)); solver_status.append(absl::StrFormat("%%%% constraints: %d\n", solver_->constraints())); solver_status.append(absl::StrFormat( - "%%%% normal propagations: %" GG_LL_FORMAT "d\n", + "%%%% normal propagations: %d\n", solver_->demon_runs(operations_research::Solver::NORMAL_PRIORITY))); solver_status.append(absl::StrFormat( - "%%%% delayed propagations: %" GG_LL_FORMAT "d\n", + "%%%% delayed propagations: %d\n", solver_->demon_runs(operations_research::Solver::DELAYED_PRIORITY))); solver_status.append( - absl::StrFormat("%%%% branches: %" GG_LL_FORMAT "d\n", + absl::StrFormat("%%%% branches: %d\n", solver_->branches())); solver_status.append( - absl::StrFormat("%%%% failures: %" GG_LL_FORMAT "d\n", + absl::StrFormat("%%%% failures: %d\n", solver_->failures())); solver_status.append( absl::StrFormat("%%%% memory: %s\n", MemoryUsage())); @@ -882,11 +882,11 @@ void Solver::Solve(FlatzincParameters p, SearchReportingInterface* report) { if (model_.objective() != nullptr) { if (!model_.maximize() && num_solutions > 0) { solver_status.append(absl::StrFormat( - "%%%% min objective: %" GG_LL_FORMAT "d%s\n", best, + "%%%% min objective: %d%s\n", best, (proven ? " (proven)" : ""))); } else if (num_solutions > 0) { solver_status.append(absl::StrFormat( - "%%%% max objective: %" GG_LL_FORMAT "d%s\n", best, + "%%%% max objective: %d%s\n", best, (proven ? " (proven)" : ""))); } } @@ -913,9 +913,7 @@ void Solver::Solve(FlatzincParameters p, SearchReportingInterface* report) { "%% name, status, obj, solns, s_time, b_time, br, " "fails, cts, demon, delayed, mem, search\n"); solver_status.append(absl::StrFormat( - "%%%% csv: %s, %s, %s, %d, %" GG_LL_FORMAT "d ms, %" GG_LL_FORMAT - "d ms, %" GG_LL_FORMAT "d, %" GG_LL_FORMAT "d, %d, %" GG_LL_FORMAT - "d, %" GG_LL_FORMAT "d, %s, %s", + "%%%% csv: %s, %s, %s, %d, %d ms, %d ms, %d, %d, %d, %d, %d, %s, %s", model_.name(), status_string, obj_string, num_solutions, solve_time, build_time, solver_->branches(), solver_->failures(), solver_->constraints(), diff --git a/ortools/sat/sat_solver.cc b/ortools/sat/sat_solver.cc index 1e8f9246ab5..e135337c5f9 100644 --- a/ortools/sat/sat_solver.cc +++ b/ortools/sat/sat_solver.cc @@ -1411,38 +1411,34 @@ std::string SatSolver::StatusString(Status status) const { absl::StrFormat(" time: %fs\n", time_in_s) + absl::StrFormat(" memory: %s\n", MemoryUsage()) + absl::StrFormat( - " num failures: %" GG_LL_FORMAT "d (%.0f /sec)\n", + " num failures: %d (%.0f /sec)\n", counters_.num_failures, static_cast(counters_.num_failures) / time_in_s) + absl::StrFormat( - " num branches: %" GG_LL_FORMAT "d (%.0f /sec)\n", + " num branches: %d (%.0f /sec)\n", counters_.num_branches, static_cast(counters_.num_branches) / time_in_s) + - absl::StrFormat(" num propagations: %" GG_LL_FORMAT - "d (%.0f /sec)\n", + absl::StrFormat(" num propagations: %d (%.0f /sec)\n", num_propagations(), static_cast(num_propagations()) / time_in_s) + - absl::StrFormat(" num binary propagations: %" GG_LL_FORMAT "d\n", + absl::StrFormat(" num binary propagations: %d\n", binary_implication_graph_->num_propagations()) + - absl::StrFormat(" num binary inspections: %" GG_LL_FORMAT "d\n", + absl::StrFormat(" num binary inspections: %d\n", binary_implication_graph_->num_inspections()) + absl::StrFormat( - " num binary redundant implications: %" GG_LL_FORMAT "d\n", + " num binary redundant implications: %d\n", binary_implication_graph_->num_redundant_implications()) + - absl::StrFormat(" num classic minimizations: %" GG_LL_FORMAT - "d" - " (literals removed: %" GG_LL_FORMAT "d)\n", + absl::StrFormat(" num classic minimizations: %d" + " (literals removed: %d)\n", counters_.num_minimizations, counters_.num_literals_removed) + - absl::StrFormat(" num binary minimizations: %" GG_LL_FORMAT - "d" - " (literals removed: %" GG_LL_FORMAT "d)\n", + absl::StrFormat(" num binary minimizations: %d" + " (literals removed: %d)\n", binary_implication_graph_->num_minimization(), binary_implication_graph_->num_literals_removed()) + - absl::StrFormat(" num inspected clauses: %" GG_LL_FORMAT "d\n", + absl::StrFormat(" num inspected clauses: %d\n", clauses_propagator_.num_inspected_clauses()) + - absl::StrFormat(" num inspected clause_literals: %" GG_LL_FORMAT - "d\n", + absl::StrFormat(" num inspected clause_literals: %d\n", clauses_propagator_.num_inspected_clause_literals()) + absl::StrFormat( " num learned literals: %d (avg: %.1f /clause)\n", @@ -1477,8 +1473,7 @@ std::string SatSolver::StatusString(Status status) const { std::string SatSolver::RunningStatisticsString() const { const double time_in_s = timer_.Get(); return absl::StrFormat( - "%6.2fs, mem:%s, fails:%" GG_LL_FORMAT - "d, " + "%6.2fs, mem:%s, fails:%d, " "depth:%d, clauses:%lld, tmp:%lld, bin:%llu, restarts:%d, vars:%d", time_in_s, MemoryUsage(), counters_.num_failures, CurrentDecisionLevel(), clauses_propagator_.num_clauses() - diff --git a/ortools/util/piecewise_linear_function.cc b/ortools/util/piecewise_linear_function.cc index 657007cbf3b..debd31300ed 100644 --- a/ortools/util/piecewise_linear_function.cc +++ b/ortools/util/piecewise_linear_function.cc @@ -257,13 +257,8 @@ void PiecewiseSegment::AddConstantToY(int64 constant) { std::string PiecewiseSegment::DebugString() const { std::string result = absl::StrFormat( - "PiecewiseSegment()", + "PiecewiseSegment()", start_x_, Value(start_x_), end_x_, Value(end_x_), reference_x_, reference_y_, slope_); return result; diff --git a/ortools/util/sorted_interval_list.cc b/ortools/util/sorted_interval_list.cc index 06249469d07..e15a5e43b7e 100644 --- a/ortools/util/sorted_interval_list.cc +++ b/ortools/util/sorted_interval_list.cc @@ -22,8 +22,8 @@ namespace operations_research { std::string ClosedInterval::DebugString() const { - if (start == end) return absl::StrFormat("[%" GG_LL_FORMAT "d]", start); - return absl::StrFormat("[%" GG_LL_FORMAT "d,%" GG_LL_FORMAT "d]", start, end); + if (start == end) return absl::StrFormat("[%d]", start); + return absl::StrFormat("[%d,%d]", start, end); } bool IntervalsAreSortedAndNonAdjacent( diff --git a/ortools/util/stats.cc b/ortools/util/stats.cc index e34c1eb62b2..6f4b9b026c9 100644 --- a/ortools/util/stats.cc +++ b/ortools/util/stats.cc @@ -35,7 +35,7 @@ std::string MemoryUsage() { } else if (mem > kDisplayThreshold * kKiloByte) { return absl::StrFormat("%2lf KB", mem * 1.0 / kKiloByte); } else { - return absl::StrFormat("%" GG_LL_FORMAT "d", mem); + return absl::StrFormat("%d", mem); } }