Skip to content

Commit

Permalink
wip: improve statos
Browse files Browse the repository at this point in the history
  • Loading branch information
Yirmandias committed Dec 11, 2023
1 parent 8434232 commit 8aad586
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 162 deletions.
29 changes: 25 additions & 4 deletions acting/core/src/ompas/interface/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ impl OMPASRunData {
max_end.unwrap() - min_start.unwrap()
}

pub fn get_deliberation_time(&self) -> f64 {
let mut deliberation_time = 0.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
}

pub fn get_deliberation_time_ratio(&self) -> f64 {
let mut deliberation_time = 0.0;
let mut i = 0;
Expand All @@ -60,7 +71,7 @@ impl OMPASRunData {
deliberation_time / i as f64
}

pub fn get_success_rate(&self) -> f64 {
pub fn get_coverage(&self) -> f64 {
let mut success = 0;
let mut i = 0;
for stat in &self.inner {
Expand All @@ -75,15 +86,25 @@ impl OMPASRunData {
}

pub fn get_n_failures(&self) -> u32 {
let mut n_failure = 0;
let mut n_failures = 0;
for stat in &self.inner {
if let OMPASStat::Process(p) = stat {
n_failures += p.n_failure;
}
}
n_failures
}

pub fn get_n_retries(&self) -> u32 {
let mut n_retries = 0;
for stat in &self.inner {
if let OMPASStat::Process(p) = stat {
if p.status.is_failed() {
n_failure += 1;
n_retries += p.n_retry;
}
}
}
n_failure
n_retries
}
}

Expand Down
14 changes: 0 additions & 14 deletions domains/gripper/om.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@
(release res_g)
)))

(def-method pick_and_drop_debug
(:task place)
(:params (?o carriable) (?r room) (?g gripper) (?p room))
(:pre-conditions (!= ?p ?r) (= (pos ?o) ?p))
(:body
(do
(define rh (acquire 'robby))
(go2 ?a)
(pick ?o ?p ?g)
(go2 ?r)
(drop ?o ?r ?g)
)))


(def-method move_and_drop
(:task place)
(:params (?o carriable) (?r room) (?g gripper))
Expand Down
34 changes: 24 additions & 10 deletions stat/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ompas_stat::config::StatosConfig;
use ompas_stat::stat::system::{SystemRunData, SystemStatFormatter};
use ompas_stat::statos_config::StatosConfig;
use std::fs;
use std::fs::OpenOptions;
use std::io::Write;
Expand Down Expand Up @@ -27,7 +27,7 @@ pub fn main() {
println!("config: {:?}", config);

for config in config.configs {
let system_run = SystemRunData::new(&config.input_dir);
let system_run = SystemRunData::new(&config.input_dir, config.clone());

let time = SystemTime::now();
let stat = system_run.compute_stat();
Expand All @@ -40,14 +40,28 @@ pub fn main() {

println!("{}", formatter);

let csv = formatter.to_csv();
if let Some(csv_output) = config.csv_output {
let csv = formatter.to_csv();

let mut file = OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(&config.output_file)
.unwrap();
file.write_all(csv.as_bytes()).unwrap();
let mut file = OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(&csv_output)
.unwrap();
file.write_all(csv.as_bytes()).unwrap();
}

if let Some(latex_output) = config.latex_output {
let csv = formatter.to_latex();

let mut file = OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(&latex_output)
.unwrap();
file.write_all(csv.as_bytes()).unwrap();
}
}
}
13 changes: 0 additions & 13 deletions stat/src/config.rs

This file was deleted.

2 changes: 1 addition & 1 deletion stat/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod config;
pub mod stat;
pub mod statos_config;
Loading

0 comments on commit 8aad586

Please sign in to comment.