Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a flag to print the solver statistics #184

Open
zapashcanon opened this issue Feb 21, 2024 · 2 comments · May be fixed by #198
Open

add a flag to print the solver statistics #184

zapashcanon opened this issue Feb 21, 2024 · 2 comments · May be fixed by #198
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@zapashcanon
Copy link
Member

the quick&dirty way to do it for reference:

diff --git a/src/symbolic_choice.ml b/src/symbolic_choice.ml
index e799358..534a023 100644
--- a/src/symbolic_choice.ml
+++ b/src/symbolic_choice.ml
@@ -19,7 +19,10 @@ let check sym_bool thread (S (solver_module, solver)) =
   | _ ->
     let check = no :: pc in
     let module Solver = (val solver_module) in
+
     let r = Solver.check solver check in
+        Solver.pp_statistics Stdlib.Format.std_formatter solver;
+        Stdlib.Format.pp_print_flush Stdlib.Format.std_formatter ();
     not r
 
 let list_select b ({ Thread.pc; _ } as thread) (S (solver_module, s)) =
@@ -34,6 +37,9 @@ let list_select b ({ Thread.pc; _ } as thread) (S (solver_module, s)) =
     let with_not_v = Bool.not v :: pc in
     let sat_true = Solver.check s with_v in
     let sat_false = Solver.check s with_not_v in
+
+        Solver.pp_statistics Stdlib.Format.std_formatter s;
+        Stdlib.Format.pp_print_flush Stdlib.Format.std_formatter ();
     match (sat_true, sat_false) with
     | false, false -> []
     | true, false | false, true -> [ (sat_true, thread) ]
@@ -78,6 +84,8 @@ let list_select_i32 sym_int thread (S (solver_module, solver)) =
       if not (Solver.check solver (additionnal @ pc)) then []
       else begin
         let model = Solver.model ~symbols:[ symbol ] solver in
+        Solver.pp_statistics Stdlib.Format.std_formatter solver;
+        Stdlib.Format.pp_print_flush Stdlib.Format.std_formatter ();
         match model with
         | None -> assert false (* ? *)
         | Some model -> (
@zapashcanon zapashcanon added enhancement New feature or request good first issue Good for newcomers labels Feb 21, 2024
@filipeom
Copy link
Collaborator

filipeom commented Feb 27, 2024

Where would printing the solver statistics make more sense? In this example you're doing it after each solver interaction. I was thinking it might be more appropriate at the end of the analysis, with all the stats accumulated. However, considering that the solver is part of the multi-threaded choice monad, gathering the statistics of every spawned solver may not be straightforward. What do you think?

@epatrizio epatrizio linked a pull request Mar 1, 2024 that will close this issue
@epatrizio
Copy link
Collaborator

For now, statistics are displayed after Solver.get_model call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants