Skip to content

Commit

Permalink
chore: EnvParam to print statistics at solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
arbimo committed Dec 1, 2023
1 parent e8c2410 commit 56b9ff1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions solver/src/solver/solver_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use tracing::instrument;
/// If true, decisions will be logged to the standard output.
static LOG_DECISIONS: EnvParam<bool> = EnvParam::new("ARIES_LOG_DECISIONS", "false");

/// If true: each time a solution is found, the solver's stats will be printed (in optimization)
static STATS_AT_SOLUTION: EnvParam<bool> = EnvParam::new("ARIES_STATS_AT_SOLUTION", "false");

/// Macro that uses the the same syntax as `println!()` but:
/// - only evaluate arguments and print if `LOG_DECISIONS` is true.
/// - prepends the thread id to the line.
Expand Down Expand Up @@ -409,6 +412,10 @@ impl<Lbl: Label> Solver<Lbl> {
self.sync.notify_solution_found(sol.clone());
let objective_value = sol.var_domain(objective).lb;
on_new_solution(objective_value, &sol);
if STATS_AT_SOLUTION.get() {
println!("********* New sol: {objective_value} *********");
self.print_stats();
}
sol
}
SolveResult::ExternalSolution(sol) => sol, // a solution was handed out to us by another solver
Expand Down

0 comments on commit 56b9ff1

Please sign in to comment.