Skip to content

Commit

Permalink
Merge branch 'master' into 0.3.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cargo.toml
  • Loading branch information
daemontus committed Feb 16, 2021
2 parents ff3b3d6 + 7f6efe8 commit 6975620
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 25 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/benchmark_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/bin/benchmark_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions src/bin/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion src/bin/rbn_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 10 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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());
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions src/scc/_impl_classifier.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/scc/_impl_progress_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/scc/algo_interleaved_transition_guided_reduction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ pub fn interleaved_transition_guided_reduction(
graph: &SymbolicAsyncGraph,
initial: GraphColoredVertices,
) -> (GraphColoredVertices, Vec<VariableId>) {
let variables = graph.network().variables().collect::<Vec<_>>();
let variables = graph.as_network().variables().collect::<Vec<_>>();
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() {
Expand Down
1 change: 1 addition & 0 deletions src/scc/algo_saturated_reachability/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/scc/algo_xie_beerel/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down

0 comments on commit 6975620

Please sign in to comment.