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 @@
#include <iterator>
#include <functional>
#include <algorithm>
#include <chrono>
#include <boost/functional.hpp>
#include "OS.h"
namespace search {
template<typename T>
......@@ -189,9 +190,9 @@ void large_neighborhood_search(State &state, Selector &selector,
typedef typename selector_traits<Selector>::fragment_type fragment;
typedef typename search_traits<Search>::assignment_type assignment;
using namespace std::chrono;
auto start = steady_clock::now();
while (steady_clock::now() - start < time_limit * 1s) {
/* TODO: Use a monotonic clock instead */
double start = GetTimeInSeconds();
while (GetTimeInSeconds() - start < time_limit) {
fragment fragment(selector(state));
assignment assignment(search(state, fragment));
assignment(state, fragment);
......@@ -349,14 +350,13 @@ void monte_carlo_tree_search(State &state, Successor &fn, Evaluator &eval) {
actions[0](state).apply(state);
}
else {
using namespace std::chrono;
mcts_node<score> node;
size_t i;
auto start = steady_clock::now();
for (i = 0; (steady_clock::now() - start) < 1s; i++) {
/* TODO: Use a monotonic clock instead */
double start = GetTimeInSeconds();
for (i = 0; (GetTimeInSeconds() - start) < 1.0; i++) {
mcts_simulation(&node, state, fn, eval, i,
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