From 552c8acada213b1ae61aeab202dc8cef17ccef57 Mon Sep 17 00:00:00 2001 From: Yirmandias Date: Mon, 22 Jan 2024 13:58:53 +0100 Subject: [PATCH] fix bug with conversion: declare parameters in define table to avoid race condition when converting in parallel two methods with same parameters label --- acting/core/src/model/sym_table/mod.rs | 44 +++++++++---- acting/core/src/model/sym_table/ref.rs | 10 ++- acting/core/src/model/sym_table/variable.rs | 7 +- acting/core/src/ompas/interface/stat.rs | 19 +++--- .../flow_graph/algo/post_processing.rs | 2 +- acting/core/src/planning/conversion/mod.rs | 14 +++- domains/gripper_door/base.scm | 4 -- domains/gripper_door/om.scm | 4 ++ domains/gripper_multi/base.scm | 4 +- domains/gripper_multi/om.scm | 13 ++-- stat/src/bin/main.rs | 6 +- stat/src/output/bar.rs | 64 +++++++++---------- stat/src/output/plot.rs | 9 ++- stat/src/stat/config.rs | 41 ++++++------ stat/src/stat/mod.rs | 8 +-- stat/src/stat/planning/mod.rs | 14 +++- stat/src/stat/system.rs | 4 +- stat/statos.bash | 4 +- 18 files changed, 159 insertions(+), 112 deletions(-) diff --git a/acting/core/src/model/sym_table/mod.rs b/acting/core/src/model/sym_table/mod.rs index 32c2e2d3..e7a539cb 100644 --- a/acting/core/src/model/sym_table/mod.rs +++ b/acting/core/src/model/sym_table/mod.rs @@ -226,31 +226,38 @@ impl SymTable { // New functions impl SymTable { - pub fn new_variable(&mut self, sym: impl Display, domain: impl Into) -> VarId { + pub fn new_variable( + &mut self, + symbol: impl Display, + label: impl Display, + domain: impl Into, + ) -> VarId { let domain_id = self.domains.new_node(VarDomain::new(domain)); - let id = self.variables.new_node(Variable::new(sym, domain_id)); + let id = self + .variables + .new_node(Variable::new(symbol, label, domain_id)); self.add_var_to_domain(domain_id, id); id } pub fn new_bool(&mut self, b: bool) -> VarId { - self.new_variable(b, b) + self.new_variable(b, b, b) } pub fn new_nil(&mut self) -> VarId { - self.new_variable(NIL, BasicType::Nil) + self.new_variable(NIL, NIL, BasicType::Nil) } pub fn new_err(&mut self) -> VarId { - self.new_variable(ERR, BasicType::Err) + self.new_variable(ERR, ERR, BasicType::Err) } pub fn new_int(&mut self, i: i64) -> VarId { - self.new_variable(i, i) + self.new_variable(i, i, i) } pub fn new_float(&mut self, f: f64) -> VarId { - self.new_variable(f, f) + self.new_variable(f, f, f) } pub fn new_number(&mut self, n: &LNumber) -> VarId { @@ -278,7 +285,7 @@ impl SymTable { pub fn new_result(&mut self) -> VarId { let index = self.meta_data.new_result_index(); let sym = format!("{RESULT_PREFIX}{index}"); - let id = self.new_variable(&sym, Domain::any()); + let id = self.new_variable(&sym, &sym, Domain::any()); self.ids.insert(&sym, &id); id } @@ -286,7 +293,7 @@ impl SymTable { pub fn new_timepoint(&mut self) -> VarId { let index = self.meta_data.new_timepoint_index(); let sym = format!("{TIMEPOINT_PREFIX}{index}"); - let id = self.new_variable(&sym, self.get_type_as_domain(TYPE_TIMEPOINT).unwrap()); + let id = self.new_variable(&sym, &sym, self.get_type_as_domain(TYPE_TIMEPOINT).unwrap()); self.ids.insert(&sym, &id); id } @@ -333,6 +340,7 @@ impl SymTable { let sym_if = &format!("{IF_PREFIX}{index}"); let id_if = self.new_variable( + sym_if, sym_if, Domain::Cst( Box::new(self.get_type_as_domain(TYPE_TASK).unwrap()), @@ -343,6 +351,7 @@ impl SymTable { let sym_m_true = &format!("m_{}_true", sym_if); let id_m_true = self.new_variable( + sym_m_true, sym_m_true, Domain::Cst( Box::new(self.get_type_as_domain(TYPE_METHOD).unwrap()), @@ -353,6 +362,7 @@ impl SymTable { let sym_m_false = &format!("m_{}_false", sym_if); let id_m_false = self.new_variable( + sym_m_false, sym_m_false, Domain::Cst( Box::new(self.get_type_as_domain(TYPE_METHOD).unwrap()), @@ -367,7 +377,7 @@ impl SymTable { pub fn new_handle(&mut self) -> VarId { let index = self.meta_data.new_handle_index(); let sym = &format!("{HANDLE_PREFIX}{index}"); - let id = self.new_variable(sym, Domain::composed(Handle as usize, vec![Any])); + let id = self.new_variable(sym, sym, Domain::composed(Handle as usize, vec![Any])); self.ids.insert(sym, &id); id } @@ -392,7 +402,7 @@ impl SymTable { pub fn new_arbitrary(&mut self) -> VarId { let index = self.meta_data.new_arbitrary_index(); let sym = &format!("{ARBITRARY_PREFIX}{index}"); - let id = self.new_variable(sym, Domain::any()); + let id = self.new_variable(sym, sym, Domain::any()); self.ids.insert(sym, &id); id } @@ -403,7 +413,7 @@ impl SymTable { self.get_sym_id(sym).unwrap() } else { let sym: &String = &sym.to_string(); - let id = self.new_variable(sym, sym.as_str()); + let id = self.new_variable(sym, sym, sym.as_str()); self.ids.insert(sym, &id); id } @@ -416,6 +426,7 @@ impl SymTable { } else { let sym: &String = &sym.to_string(); let id = self.new_variable( + sym, sym, Domain::Cst(Box::new(domain.into()), Cst::Symbol(sym.to_string())), ); @@ -432,11 +443,11 @@ impl SymTable { ) -> VarId { let symbol = symbol.to_string(); let version = self.ids.version(&symbol); - let sym = format!("{symbol}_{version}"); + let label = format!("{symbol}_{version}"); let domain_id = self.domains.new_node(VarDomain::new(domain)); let id = self .variables - .new_node(Variable::new_parameter(sym, domain_id)); + .new_node(Variable::new_parameter(&symbol, label, domain_id)); self.add_var_to_domain(domain_id, id); self.ids.insert(&symbol, &id); self.set_declaration(id, declaration); @@ -465,6 +476,7 @@ impl SymTable { domain: domain_id, parameter: variable.parameter, label: sym, + symbol: symbol.clone(), declaration: None, drop: None, }; @@ -518,6 +530,10 @@ impl SymTable { self.variables[id].label.as_str() } + pub fn get_symbol(&self, id: VarId) -> String { + self.variables[id].symbol.to_string() + } + pub fn get_domain_of_var(&mut self, v: VarId) -> &Domain { let domain_id = self.get_domain_id(v); self.get_domain(domain_id) diff --git a/acting/core/src/model/sym_table/ref.rs b/acting/core/src/model/sym_table/ref.rs index 54479bd5..f6bcff0a 100644 --- a/acting/core/src/model/sym_table/ref.rs +++ b/acting/core/src/model/sym_table/ref.rs @@ -122,6 +122,10 @@ impl RefSymTable { self.0.write().unwrap().get_label(id, parent).to_string() } + pub fn get_symbol(&self, id: VarId) -> String { + self.0.read().unwrap().get_symbol(id) + } + pub fn get_var_parent(&self, v: VarId) -> VarId { self.0.write().unwrap().get_var_parent(v) } @@ -225,7 +229,7 @@ impl RefSymTable { self.0.read().unwrap().union(d1, d2) } - pub fn substract(&self, d1: &Domain, d2: &Domain) -> Domain { + pub fn subtract(&self, d1: &Domain, d2: &Domain) -> Domain { self.0.read().unwrap().substract(d1, d2) } @@ -237,7 +241,7 @@ impl RefSymTable { self.0.write().unwrap().union_domains(id_d1, id_d2) } - pub fn substract_domains(&self, id_d1: DomainId, id_d2: DomainId) -> Domain { + pub fn subtract_domains(&self, id_d1: DomainId, id_d2: DomainId) -> Domain { self.0.write().unwrap().substract_domains(id_d1, id_d2) } @@ -245,7 +249,7 @@ impl RefSymTable { self.0.write().unwrap().meet_to_domain(id_d1, domain) } - pub fn substract_to_domain(&self, id_d1: DomainId, domain: impl Into) -> EmptyDomains { + pub fn subtract_to_domain(&self, id_d1: DomainId, domain: impl Into) -> EmptyDomains { self.0.write().unwrap().subtract_to_domain(id_d1, domain) } diff --git a/acting/core/src/model/sym_table/variable.rs b/acting/core/src/model/sym_table/variable.rs index 40559a96..46583aca 100644 --- a/acting/core/src/model/sym_table/variable.rs +++ b/acting/core/src/model/sym_table/variable.rs @@ -6,26 +6,29 @@ pub struct Variable { pub domain: DomainId, pub parameter: bool, pub label: String, + pub symbol: String, pub declaration: Option, pub drop: Option, } impl Variable { - pub fn new(label: impl Display, domain: DomainId) -> Self { + pub fn new(symbol: impl Display, label: impl Display, domain: DomainId) -> Self { Self { domain, parameter: false, label: label.to_string(), + symbol: symbol.to_string(), declaration: None, drop: None, } } - pub fn new_parameter(label: impl Display, domain: DomainId) -> Self { + pub fn new_parameter(symbol: impl Display, label: impl Display, domain: DomainId) -> Self { Self { domain, parameter: true, label: label.to_string(), + symbol: symbol.to_string(), declaration: None, drop: None, } diff --git a/acting/core/src/ompas/interface/stat.rs b/acting/core/src/ompas/interface/stat.rs index c2dc190c..2a37699e 100644 --- a/acting/core/src/ompas/interface/stat.rs +++ b/acting/core/src/ompas/interface/stat.rs @@ -3,13 +3,11 @@ use crate::ompas::manager::acting::inner::ActingProcessKind; use crate::ompas::manager::acting::interval::Duration; use crate::ompas::manager::acting::process::process_stat::ActingProcessStat; use crate::ompas::manager::planning::planner_stat::{PlannerStat, PlanningStatus}; -use crate::ompas::scheme::monitor::debug_continuous_planning::plan; use serde::{Deserialize, Serialize}; -use std::f64::NAN; #[derive(Default, Debug, Serialize, Deserialize)] pub struct OMPASRunData { - inner: Vec, + pub inner: Vec, } impl OMPASRunData { @@ -113,8 +111,9 @@ impl OMPASRunData { let mut i = 0; for stat in &self.inner { if let OMPASStat::Process(p) = stat { - deliberation_time += - p.deliberation_time.mean.as_secs() * p.deliberation_time.instance as f64; + deliberation_time += p.deliberation_time.mean.as_secs() + * p.deliberation_time.instance as f64 + / p.duration.as_secs(); i += 1; } } @@ -129,7 +128,6 @@ impl OMPASRunData { if pwt.is_nan() { pwt = 0.0; } - println!("twp {}", pwt); let instance = p.planning_waiting_time.instance as f64; planning_waiting_time += pwt * instance; } @@ -143,8 +141,13 @@ impl OMPASRunData { let mut i = 0; for stat in &self.inner { if let OMPASStat::Process(p) = stat { - planning_waiting_time += p.planning_waiting_time.mean.as_secs() - * p.planning_waiting_time.instance as f64; + let mut pwt = p.planning_waiting_time.mean.as_secs(); + if pwt.is_nan() { + pwt = 0.0; + } + let instance = p.planning_waiting_time.instance as f64; + planning_waiting_time += pwt * instance + / (p.deliberation_time.mean.as_secs() * (p.deliberation_time.instance as f64)); i += 1; } } diff --git a/acting/core/src/planning/conversion/flow_graph/algo/post_processing.rs b/acting/core/src/planning/conversion/flow_graph/algo/post_processing.rs index 2b79ccdb..c48e9b22 100644 --- a/acting/core/src/planning/conversion/flow_graph/algo/post_processing.rs +++ b/acting/core/src/planning/conversion/flow_graph/algo/post_processing.rs @@ -40,7 +40,7 @@ pub fn propagate( let id = st.get_var_parent(id); let domain_id = st.get_domain_id(id); //println!("Subtract({id}, {})", graph.sym_table.format_domain(&d)); - let emptys = st.substract_to_domain(domain_id, d); + let emptys = st.subtract_to_domain(domain_id, d); if let EmptyDomains::Some(emptys) = emptys { //println!("[Subtract] Domains of {:?} are empty.", emptys); for e in &emptys { diff --git a/acting/core/src/planning/conversion/mod.rs b/acting/core/src/planning/conversion/mod.rs index 6f8d27ed..b3d21458 100644 --- a/acting/core/src/planning/conversion/mod.rs +++ b/acting/core/src/planning/conversion/mod.rs @@ -14,6 +14,7 @@ use crate::planning::conversion::flow_graph::algo::p_eval::p_eval; use crate::planning::conversion::flow_graph::algo::p_eval::r#struct::PLEnv; use crate::planning::conversion::flow_graph::algo::post_processing::flow_graph_post_processing; use crate::planning::conversion::flow_graph::algo::pre_processing::pre_processing; +use crate::planning::conversion::flow_graph::define_table::DefineTable; use crate::planning::conversion::flow_graph::graph::FlowGraph; use crate::planning::planner::problem::PlanningDomain; use crate::{ChronicleDebug, OMPAS_CHRONICLE_DEBUG}; @@ -119,6 +120,16 @@ pub fn _convert( ) -> Result { let time = SystemTime::now(); let n_conversion = N_CONVERSION.fetch_add(1, Ordering::Relaxed); + let mut define_table: DefineTable = Default::default(); + if let Some(ch) = &ch { + for param in &ch.get_name()[1..] { + let sym = st.get_symbol(*param); + //if sym == "?r" { + println!("{sym}"); + //} + define_table.insert(sym, *param); + } + } let mut graph = FlowGraph::new(st); if OMPAS_CHRONICLE_DEBUG.get() >= ChronicleDebug::Full { @@ -128,7 +139,8 @@ pub fn _convert( lv.format(0) ); } - let flow = convert_lv(lv, &mut graph, &mut Default::default())?; + + let flow = convert_lv(lv, &mut graph, &mut define_table)?; graph.flow = flow; #[cfg(feature = "conversion_data")] diff --git a/domains/gripper_door/base.scm b/domains/gripper_door/base.scm index 27754845..273c6ece 100644 --- a/domains/gripper_door/base.scm +++ b/domains/gripper_door/base.scm @@ -14,10 +14,6 @@ (:params (?r1 room) (?d door) (?r2 room)) (:result boolean)) - (def-function min-distance - (:params (?r1 room) (?r2 room)) - (:result int)) - ; New commands (def-command move (:params (?from room) (?to room) (?d door))) (def-command-pddl-model move diff --git a/domains/gripper_door/om.scm b/domains/gripper_door/om.scm index 11462b13..c9606b7a 100644 --- a/domains/gripper_door/om.scm +++ b/domains/gripper_door/om.scm @@ -5,6 +5,10 @@ (load "../gripper/om.scm") (remove-method m_move) + (def-function min-distance + (:params (?r1 room) (?r2 room)) + (:result int)) + (def-method m_move (:task go2) (:params (?r room) (?a room) (?n room) (?d door)) diff --git a/domains/gripper_multi/base.scm b/domains/gripper_multi/base.scm index eaea94c6..01a2eca2 100644 --- a/domains/gripper_multi/base.scm +++ b/domains/gripper_multi/base.scm @@ -20,8 +20,8 @@ ; Additional state functions (remove-state-function at-robby) - (def-state-function at-rob (:params (?r robot)) (:result room)) - (def-state-function carry (:params (?r robot) (?g gripper)) (:result carriable)) + (def-state-function at-rob (:params (?ro robot)) (:result room)) + (def-state-function carry (:params (?ro robot) (?g gripper)) (:result carriable)) ; New commands (def-command move (:params (?r robot) (?from room) (?to room) (?d door))) diff --git a/domains/gripper_multi/om.scm b/domains/gripper_multi/om.scm index dd13d2c5..b1018322 100644 --- a/domains/gripper_multi/om.scm +++ b/domains/gripper_multi/om.scm @@ -1,5 +1,5 @@ (begin - (def-function gripper_of (:params (?r robot) (?g gripper)) (:result object)) + (def-function gripper_of (:params (?ro robot) (?g gripper)) (:result object)) (def-task go2 (:params (?ro robot) (?r room))) (def-method go2_noop @@ -60,8 +60,6 @@ (go2 ?ro ?r) (drop ?ro ?o ?r ?g)))) - - (def-task t_open (:params (?ro robot) (?d door) (?r room))) (def-method open_noop (:task t_open) @@ -71,7 +69,7 @@ (def-method open_direct (:task t_open) - (:params (?ro robot) (?d door) (?r room) (?g gripper)) + (:params (?ro robot) (?d door) (?r room) (?g gripper)) (:pre-conditions (! (opened ?d)) (= (carry ?ro ?g) empty) @@ -81,6 +79,13 @@ (go2 ?ro ?r) (open ?ro ?d ?r ?g)))) +; (def-task test (?ro robot) (?r room)) +; (def-method m_test +; (:params (?ro robot) (?r room)) +; (:pre-conditions ) +; (:body nil)) + + (def-method drop_and_open (:task t_open) (:params (?ro robot) (?d door) (?r room)) diff --git a/stat/src/bin/main.rs b/stat/src/bin/main.rs index b51b4c84..ab12f122 100644 --- a/stat/src/bin/main.rs +++ b/stat/src/bin/main.rs @@ -1,7 +1,7 @@ use ompas_stat::stat::system::SystemRunData; use ompas_stat::statos_config::StatosConfig; use std::fs; -use std::fs::OpenOptions; +use std::fs::{File, OpenOptions}; use std::io::Write; use std::path::PathBuf; use std::time::SystemTime; @@ -132,9 +132,11 @@ pub fn main() { let latex = formatter.to_latex(); let path: PathBuf = format!("{}{}", output_dir.display(), latex_output.display()).into(); - let path = path.canonicalize().unwrap(); + println!("path: {}", path.display()); + //let path = path.canonicalize().unwrap(); //let path = latex_output; println!("path: {}", path.display()); + let _ = File::create(&path).unwrap(); let mut file = OpenOptions::new() .create(true) .write(true) diff --git a/stat/src/output/bar.rs b/stat/src/output/bar.rs index 1b518b3a..0c04452c 100644 --- a/stat/src/output/bar.rs +++ b/stat/src/output/bar.rs @@ -33,10 +33,10 @@ impl Bar { let instance_run_data = run .inner .get(&problem_name) - .unwrap() + .unwrap_or_else(|| panic!("Missing problem {problem_name} in data.")) .inner .get(&instance_name) - .unwrap(); + .unwrap_or_else(|| panic!("Missing instance {instance_name} in data.")); let stat = instance_run_data.get_stat(); let mut dat = "Config".to_string(); for field in &self.fields { @@ -47,45 +47,40 @@ impl Bar { let mut x_tick_labels = "{".to_string(); let mut y_min: f64 = 0.0; let mut y_max: f64 = 0.0; - for (i, (config_name, config_stat)) in stat - .inner - .iter() - .filter(|(name, _)| { - let name = name.to_string(); - for c in &self.configs { - if name.contains(c) { - return true; - } + let mut i = 0; + for config in &self.configs { + 'loop_config: for (config_name, config_stat) in &stat.inner { + if !config_name.to_string().contains(config) { + continue 'loop_config; } - false - }) - .enumerate() - { - if i > 0 { - x_tick.push(','); - x_tick_labels.push(','); - } - write!(x_tick, "{}", i).unwrap(); - write!(x_tick_labels, "{}", config_name.format()).unwrap(); - write!(dat, "{}", i).unwrap(); - for field in &self.fields { - if let Some(stat) = config_stat.get(&field) { - write!(dat, " {} {}", stat.mean, stat.se).unwrap(); - y_min = y_min.min(stat.mean - stat.se); - y_max = y_max.max(stat.mean + stat.se); - } else { - write!(dat, " 0 0").unwrap(); + if i > 0 { + x_tick.push(','); + x_tick_labels.push(','); } + write!(x_tick, "{}", i).unwrap(); + write!(x_tick_labels, "{}", config_name.format()).unwrap(); + write!(dat, "{}", i).unwrap(); + for field in &self.fields { + if let Some(stat) = config_stat.get(&field) { + write!(dat, " {} {}", stat.mean, stat.se).unwrap(); + y_min = y_min.min(stat.mean - stat.se); + y_max = y_max.max(stat.mean + stat.se); + } else { + write!(dat, " 0 0").unwrap(); + } + } + dat.push('\n'); + i += 1; } - dat.push('\n'); } + x_tick.push('}'); x_tick_labels.push('}'); y_min *= 1.1; y_max *= 1.2; let x_label = "Configuration"; - let y_label = self.fields[0].to_string(); + let y_label = format!("{} ({})", self.fields[0].to_latex(), self.fields[0].unit()); let mut tex = format!( "\ @@ -120,13 +115,14 @@ impl Bar { legend style={{font = \\footnotesize}}, ]" ); - - for field in &self.fields { + let bar_start: i64 = -6 * (self.fields.len() as i64 - 1); + for (i, field) in self.fields.iter().enumerate() { + let bar_shift = bar_start + i as i64 * 12; write!( tex, " \\addplot+[ - bar shift = 0pt, + bar shift = {bar_shift}pt, error bars/.cd, y dir=both, y explicit diff --git a/stat/src/output/plot.rs b/stat/src/output/plot.rs index cc8f8cf0..b22ad557 100644 --- a/stat/src/output/plot.rs +++ b/stat/src/output/plot.rs @@ -38,10 +38,10 @@ impl Plot { let instance_run_data = run .inner .get(&problem_name) - .unwrap() + .unwrap_or_else(|| panic!("Missing problem {problem_name} in data.")) .inner .get(&instance_name) - .unwrap(); + .unwrap_or_else(|| panic!("Missing instance {instance_name} in data.")); let stat = instance_run_data.get_planning_stat(); let mut instance = 0; @@ -108,7 +108,7 @@ impl Plot { x_tick.push('}'); let x_label = "Instance"; - let y_label = "Time (s)"; + let y_label = format!("{} ({})", self.fields[0].to_latex(), self.fields[0].unit()); let mut tex = format!( "\ @@ -155,13 +155,12 @@ impl Plot { x=Instance, y={}, y error={}E]{{{}}}; - \\addlegendentry{{{}\\_{}}} + \\addlegendentry{{{}}} ", field, field, dat.path.display(), dat.name, - field.to_latex(), ) .unwrap(); } diff --git a/stat/src/stat/config.rs b/stat/src/stat/config.rs index 4e095a6b..3cecfbe3 100644 --- a/stat/src/stat/config.rs +++ b/stat/src/stat/config.rs @@ -3,7 +3,7 @@ use crate::stat::planning::{ConfigPlanningStat, PlanningField}; use crate::stat::Field; use crate::stat::Field::*; use crate::stat::Stat; -use ompas_core::ompas::interface::stat::OMPASRunData; +use ompas_core::ompas::interface::stat::{OMPASRunData, OMPASStat}; use ompas_core::ompas::manager::acting::inner::ActingProcessKind; use std::collections::HashMap; use std::fmt::Write; @@ -18,15 +18,15 @@ pub struct ConfigName { impl ConfigName { pub fn format(&self) -> String { - let mut default = match self.select_heuristic.as_str() { + let default = match self.select_heuristic.as_str() { "random" => "R".to_string(), "upom" => "U".to_string(), "aries" => "A".to_string(), + "cost" => "C".to_string(), + "greedy" => "G".to_string(), t => t.to_string(), }; - for o in &self.other { - write!(default, "+{}", o).unwrap(); - } + let continuous_planning = match self.continuous_planning_config.as_str() { "satisfactory" => "Sat", "optimality" => "Opt", @@ -59,7 +59,14 @@ pub struct ConfigRunData { } impl ConfigRunData { - pub fn add_run(&mut self, run_stat: OMPASRunData) { + pub fn add_run(&mut self, mut run_stat: OMPASRunData) { + run_stat.inner.retain(|stat| { + if let OMPASStat::Process(p) = stat { + !p.label.contains("charge") + } else { + true + } + }); self.inner.push(run_stat); } @@ -248,12 +255,7 @@ impl ConfigRunData { } fn get_deliberation_time_ratio_stat(&self) -> Stat { - let ratios: Vec = self - .inner - .iter() - .map(|run| run.get_deliberation_time_ratio()) - .collect(); - Stat::from(ratios.as_slice()) * Stat::new(100.0) + self.get_deliberation_time_stat() * Stat::new(100.0) / self.get_execution_time_stat() } fn get_planning_waiting_time_stat(&self) -> Stat { @@ -263,17 +265,11 @@ impl ConfigRunData { .map(|run| run.get_planning_waiting_time()) .collect(); let stat: Stat = times.as_slice().into(); - //println!("TWP = {}", stat.mean); stat } fn get_planning_waiting_time_ratio_stat(&self) -> Stat { - let times: Vec = self - .inner - .iter() - .map(|run| run.get_planning_waiting_time_ratio()) - .collect(); - Stat::from(times.as_slice()) * Stat::new(100.0) + self.get_planning_waiting_time_stat() * Stat::new(100.0) / self.get_deliberation_time_stat() } fn get_planning_time_stat(&self) -> Stat { @@ -389,7 +385,11 @@ impl ConfigProblemStat { let mut cells = vec![]; let last = fields.len() - 1; for (i, field) in fields.iter().enumerate() { - let info = format!("{}({})", field.to_latex(), field.unit_short()); + let mut info = field.to_latex(); + let unit = field.unit_short(); + if unit != "" { + write!(info, "({})", unit).unwrap(); + } if i == last { cells.push(Cell::double(info)) } else { @@ -440,7 +440,6 @@ impl From<&[ConfigInstanceStat]> for ConfigProblemStat { } } let new_stat = new_stat / Stat::new(i); - //println!("{}: {}", field, new_stat.mean); config_problem_stat.stat_map.insert(*field, new_stat); } diff --git a/stat/src/stat/mod.rs b/stat/src/stat/mod.rs index c4b63ee6..dc84f44c 100644 --- a/stat/src/stat/mod.rs +++ b/stat/src/stat/mod.rs @@ -206,7 +206,7 @@ pub const NUMBER_RETRIES: &str = "NR"; pub const NUMBER_FAILURES: &str = "NF"; pub const DISTANCE_TO_BEST_SCORE: &str = "DBES"; pub const BEST_SCORE_RATIO: &str = "RBES"; -pub const PLANNING_TIME: &str = "PT"; +pub const PLANNING_TIME: &str = "TP"; pub const PLANNING_TIME_RATIO: &str = "PTR"; pub const NUMBER_PLANNING_INSTANCE: &str = "N_{PI}"; pub const AVERAGE_PLANNING_TIME: &str = "APT"; @@ -231,9 +231,9 @@ impl Field { DeliberationTime => "$T_D$", DeliberationTimeRatio => "$RT_D$", Coverage => "\\textit{{Cov}}", - EfficiencyScore => "$E_S$", - BestScoreRatio => "$RE_S^{{*}}$", - DistanceToBestScore => "$DE^{*}_S$", + EfficiencyScore => "$\\hat{E_S}$", + BestScoreRatio => "$\\hat{RE_S^{*}}$", + DistanceToBestScore => "$\\hat{DE^{*}_S}$", NumberRetries => "$N_R$", NumberFailures => "N_F", PlanningWaitingTime => "$T_{WP}$", diff --git a/stat/src/stat/planning/mod.rs b/stat/src/stat/planning/mod.rs index fe0cb7ee..c4917f5e 100644 --- a/stat/src/stat/planning/mod.rs +++ b/stat/src/stat/planning/mod.rs @@ -14,6 +14,14 @@ impl PlanningField { pub fn to_latex(&self) -> String { format!("${}$", self) } + pub fn unit(&self) -> String { + match self { + PlanningField::PlanningTimes => "seconds", + PlanningField::PlanningSolutions => "", + PlanningField::PlanningSuccesses => "percentage", + } + .to_string() + } } impl Display for PlanningField { @@ -23,13 +31,13 @@ impl Display for PlanningField { "{}", match self { PlanningField::PlanningTimes => { - "PT" + "T_P" } PlanningField::PlanningSolutions => { - "PS" + "S_P" } PlanningField::PlanningSuccesses => { - "PSR" + "Cov_P" } } ) diff --git a/stat/src/stat/system.rs b/stat/src/stat/system.rs index 7ff23fd0..00c0070d 100644 --- a/stat/src/stat/system.rs +++ b/stat/src/stat/system.rs @@ -39,7 +39,7 @@ impl SystemRunData { if let Some(escapes) = &input_dir.escapes { for escape in escapes { if format!("{}", file.display()).contains(escape) { - println!("escape file: {}", file.display()); + //println!("escape file: {}", file.display()); continue 'loop_file; } } @@ -51,7 +51,7 @@ impl SystemRunData { if let Some(escapes) = &input_dir.escapes { for escape in escapes { if format!("{}", file.display()).contains(escape) { - println!("escape file: {}", file.display()); + //println!("escape file: {}", file.display()); continue 'loop_file; } } diff --git a/stat/statos.bash b/stat/statos.bash index b10dd361..4381fec1 100644 --- a/stat/statos.bash +++ b/stat/statos.bash @@ -1,3 +1,3 @@ #cargo run --bin statos -- -c config_gobot_sim.yml -#cargo run --bin statos -- -c config_gobot_sim_2.yml -cargo run --bin statos -- -c config_gripper_door.yml \ No newline at end of file +#cargo run --bin statos -- -c config_gripper_door.yml +cargo run --bin statos -- -c config_gripper_multi.yml \ No newline at end of file