From 5113b0e591ce601743f48cd5c988169c7332cbf8 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Mon, 18 Mar 2024 15:20:37 -0600 Subject: [PATCH] More migration to --- solvers/gecode/gecode.cc | 18 +++++++++--------- solvers/gecode/gecode.h | 14 +++++++------- solvers/ilogcp/ilogcp.cc | 2 +- solvers/ilogcp/ilogcp.h | 4 ++-- solvers/jacop/jacop.cc | 6 +++--- solvers/jacop/jacop.h | 12 ++++++------ solvers/localsolver/localsolver.cc | 4 ++-- solvers/sulum/sulum.cc | 4 ++-- test/solvers/numberofmap-speed-test.cc | 6 +++--- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/solvers/gecode/gecode.cc b/solvers/gecode/gecode.cc index 13c2bdcd5..693f65df0 100644 --- a/solvers/gecode/gecode.cc +++ b/solvers/gecode/gecode.cc @@ -518,14 +518,14 @@ GecodeSolver::Stop::Stop(GecodeSolver &solver) : solver_(solver) { output_or_limit_ = solver.output_ || solver.time_limit_ < DBL_MAX || solver.node_limit_ != ULONG_MAX || solver.fail_limit_ != ULONG_MAX; - steady_clock::time_point start = steady_clock::now(); + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); double end_time_in_ticks = start.time_since_epoch().count() + - solver.time_limit_ * steady_clock::period::den / - steady_clock::period::num; - end_time_ = steady_clock::time_point(steady_clock::duration( - end_time_in_ticks >= std::numeric_limits::max() ? - std::numeric_limits::max() : - static_cast(end_time_in_ticks))); + solver.time_limit_ * std::chrono::steady_clock::period::den / + std::chrono::steady_clock::period::num; + end_time_ = std::chrono::steady_clock::time_point(std::chrono::steady_clock::duration( + end_time_in_ticks >= std::numeric_limits::max() ? + std::numeric_limits::max() : + static_cast(end_time_in_ticks))); next_output_time_ = start + GetOutputInterval(); } @@ -536,7 +536,7 @@ bool GecodeSolver::Stop::stop( return true; } if (!output_or_limit_) return false; - steady_clock::time_point time = steady_clock::now(); + std::chrono::steady_clock::time_point time = std::chrono::steady_clock::now(); if (solver_.output_ && time >= next_output_time_) { solver_.Output("{:10} {:10} {:10}\n", s.depth, s.node, s.fail); next_output_time_ += GetOutputInterval(); @@ -783,7 +783,7 @@ GecodeSolver::ProblemPtr GecodeSolver::Search( } void GecodeSolver::Solve(Problem &p, SolutionHandler &sh) { - steady_clock::time_point time = steady_clock::now(); + std::chrono::steady_clock::time_point time = std::chrono::steady_clock::now(); SetStatus(-1, ""); diff --git a/solvers/gecode/gecode.h b/solvers/gecode/gecode.h index f120efc99..25b3d0896 100644 --- a/solvers/gecode/gecode.h +++ b/solvers/gecode/gecode.h @@ -37,7 +37,7 @@ # pragma warning(pop) #endif -#include "mp/clock.h" +#include "mp/utils-clock.h" #include "mp/expr-visitor.h" #include "mp/problem.h" #include "mp/solver.h" @@ -358,14 +358,14 @@ class GecodeSolver : public SolverImpl { class Stop : public Gecode::Search::Stop { private: GecodeSolver &solver_; - steady_clock::time_point end_time_; - steady_clock::time_point next_output_time_; + std::chrono::steady_clock::time_point end_time_; + std::chrono::steady_clock::time_point next_output_time_; bool output_or_limit_; - steady_clock::duration GetOutputInterval() const { - return steady_clock::duration( - static_cast(solver_.output_frequency_ * - steady_clock::period::den / steady_clock::period::num)); + std::chrono::steady_clock::duration GetOutputInterval() const { + return std::chrono::steady_clock::duration( + static_cast(solver_.output_frequency_ * + std::chrono::steady_clock::period::den / std::chrono::steady_clock::period::num)); } public: diff --git a/solvers/ilogcp/ilogcp.cc b/solvers/ilogcp/ilogcp.cc index dcf97fdaf..f4263c149 100644 --- a/solvers/ilogcp/ilogcp.cc +++ b/solvers/ilogcp/ilogcp.cc @@ -824,7 +824,7 @@ void IlogCPSolver::Solve(Problem &p, SolutionHandler &sh) { } void IlogCPSolver::InitProblemModificationPhase(const Problem &p) { - stats.time = steady_clock::now(); + stats.time = std::chrono::steady_clock::now(); optimizer = optimizer_; if (optimizer == AUTO) { diff --git a/solvers/ilogcp/ilogcp.h b/solvers/ilogcp/ilogcp.h index c6591e748..49b6be1d8 100644 --- a/solvers/ilogcp/ilogcp.h +++ b/solvers/ilogcp/ilogcp.h @@ -52,7 +52,7 @@ #include /* Needed for g++ -m32 on MacOSX. */ #include -#include "mp/clock.h" +#include "mp/utils-clock.h" #include "mp/solver.h" namespace mp { @@ -144,7 +144,7 @@ class IlogCPSolver : public SolverImpl { void SetCPLEXIntOption(const SolverOption &opt, int value, int param); struct Stats { - steady_clock::time_point time; + std::chrono::steady_clock::time_point time; double setup_time; double solution_time; }; diff --git a/solvers/jacop/jacop.cc b/solvers/jacop/jacop.cc index a25049e44..03e09ccd3 100644 --- a/solvers/jacop/jacop.cc +++ b/solvers/jacop/jacop.cc @@ -486,7 +486,7 @@ void JaCoPSolver::Output(fmt::CStringRef format, const fmt::ArgList &args) { } void JaCoPSolver::PrintLogEntry() { - if (outlev_ == 0 || steady_clock::now() < next_output_time_) + if (outlev_ == 0 || std::chrono::steady_clock::now() < next_output_time_) return; Output("{:10} {:10} {:10}\n", env_.CallIntMethodKeepException(search_.get(), get_depth_), @@ -544,7 +544,7 @@ JNIEXPORT jboolean JNICALL JaCoPSolver::Stop(JNIEnv *, jobject, jlong data) { } void JaCoPSolver::Solve(Problem &p, SolutionHandler &sh) { - steady_clock::time_point time = steady_clock::now(); + std::chrono::steady_clock::time_point time = std::chrono::steady_clock::now(); std::vector jvm_options(jvm_options_.size() + 2); for (size_t i = 0, n = jvm_options_.size(); i != n; ++i) @@ -660,7 +660,7 @@ void JaCoPSolver::Solve(Problem &p, SolutionHandler &sh) { "Max Depth", "Nodes", "Fails", (has_obj ? "Best Obj" : "")); jboolean found = false; output_count_ = 0; - next_output_time_ = steady_clock::now() + GetOutputInterval(); + next_output_time_ = std::chrono::steady_clock::now() + GetOutputInterval(); try { if (has_obj) { jmethodID labeling = env_.GetMethod(dfs_class.get(), "labeling", diff --git a/solvers/jacop/jacop.h b/solvers/jacop/jacop.h index 076fafa45..3da1b961b 100644 --- a/solvers/jacop/jacop.h +++ b/solvers/jacop/jacop.h @@ -25,7 +25,7 @@ #include -#include "mp/clock.h" +#include "mp/utils-clock.h" #include "mp/expr-visitor.h" #include "mp/problem.h" #include "mp/solver.h" @@ -398,7 +398,7 @@ class JaCoPSolver : public SolverImpl { std::vector jvm_options_; jlong outlev_; double output_frequency_; - steady_clock::time_point next_output_time_; + std::chrono::steady_clock::time_point next_output_time_; unsigned output_count_; std::string header_; const char *var_select_; @@ -456,10 +456,10 @@ class JaCoPSolver : public SolverImpl { void Output(fmt::CStringRef format, const fmt::ArgList &args); FMT_VARIADIC(void, Output, fmt::CStringRef) - steady_clock::duration GetOutputInterval() const { - return steady_clock::duration( - static_cast(output_frequency_ * - steady_clock::period::den / steady_clock::period::num)); + std::chrono::steady_clock::duration GetOutputInterval() const { + return std::chrono::steady_clock::duration( + static_cast(output_frequency_ * + std::chrono::steady_clock::period::den / std::chrono::steady_clock::period::num)); } // Prints the solution log entry if the time is right. diff --git a/solvers/localsolver/localsolver.cc b/solvers/localsolver/localsolver.cc index eaa18caf9..e1f3c7439 100644 --- a/solvers/localsolver/localsolver.cc +++ b/solvers/localsolver/localsolver.cc @@ -25,7 +25,7 @@ #include #include -#include "mp/clock.h" +#include "mp/utils-clock.h" #include "mp/safeint.h" #ifndef MP_DRIVER_DATE @@ -559,7 +559,7 @@ LocalSolver::LocalSolver() } void LocalSolver::Solve(ProblemBuilder &builder, SolutionHandler &sh) { - steady_clock::time_point time = steady_clock::now(); + std::chrono::steady_clock::time_point time = std::chrono::steady_clock::now(); ls::LocalSolver &solver = builder.solver(); ls::LSModel model = solver.getModel(); diff --git a/solvers/sulum/sulum.cc b/solvers/sulum/sulum.cc index 16f19e683..e617ac082 100644 --- a/solvers/sulum/sulum.cc +++ b/solvers/sulum/sulum.cc @@ -21,7 +21,7 @@ */ #include "sulum/sulum.h" -#include "mp/clock.h" +#include "mp/utils-clock.h" #include @@ -151,7 +151,7 @@ SulumSolver::~SulumSolver() { } void SulumSolver::Solve(ColProblem &p, SolutionHandler &sh) { - steady_clock::time_point time = steady_clock::now(); + std::chrono::steady_clock::time_point time = std::chrono::steady_clock::now(); if (p.has_nonlinear_cons() || p.num_logical_cons() != 0) throw Error("Sulum doesn't support nonlinear problems"); diff --git a/test/solvers/numberofmap-speed-test.cc b/test/solvers/numberofmap-speed-test.cc index 10ddb1786..ebc4023e9 100644 --- a/test/solvers/numberofmap-speed-test.cc +++ b/test/solvers/numberofmap-speed-test.cc @@ -1,5 +1,5 @@ #include "ilogcp/concert.h" -#include "mp/clock.h" +#include "mp/utils-clock.h" #include "mp/problem.h" struct CreateVar { @@ -17,10 +17,10 @@ int main() { b.AddArg(p.MakeVariable(i)); exprs[i] = p.EndNumberOf(b); } - mp::steady_clock::time_point start = mp::steady_clock::now(); + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); for (int i = 0; i < num_exprs; ++i) map.Add(0, exprs[i]); - mp::steady_clock::time_point end = mp::steady_clock::now(); + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); fmt::print("Executed NumberOfMap.Add {} times in {} s.\n", num_exprs, mp::duration_cast< mp::duration >(end - start).count()); }