Skip to content

Commit

Permalink
Add initial implementation of ControlComputation.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Sep 7, 2024
1 parent aa3d6f8 commit 3b2f0eb
Show file tree
Hide file tree
Showing 6 changed files with 574 additions and 445 deletions.
2 changes: 2 additions & 0 deletions .cargo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore the actual `cargo/config.toml`. You should pick one of the pre-defined values for your current machine.
config.toml
5 changes: 5 additions & 0 deletions .cargo/config-macos-dev.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[env]
Z3_SYS_Z3_HEADER="/opt/homebrew/include/z3.h"

[build]
rustflags=["-C", "link-args=-L/opt/homebrew/lib"]
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ futures = "0.3.30"
tokio = "1.40.0"
fixed-map = "0.9.5"
lazy_static = "1.5.0"
biodivine-pbn-control = { git = "https://github.com/sybila/biodivine-pbn-control", rev = "99f9da756c370daf5428b3d61ef76c24e7d8de5f" }

[dev-dependencies]
31 changes: 31 additions & 0 deletions src/control.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use biodivine_pbn_control::control::PhenotypeControlMap;
use biodivine_pbn_control::perturbation::PerturbationGraph;
use std::sync::Arc;
use std::thread::JoinHandle;
use std::time::{SystemTime, UNIX_EPOCH};

pub struct ControlComputation {
pub timestamp: SystemTime,
pub finished_timestamp: Option<SystemTime>,
pub input_model: String,
pub graph: Arc<PerturbationGraph>,
pub thread: Option<JoinHandle<()>>,
pub results: Option<PhenotypeControlMap>,
}

impl ControlComputation {
pub fn start_timestamp(&self) -> u128 {
self.timestamp
.duration_since(UNIX_EPOCH)
.expect("Time error")
.as_millis()
}

pub fn end_timestamp(&self) -> Option<u128> {
self.finished_timestamp.map(|t| {
t.duration_since(UNIX_EPOCH)
.expect("Time error")
.as_millis()
})
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::sync::atomic::AtomicBool;
pub mod algorithms;

pub mod bdt;
pub mod control;
pub mod scc;
/// Some utility methods which we can later move to std-lib
pub mod util;
Expand Down
Loading

0 comments on commit 3b2f0eb

Please sign in to comment.