diff --git a/Cargo.toml b/Cargo.toml index ab348a5..79b6822 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,8 +16,7 @@ debug = true #lto = true [dependencies] -biodivine-lib-std = { git = "https://github.com/sybila/biodivine-lib-std.git" } -biodivine-lib-param-bn = { git = "https://github.com/sybila/biodivine-lib-param-bn.git", tag = "v0.1.0-beta.2" } +biodivine-lib-param-bn = "0.1.0" rocket = "0.4.6" rayon = "1.5.0" crossbeam = "0.8.0" diff --git a/src/bin/benchmark_filter.rs b/src/bin/benchmark_filter.rs index 4e5bbb2..fe95165 100644 --- a/src/bin/benchmark_filter.rs +++ b/src/bin/benchmark_filter.rs @@ -18,7 +18,7 @@ fn main() { let model_path = bench_dir.path().join("model.sbml"); let model_string = std::fs::read_to_string(model_path).unwrap(); - let (sbml_model, _) = BooleanNetwork::from_sbml(&model_string).unwrap(); + let (sbml_model, _) = BooleanNetwork::try_from_sbml(&model_string).unwrap(); let model = erase_regulation_bounds(&sbml_model); let bench_name = bench_dir.file_name().to_str().unwrap().to_string(); diff --git a/src/bin/benchmark_validator.rs b/src/bin/benchmark_validator.rs index 79e3e7b..c64f21f 100644 --- a/src/bin/benchmark_validator.rs +++ b/src/bin/benchmark_validator.rs @@ -32,7 +32,7 @@ fn main() { } else { // Check that the sbml model is readable: let model_string = std::fs::read_to_string(sbml_model_path).unwrap(); - let model = BooleanNetwork::from_sbml(&model_string); + let model = BooleanNetwork::try_from_sbml(&model_string); match model { Err(err) => { errors += 1; diff --git a/src/bin/experiment.rs b/src/bin/experiment.rs index a77c963..5ad5f36 100644 --- a/src/bin/experiment.rs +++ b/src/bin/experiment.rs @@ -34,7 +34,7 @@ fn main() { ); println!( "State space: {}", - graph.unit_vertices().approx_cardinality() + graph.unit_colored_vertices().approx_cardinality() ); let classifier = Classifier::new(&graph); @@ -44,8 +44,11 @@ fn main() { // Now we can actually start the computation... // First, perform ITGR reduction. - let (universe, active_variables) = - interleaved_transition_guided_reduction(&task_context, &graph, graph.mk_unit_vertices()); + let (universe, active_variables) = interleaved_transition_guided_reduction( + &task_context, + &graph, + graph.mk_unit_colored_vertices(), + ); // Then run Xie-Beerel to actually detect the components. xie_beerel_attractors( diff --git a/src/bin/rbn_generator.rs b/src/bin/rbn_generator.rs index 5820cca..d2b2137 100644 --- a/src/bin/rbn_generator.rs +++ b/src/bin/rbn_generator.rs @@ -90,7 +90,10 @@ fn main() { let source = random.gen_range(0..V_COUNT); let target = random.gen_range(0..V_COUNT); if rg - .find_regulation(VariableId::from(source), VariableId::from(target)) + .find_regulation( + VariableId::try_from_usize(&rg, source).unwrap(), + VariableId::try_from_usize(&rg, target).unwrap(), + ) .is_none() { let monotonicity = if random.gen_bool(0.7) { diff --git a/src/main.rs b/src/main.rs index 8970987..5c7304a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,8 +21,9 @@ use std::convert::TryFrom; use biodivine_aeon_server::scc::algo_interleaved_transition_guided_reduction::interleaved_transition_guided_reduction; use biodivine_aeon_server::scc::algo_xie_beerel::xie_beerel_attractors; use biodivine_aeon_server::GraphTaskContext; +use biodivine_lib_param_bn::biodivine_std::bitvector::{ArrayBitVector, BitVector}; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColors, SymbolicAsyncGraph}; -use biodivine_lib_std::collections::bitvectors::{ArrayBitVector, BitVector}; use rocket::config::Environment; use rocket::{Config, Data}; use std::cmp::max; @@ -379,14 +380,14 @@ fn get_attractors(class_str: String) -> BackendResponse { let mut state_0 = ArrayBitVector::from(vec![ false; - graph.network().num_vars() + graph.as_network().num_vars() ]); let mut state_1 = ArrayBitVector::from(vec![ true; - graph.network().num_vars() + graph.as_network().num_vars() ]); - for var in graph.network().variables() { + for var in graph.as_network().variables() { let var_true = witness_graph .fix_network_variable(var, true) .vertices(); @@ -409,7 +410,7 @@ fn get_attractors(class_str: String) -> BackendResponse { for source in attractor.materialize().iter() { let source_set = witness_graph.vertex(&source); let mut target_set = witness_graph.mk_empty_vertices(); - for v in witness_graph.network().variables() { + for v in witness_graph.as_network().variables() { let post = witness_graph.var_post(v, &source_set); if !post.is_empty() { not_fixed_vars.insert(v.into()); @@ -575,7 +576,7 @@ fn start_computation(data: Data) -> BackendResponse { interleaved_transition_guided_reduction( task_context, &graph, - graph.mk_unit_vertices(), + graph.mk_unit_colored_vertices(), ); // Then run Xie-Beerel to actually detect the components. @@ -687,7 +688,7 @@ fn sbml_to_aeon(data: Data) -> BackendResponse { let mut sbml_string = String::new(); match stream.read_to_string(&mut sbml_string) { Ok(_) => { - match BooleanNetwork::from_sbml(&sbml_string) { + match BooleanNetwork::try_from_sbml(&sbml_string) { Ok((model, layout)) => { let mut model_string = format!("{}", model); // convert back to aeon model_string += "\n"; @@ -748,7 +749,7 @@ fn aeon_to_sbml(data: Data) -> BackendResponse { Ok(_) => match BooleanNetwork::try_from(aeon_string.as_str()) { Ok(network) => { let layout = read_layout(&aeon_string); - let sbml_string = network.to_sbml(&layout); + let sbml_string = network.to_sbml(Some(&layout)); BackendResponse::ok(&object! { "model" => sbml_string }.to_string()) } Err(error) => BackendResponse::err(&error), @@ -771,7 +772,7 @@ fn aeon_to_sbml_instantiated(data: Data) -> BackendResponse { let witness = graph.pick_witness(graph.unit_colors()); let layout = read_layout(&aeon_string); BackendResponse::ok( - &object! { "model" => witness.to_sbml(&layout) }.to_string(), + &object! { "model" => witness.to_sbml(Some(&layout)) }.to_string(), ) } Err(error) => BackendResponse::err(&error), diff --git a/src/scc/_impl_classifier.rs b/src/scc/_impl_classifier.rs index cfb0295..ee6d804 100644 --- a/src/scc/_impl_classifier.rs +++ b/src/scc/_impl_classifier.rs @@ -1,8 +1,8 @@ use super::{Behaviour, Class, Classifier}; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{ GraphColoredVertices, GraphColors, GraphVertices, SymbolicAsyncGraph, }; -use biodivine_lib_std::param_graph::Params; use std::collections::HashMap; use std::sync::Mutex; @@ -104,9 +104,9 @@ impl Classifier { } if !not_sink_params.is_empty() { let mut disorder = graph.mk_empty_colors(); - for variable in graph.network().variables() { + for variable in graph.as_network().variables() { let found_first_successor = &graph.var_can_post(variable, &without_sinks); - for next_variable in graph.network().variables() { + for next_variable in graph.as_network().variables() { if next_variable == variable { continue; } @@ -179,7 +179,7 @@ impl Classifier { graph: &SymbolicAsyncGraph, ) -> GraphColoredVertices { let mut is_not_sink = graph.empty_vertices().clone(); - for variable in graph.network().variables() { + for variable in graph.as_network().variables() { let has_successor = &graph.var_can_post(variable, &component); if !has_successor.is_empty() { is_not_sink = is_not_sink.union(has_successor); diff --git a/src/scc/_impl_progress_tracker.rs b/src/scc/_impl_progress_tracker.rs index 74cf966..d2e11b1 100644 --- a/src/scc/_impl_progress_tracker.rs +++ b/src/scc/_impl_progress_tracker.rs @@ -21,7 +21,7 @@ impl ProgressTracker { /// Restart progress counter with given graph. pub fn init_from_graph(&self, graph: &SymbolicAsyncGraph) { - let all_states = graph.unit_vertices().approx_cardinality(); + let all_states = graph.unit_colored_vertices().approx_cardinality(); let mut total = self.total.lock().unwrap(); *total = all_states; let mut remaining = self.remaining.lock().unwrap(); diff --git a/src/scc/algo_interleaved_transition_guided_reduction/_impl_extended_component_process.rs b/src/scc/algo_interleaved_transition_guided_reduction/_impl_extended_component_process.rs index e358ccb..786de4a 100644 --- a/src/scc/algo_interleaved_transition_guided_reduction/_impl_extended_component_process.rs +++ b/src/scc/algo_interleaved_transition_guided_reduction/_impl_extended_component_process.rs @@ -2,6 +2,7 @@ use crate::scc::algo_interleaved_transition_guided_reduction::{ BwdProcess, ExtendedComponentProcess, Process, Scheduler, }; use crate::scc::algo_saturated_reachability::reach_bwd; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph}; use biodivine_lib_param_bn::VariableId; diff --git a/src/scc/algo_interleaved_transition_guided_reduction/_impl_fwd_bwd_process.rs b/src/scc/algo_interleaved_transition_guided_reduction/_impl_fwd_bwd_process.rs index f12556e..0cf6954 100644 --- a/src/scc/algo_interleaved_transition_guided_reduction/_impl_fwd_bwd_process.rs +++ b/src/scc/algo_interleaved_transition_guided_reduction/_impl_fwd_bwd_process.rs @@ -2,6 +2,7 @@ use crate::scc::algo_interleaved_transition_guided_reduction::{ BwdProcess, FwdProcess, Process, Scheduler, }; use crate::scc::algo_saturated_reachability::reachability_step; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph}; impl BwdProcess { diff --git a/src/scc/algo_interleaved_transition_guided_reduction/_impl_reachable_process.rs b/src/scc/algo_interleaved_transition_guided_reduction/_impl_reachable_process.rs index 2b54685..6aaa23f 100644 --- a/src/scc/algo_interleaved_transition_guided_reduction/_impl_reachable_process.rs +++ b/src/scc/algo_interleaved_transition_guided_reduction/_impl_reachable_process.rs @@ -2,6 +2,7 @@ use crate::scc::algo_interleaved_transition_guided_reduction::{ ExtendedComponentProcess, FwdProcess, Process, ReachableProcess, Scheduler, }; use crate::scc::algo_saturated_reachability::reach_bwd; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph}; use biodivine_lib_param_bn::VariableId; diff --git a/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs b/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs index 9759cb6..b5a3d92 100644 --- a/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs +++ b/src/scc/algo_interleaved_transition_guided_reduction/_impl_scheduler.rs @@ -1,5 +1,6 @@ use crate::scc::algo_interleaved_transition_guided_reduction::{Process, Scheduler}; use crate::GraphTaskContext; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph}; use biodivine_lib_param_bn::VariableId; diff --git a/src/scc/algo_interleaved_transition_guided_reduction/mod.rs b/src/scc/algo_interleaved_transition_guided_reduction/mod.rs index a2603e5..25e6dac 100644 --- a/src/scc/algo_interleaved_transition_guided_reduction/mod.rs +++ b/src/scc/algo_interleaved_transition_guided_reduction/mod.rs @@ -27,16 +27,16 @@ pub fn interleaved_transition_guided_reduction( graph: &SymbolicAsyncGraph, initial: GraphColoredVertices, ) -> (GraphColoredVertices, Vec) { - let variables = graph.network().variables().collect::>(); + let variables = graph.as_network().variables().collect::>(); let mut scheduler = Scheduler::new(ctx, initial, variables); - for variable in graph.network().variables() { + for variable in graph.as_network().variables() { scheduler.spawn(ReachableProcess::new( variable, graph, scheduler.get_universe().clone(), )); } - let process_count = u32::try_from(graph.network().num_vars() * 2).unwrap(); + let process_count = u32::try_from(graph.as_network().num_vars() * 2).unwrap(); ctx.progress.set_process_count(process_count); // * 2 because each will spawn one extra. while !scheduler.is_done() { diff --git a/src/scc/algo_saturated_reachability/mod.rs b/src/scc/algo_saturated_reachability/mod.rs index 700bfa1..ed03f83 100644 --- a/src/scc/algo_saturated_reachability/mod.rs +++ b/src/scc/algo_saturated_reachability/mod.rs @@ -1,4 +1,5 @@ use crate::GraphTaskContext; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph}; use biodivine_lib_param_bn::VariableId; diff --git a/src/scc/algo_xie_beerel/mod.rs b/src/scc/algo_xie_beerel/mod.rs index 57dc913..1b0ebe2 100644 --- a/src/scc/algo_xie_beerel/mod.rs +++ b/src/scc/algo_xie_beerel/mod.rs @@ -1,5 +1,6 @@ use crate::scc::algo_saturated_reachability::{reach_bwd, reachability_step}; use crate::GraphTaskContext; +use biodivine_lib_param_bn::biodivine_std::traits::Set; use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph}; use biodivine_lib_param_bn::VariableId;