Skip to content
Snippets Groups Projects
Commit b5891a6c authored by Kilian Verhetsel's avatar Kilian Verhetsel
Browse files

Replaced uses of std::chrono with GetTimeInSeconds

A monotonic clock (e.g. clock_gettime(2), GetTickCount64) would be more
appropriate.
parent 7fbdbb75
Branches
Tags
No related merge requests found
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
#include <iterator> #include <iterator>
#include <functional> #include <functional>
#include <algorithm> #include <algorithm>
#include <chrono>
#include <boost/functional.hpp> #include <boost/functional.hpp>
#include "OS.h"
namespace search { namespace search {
template<typename T> template<typename T>
...@@ -189,9 +190,9 @@ void large_neighborhood_search(State &state, Selector &selector, ...@@ -189,9 +190,9 @@ void large_neighborhood_search(State &state, Selector &selector,
typedef typename selector_traits<Selector>::fragment_type fragment; typedef typename selector_traits<Selector>::fragment_type fragment;
typedef typename search_traits<Search>::assignment_type assignment; typedef typename search_traits<Search>::assignment_type assignment;
using namespace std::chrono; /* TODO: Use a monotonic clock instead */
auto start = steady_clock::now(); double start = GetTimeInSeconds();
while (steady_clock::now() - start < time_limit * 1s) { while (GetTimeInSeconds() - start < time_limit) {
fragment fragment(selector(state)); fragment fragment(selector(state));
assignment assignment(search(state, fragment)); assignment assignment(search(state, fragment));
assignment(state, fragment); assignment(state, fragment);
...@@ -349,14 +350,13 @@ void monte_carlo_tree_search(State &state, Successor &fn, Evaluator &eval) { ...@@ -349,14 +350,13 @@ void monte_carlo_tree_search(State &state, Successor &fn, Evaluator &eval) {
actions[0](state).apply(state); actions[0](state).apply(state);
} }
else { else {
using namespace std::chrono;
mcts_node<score> node; mcts_node<score> node;
size_t i; size_t i;
auto start = steady_clock::now(); /* TODO: Use a monotonic clock instead */
for (i = 0; (steady_clock::now() - start) < 1s; i++) { double start = GetTimeInSeconds();
for (i = 0; (GetTimeInSeconds() - start) < 1.0; i++) {
mcts_simulation(&node, state, fn, eval, i, mcts_simulation(&node, state, fn, eval, i,
actions.begin(), actions.end()); actions.begin(), actions.end());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment