Skip to content

Commit

Permalink
Update to latest dependencies and all that jazz...
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Sep 7, 2024
1 parent 24feb9a commit 4c799c9
Show file tree
Hide file tree
Showing 25 changed files with 326 additions and 261 deletions.
20 changes: 11 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ rustdoc-args = ["--html-in-header", "docs-head.html"]
[profile.release]
# This is important for profiling - otherwise we would get unreadable traces.
#debug = true
# This gives a marginally better runtime, but a much much longer compile times, so disabled by default.
# This gives a marginally better runtime, but a much, much longer compile times, so disabled by default.
#lto = true

[dependencies]
biodivine-lib-bdd = "0.4.0"
biodivine-lib-param-bn = "0.3.0"
rocket = "0.5.0-rc.1"
biodivine-lib-bdd = "0.5.19"
biodivine-lib-param-bn = "0.5.11"
rocket = "0.5.1"
rocket_cors = "0.6.0"
json = "0.12.4"
regex = "1.5.4"
rand = "0.8.1"
futures = "0.3.21"
tokio = "1.18.1"
fixed-map = "0.7.2"
regex = "1.10.6"
rand = "0.8.5"
futures = "0.3.30"
tokio = "1.40.0"
fixed-map = "0.9.5"
lazy_static = "1.5.0"

[dev-dependencies]
2 changes: 1 addition & 1 deletion src/_impl_graph_task_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl GraphTaskContext {
self.is_cancelled.load(Ordering::SeqCst)
}

/// Set the status of this task to cancelled.
/// Set the status of this task to cancel.
///
/// Return true if the computation was set to cancelled by this call, false if it was
/// cancelled previously.
Expand Down
51 changes: 23 additions & 28 deletions src/algorithms/asymptotic_behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::sync::Arc;

/// Describes a possible asymptotic behaviour of a discrete system.
/// Intuitively:
/// - `Stability` is when all of the system variables reach a fixed state.
/// - `Stability` is when all the system variables reach a fixed state.
/// - `Oscillation` is when some system variables change predictably and the rest
/// has a fixed state.
/// - `Disorder` is when some system variables change in a non-deterministic, unpredictable
Expand Down Expand Up @@ -127,7 +127,7 @@ impl AsymptoticBehaviour {
///
/// Note that it doesn't matter whether the variable update leaves the `set` or stays within.
/// Both count as unstable. However, you can use `SymbolicAsyncGraph::restrict` to disregard
/// updates leading outside of the provided `set`.
/// updates leading outside the provided `set`.
pub fn check_variable_stability(
stg: &SymbolicAsyncGraph,
set: &GraphColoredVertices,
Expand All @@ -147,8 +147,7 @@ impl AsymptoticBehaviour {
/// This method should be slightly faster than computing `AsymptoticBehaviour::classify`
/// in full.
pub fn check_stability(stg: &SymbolicAsyncGraph, set: &GraphColoredVertices) -> GraphColors {
stg.as_network()
.variables()
stg.variables()
.map(|var| Self::check_variable_stability(stg, set, var))
.fold(set.colors(), |a, b| a.intersect(&b))
}
Expand Down Expand Up @@ -199,10 +198,10 @@ impl AsymptoticBehaviour {
// transitions are discovered. Any color that appears in `successor_zero` or
// `successor_more` is guaranteed to not have only deterministic cycles.
let mut successors_zero = set.clone();
let mut successors_one = stg.mk_empty_vertices();
let mut successors_more = stg.mk_empty_vertices();
let mut successors_one = stg.mk_empty_colored_vertices();
let mut successors_more = stg.mk_empty_colored_vertices();

for var in stg.as_network().variables() {
for var in stg.variables() {
let can_change = stg.var_can_post(var, set);

let move_to_one = successors_zero.intersect(&can_change);
Expand Down Expand Up @@ -242,7 +241,7 @@ impl AsymptoticBehaviour {
set: Arc<GraphColoredVertices>,
) -> AsymptoticBehaviourMap {
let all_colors = set.colors();
let variables = stg.as_network().variables().collect();
let variables = stg.variables().collect();
let [zero, one, more] = Self::classify_recursive(stg.clone(), set.clone(), variables).await;

let stability = zero.colors().minus(&one.colors()).minus(&more.colors());
Expand All @@ -261,14 +260,18 @@ impl AsymptoticBehaviour {
set: Arc<GraphColoredVertices>,
variables: Vec<VariableId>,
) -> BoxFuture<'static, [GraphColoredVertices; 3]> {
return if variables.len() == 1 {
if variables.len() == 1 {
// If there is only one variable remaining, compute states that can perform transition
// with this variable. These are marked as "one transition", remaining are
// "zero transitions".
let var = variables[0];
Box::pin(async move {
let can_post = stg.var_can_post(var, &set);
[set.minus(&can_post), can_post, stg.mk_empty_vertices()]
[
set.minus(&can_post),
can_post,
stg.mk_empty_colored_vertices(),
]
})
} else {
// If there are more variables, split into two branches and continue each
Expand All @@ -289,7 +292,7 @@ impl AsymptoticBehaviour {
let zero = l_zero.intersect(&r_zero);
[zero, one, more]
})
};
}
}
}

Expand Down Expand Up @@ -322,7 +325,7 @@ mod tests {
)
.unwrap();

let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();
let all_colors = stg.mk_unit_colors();

let t_state = stg.vertex(&ArrayBitVector::from(vec![true, true]));
Expand All @@ -343,10 +346,7 @@ mod tests {
);
}

assert_symbolic_eq!(
sink_colors.as_bdd(),
classification.get(AsymptoticBehaviour::Stability).as_bdd()
);
assert_symbolic_eq!(sink_colors.as_bdd(), classification.get(Stability).as_bdd());
}

#[tokio::test]
Expand All @@ -361,7 +361,7 @@ mod tests {
)
.unwrap();

let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();
let all_colors = stg.mk_unit_colors();

let t_state = stg.vertex(&ArrayBitVector::from(vec![true, true]));
Expand All @@ -383,10 +383,7 @@ mod tests {
);
}

assert_symbolic_eq!(
sink_colors.as_bdd(),
classification.get(AsymptoticBehaviour::Stability).as_bdd()
);
assert_symbolic_eq!(sink_colors.as_bdd(), classification.get(Stability).as_bdd());
}

#[tokio::test]
Expand All @@ -402,7 +399,7 @@ mod tests {
)
.unwrap();

let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();
let all_colors = stg.mk_unit_colors();

let t_state = stg.vertex(&ArrayBitVector::from(vec![true, true]));
Expand All @@ -426,9 +423,7 @@ mod tests {

assert_symbolic_eq!(
oscillation_colors.as_bdd(),
classification
.get(AsymptoticBehaviour::Oscillation)
.as_bdd()
classification.get(Oscillation).as_bdd()
);
}

Expand All @@ -443,7 +438,7 @@ mod tests {
)
.unwrap();

let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();
let all_states = stg.mk_unit_colored_vertices();
let all_colors = stg.mk_unit_colors();

Expand All @@ -463,7 +458,7 @@ mod tests {

assert_symbolic_eq!(
disordered_colors.as_bdd(),
classification.get(AsymptoticBehaviour::Disorder).as_bdd()
classification.get(Disorder).as_bdd()
);
}

Expand All @@ -480,7 +475,7 @@ mod tests {
)
.unwrap();

let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();
let all_states = stg.mk_unit_colored_vertices();
let all_colors = stg.mk_unit_colors();

Expand Down
8 changes: 6 additions & 2 deletions src/algorithms/asymptotic_behaviour_classifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Class(Set<AsymptoticBehaviour>);

impl Feature for Class {
fn extend(&self, other: &Self) -> Self {
let mut set = self.0.clone();
let mut set = self.0;
for value in other.0.iter() {
set.insert(value);
}
Expand Down Expand Up @@ -99,6 +99,10 @@ impl AsymptoticBehaviourClassifier {
self.classifier.len()
}

pub fn is_empty(&self) -> bool {
self.classifier.is_empty()
}

/// Extend this classifier using a full behaviour classification map.
pub fn add_classification(&mut self, classification: &AsymptoticBehaviourMap) {
for (behaviour, colors) in classification.clone().to_vec() {
Expand Down Expand Up @@ -142,7 +146,7 @@ mod tests {
// works as expected.

let a = bn.as_graph().find_variable("a").unwrap();
let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();

let a_true = stg.fix_network_variable(a, true);
let a_false = stg.fix_network_variable(a, false);
Expand Down
8 changes: 6 additions & 2 deletions src/algorithms/asymptotic_behaviour_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Count(Map<AsymptoticBehaviour, usize>);

impl Feature for Count {
fn extend(&self, other: &Self) -> Self {
let mut map = self.0.clone();
let mut map = self.0;
for (key, value) in other.0.iter() {
if let Some(current) = map.get(key) {
let new_count = *value + *current;
Expand Down Expand Up @@ -103,6 +103,10 @@ impl AsymptoticBehaviourCounter {
self.counter.len()
}

pub fn is_empty(&self) -> bool {
self.counter.is_empty()
}

/// Extend this classifier using a full behaviour classification map.
pub fn add_classification(&mut self, classification: &AsymptoticBehaviourMap) {
for (behaviour, colors) in classification.clone().to_vec() {
Expand Down Expand Up @@ -146,7 +150,7 @@ mod tests {
// works as expected.

let a = bn.as_graph().find_variable("a").unwrap();
let stg = SymbolicAsyncGraph::new(bn).unwrap();
let stg = SymbolicAsyncGraph::new(&bn).unwrap();

let a_true = stg.fix_network_variable(a, true);
let a_false = stg.fix_network_variable(a, false);
Expand Down
Loading

0 comments on commit 4c799c9

Please sign in to comment.