Skip to content

Commit

Permalink
Fixing bug in trace buffer flush at exit, and reducing minimum iterat…
Browse files Browse the repository at this point in the history
…ions for simulated annealing
  • Loading branch information
khuck committed Feb 5, 2024
1 parent 396b3fe commit 146cacc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/apex/simulated_annealing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ size_t SimulatedAnnealing::get_max_iterations() {
}
//return max_iter / vars.size();
//return max_iter * vars.size() *vars.size();
return std::min(max_iterations, (std::max(min_iterations, max_iter*max_iter)));
auto foo = std::min(max_iterations, (std::max(min_iterations, max_iter*vars.size())));
//std::cout << "Max iterations: " << foo << std::endl;
return foo;
}

double SimulatedAnnealing::acceptance_probability(double new_cost) {
Expand Down
2 changes: 1 addition & 1 deletion src/apex/trace_event_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ void trace_event_listener::flush_trace_if_necessary(bool force) {
void trace_event_listener::close_trace(void) {
static bool closed{false};
if (closed) return;
flush_trace(this);
auto& trace_file = get_trace_file();
std::stringstream ss;
ss.precision(3);
Expand All @@ -549,6 +548,7 @@ void trace_event_listener::close_trace(void) {
ss << "]\n";
ss << "}\n" << std::endl;
write_to_trace(ss);
flush_trace(this);
//printf("Closing trace...\n"); fflush(stdout);
trace_file.close();
closed = true;
Expand Down

0 comments on commit 146cacc

Please sign in to comment.