Skip to content

Commit

Permalink
Switched to running average iteration time
Browse files Browse the repository at this point in the history
  • Loading branch information
jajhall committed Nov 28, 2022
1 parent e021356 commit b712d6c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/util/HFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ HighsInt HFactor::buildKernel() {
// Initial timer frequency: may be reduced if iterations get slow
HighsInt timer_frequency = 100;
double previous_iteration_time = 0;
double iteration_time = 0;
double average_iteration_time = 0;
const bool check_for_timeout = this->time_limit_ < kHighsInf;
HighsInt search_k = 0;

Expand All @@ -897,12 +897,16 @@ HighsInt HFactor::buildKernel() {
double current_time = build_timer_->readRunHighsClock();
double time_difference = current_time - previous_iteration_time;
previous_iteration_time = current_time;
iteration_time = time_difference / (1.0 * timer_frequency);
double iteration_time = time_difference / (1.0 * timer_frequency);
average_iteration_time = 0.9* average_iteration_time + 0.1 * iteration_time;

if (time_difference > this->time_limit_/1e3)
timer_frequency = std::max(1, timer_frequency/10);
HighsInt iterations_left = kernel_dim - search_k + 1;
double remaining_time_bound = iteration_time * iterations_left;
double remaining_time_bound = average_iteration_time * iterations_left;
double total_time_bound = current_time + remaining_time_bound;
printf("%d; Iter: Time %11.4g; average = %11.4g; Bound = %11.4g\n",
search_k, iteration_time, average_iteration_time, total_time_bound);
if (current_time > this->time_limit_ || total_time_bound > this->time_limit_)
return kBuildKernelReturnTimeout;
}
Expand Down

0 comments on commit b712d6c

Please sign in to comment.