Skip to content

Commit

Permalink
Update lib-param-bn and fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Dec 15, 2020
1 parent 5f89cf0 commit f05fc65
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ debug = 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", rev = "e42fc0b2dab8be4bca09e82d6fdd11768808c804" }
biodivine-lib-param-bn = { git = "https://github.com/sybila/biodivine-lib-param-bn.git", tag = "v0.1.0-beta.1" }
rocket = "0.4.6"
rayon = "1.5.0"
crossbeam = "0.8.0"
Expand Down
12 changes: 4 additions & 8 deletions src/bin/benchmark_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,9 @@ fn main() {
match model {
Ok(mut model) => {
// Check that basic properties match SBML model. But note that variables can be re-ordered...
let mut models_match =
model.num_vars() == sbml_model.num_vars();
let mut models_match = model.num_vars() == sbml_model.num_vars();
if model.num_vars() != sbml_model.num_vars() {
eprintln!(
"{} != {}",
model.num_vars(),
sbml_model.num_vars()
);
eprintln!("{} != {}", model.num_vars(), sbml_model.num_vars());
}
for v in model.variables() {
let regulators_in_model: HashSet<String> = model
Expand All @@ -77,7 +72,8 @@ fn main() {
.collect();
let regulators_in_sbml_model: HashSet<String> = sbml_model
.regulators(
sbml_model.as_graph()
sbml_model
.as_graph()
.find_variable(model.get_variable_name(v))
.unwrap(),
)
Expand Down
12 changes: 9 additions & 3 deletions src/bin/experiment.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use biodivine_aeon_server::scc::algo_symbolic_components::{components_2};
use biodivine_aeon_server::scc::algo_symbolic_components::components_2;
use biodivine_aeon_server::scc::{Classifier, ProgressTracker};
use biodivine_lib_param_bn::symbolic_async_graph::SymbolicAsyncGraph;
use biodivine_lib_param_bn::BooleanNetwork;
Expand All @@ -16,7 +16,10 @@ fn main() {
.as_millis();

let model = BooleanNetwork::try_from(buffer.as_str()).unwrap();
let names: Vec<_> = model.variables().map(|id| model.get_variable_name(id)).collect();
let names: Vec<_> = model
.variables()
.map(|id| model.get_variable_name(id))
.collect();
println!("Model loaded...");
println!("{} variables: {:?}", model.num_vars(), names);

Expand All @@ -27,7 +30,10 @@ fn main() {
"Admissible parametrisations: {}",
graph.unit_colors().approx_cardinality()
);
println!("State space: {}", graph.unit_vertices().approx_cardinality());
println!(
"State space: {}",
graph.unit_vertices().approx_cardinality()
);

let classifier = Classifier::new(&graph);
let progress = ProgressTracker::new(&graph);
Expand Down
21 changes: 14 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,13 @@ fn get_results() -> BackendResponse {
};
let lines: Vec<String> = data
.iter()
.map(|(c, p)| format!("{{\"sat_count\":{},\"phenotype\":{}}}", p.approx_cardinality(), c))
.map(|(c, p)| {
format!(
"{{\"sat_count\":{},\"phenotype\":{}}}",
p.approx_cardinality(),
c
)
})
.collect();

println!("Result {:?}", lines);
Expand Down Expand Up @@ -332,15 +338,15 @@ fn get_attractors(class_str: String) -> BackendResponse {
if let Some(class) = has_class {
if let Some(graph) = &cmp.graph {
let witness_colour = class.pick_singleton();
let witness_network: BooleanNetwork = graph.pick_witness(&witness_colour);
let witness_network: BooleanNetwork =
graph.pick_witness(&witness_colour);
let witness_graph =
SymbolicAsyncGraph::new(witness_network.clone()).unwrap();
let witness_str = witness_network.to_string();
let witness_attractors = classifier.attractors(&witness_colour);
let variable_name_strings =
witness_network.variables().map(|id| {
format!("\"{}\"", witness_network.get_variable_name(id))
});
let variable_name_strings = witness_network
.variables()
.map(|id| format!("\"{}\"", witness_network.get_variable_name(id)));

let mut all_attractors: Vec<(
Behaviour,
Expand All @@ -367,7 +373,8 @@ fn get_attractors(class_str: String) -> BackendResponse {
if *behaviour == Behaviour::Stability {
// This is a sink - no edges
assert_eq!(attractor.materialize().iter().count(), 1);
let sink: ArrayBitVector = attractor.materialize().iter().next().unwrap();
let sink: ArrayBitVector =
attractor.materialize().iter().next().unwrap();
attractor_graph.push((sink.clone(), sink));
for i in 0..witness_network.num_vars() {
// In sink, we mark everything as "not-fixed" because we want to just display it normally.
Expand Down
5 changes: 1 addition & 4 deletions src/scc/_impl_classifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ impl Classifier {
}

/// Find attractor of the given witness colour. The argument set must be a singleton.
pub fn attractors(
&self,
witness_colour: &GraphColors,
) -> Vec<(GraphVertices, Behaviour)> {
pub fn attractors(&self, witness_colour: &GraphColors) -> Vec<(GraphVertices, Behaviour)> {
if witness_colour.approx_cardinality() != 1.0 {
eprintln!("WARNING: Computing attractor witnesses for non-singleton set. (This may be just a floating point error in large models).");
}
Expand Down
12 changes: 9 additions & 3 deletions src/scc/algo_effectively_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ pub fn reach_saturated_fwd_excluding(
let mut active_variable = last_variable;
loop {
let variable = variables[active_variable];
let post = graph.var_post(variable, &result).intersect(guard).minus(&result);
let post = graph
.var_post(variable, &result)
.intersect(guard)
.minus(&result);
result = result.union(&post);

if !post.is_empty() {
Expand Down Expand Up @@ -164,7 +167,10 @@ pub fn reach_saturated_bwd_excluding(
let mut active_variable = last_variable;
loop {
let variable = variables[active_variable];
let post = graph.var_pre(variable, &result).intersect(guard).minus(&result);
let post = graph
.var_pre(variable, &result)
.intersect(guard)
.minus(&result);
result = result.union(&post);

if !post.is_empty() {
Expand All @@ -178,4 +184,4 @@ pub fn reach_saturated_bwd_excluding(
}
}
return result;
}
}
9 changes: 6 additions & 3 deletions src/scc/algo_symbolic_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::scc::algo_effectively_constant::{
use crate::scc::ProgressTracker;
use biodivine_lib_param_bn::symbolic_async_graph::{GraphColoredVertices, SymbolicAsyncGraph};
use biodivine_lib_std::param_graph::Params;
use std::sync::atomic::{AtomicBool};
use std::sync::atomic::AtomicBool;

pub fn components_2<F>(graph: &SymbolicAsyncGraph, on_component: F)
where
Expand All @@ -23,8 +23,11 @@ where
let bwd_pivot = reach_saturated_bwd_excluding(graph, &pivot, &universe, &variables);
let component_with_pivot =
reach_saturated_fwd_excluding(graph, &pivot, &bwd_pivot, &variables);
let after_component = graph.post(&component_with_pivot).minus(&component_with_pivot);
let is_candidate = component_with_pivot.colors()
let after_component = graph
.post(&component_with_pivot)
.minus(&component_with_pivot);
let is_candidate = component_with_pivot
.colors()
.minus(&after_component.colors());
if !is_candidate.is_empty() {
on_component(component_with_pivot.intersect_colors(&is_candidate));
Expand Down
4 changes: 2 additions & 2 deletions src/scc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::collections::HashMap;
use std::sync::Mutex;
use std::vec::IntoIter;

pub mod algo_effectively_constant;
pub mod algo_symbolic_components;
/// **(internal)** Utility methods for the behaviour `Class`.
mod _impl_class;
/// **(internal)** Implementation of `Behaviour` classification in `Classifier`.
mod _impl_classifier;
pub mod algo_effectively_constant;
pub mod algo_symbolic_components;
mod impl_progress_tracker;
mod impl_state_set_iterator;

Expand Down

0 comments on commit f05fc65

Please sign in to comment.