prune_lang/interp/
config.rs1use super::*;
2use crate::cli::args;
3
4#[derive(Debug)]
5pub struct RunnerConfig {
6 pub depth_step: usize,
7 pub depth_limit: usize,
8 pub answer_limit: usize,
9 pub answer_pause: bool,
10 pub solver: args::Solver,
11 pub heuristic: args::Heuristic,
12 pub debug_mode: bool,
13}
14
15impl RunnerConfig {
16 pub fn new(solver: args::Solver, heuristic: args::Heuristic, debug_mode: bool) -> RunnerConfig {
17 RunnerConfig {
18 depth_step: 5,
19 depth_limit: 100,
20 answer_limit: usize::MAX,
21 answer_pause: false,
22 solver,
23 heuristic,
24 debug_mode,
25 }
26 }
27
28 pub fn reset_default(&mut self) {
29 self.depth_step = 5;
30 self.depth_limit = 100;
31 self.answer_limit = usize::MAX;
32 }
33
34 pub fn set_param(&mut self, param: &QueryParam) {
35 match param {
36 QueryParam::DepthStep(x) => {
37 self.depth_step = *x;
38 }
39 QueryParam::DepthLimit(x) => {
40 self.depth_limit = *x;
41 }
42 QueryParam::AnswerLimit(x) => {
43 self.answer_limit = *x;
44 }
45 QueryParam::AnswerPause(x) => {
46 self.answer_pause = *x;
47 }
48 }
49 }
50}
51
52#[derive(Debug)]
53pub struct RunnerStats {
54 pub step_cnt: usize,
55 pub step_cnt_la: usize,
56 pub total_step: usize,
57 pub acc_total_step: usize,
58}
59
60impl Default for RunnerStats {
61 fn default() -> Self {
62 Self::new()
63 }
64}
65
66impl RunnerStats {
67 pub fn new() -> RunnerStats {
68 RunnerStats {
69 step_cnt: 0,
70 step_cnt_la: 0,
71 total_step: 0,
72 acc_total_step: 0,
73 }
74 }
75
76 pub fn reset(&mut self) {
77 self.step_cnt = 0;
78 self.step_cnt_la = 0;
79 self.total_step = 0;
80 }
81
82 pub fn step(&mut self) {
83 self.step_cnt += 1;
84 self.total_step += 1;
85 self.acc_total_step += 1;
86 }
87
88 pub fn step_la(&mut self) {
89 self.step_cnt_la += 1;
90 self.total_step += 1;
91 self.acc_total_step += 1;
92 }
93
94 pub fn print_stat(&self) -> String {
95 format!(
96 "[STAT]: step = {}, step_la = {}(ratio {}), total = {}, acc_total = {} ",
97 self.step_cnt,
98 self.step_cnt_la,
99 (self.step_cnt_la as f32) / (self.step_cnt as f32 + 0.001),
100 self.total_step,
101 self.acc_total_step,
102 )
103 }
104}