Skip to content

Commit

Permalink
Parameter introspection on SymbolicContext.
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Dec 20, 2023
1 parent 8bc6c75 commit d352b20
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/symbolic_async_graph/_impl_symbolic_context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::symbolic_async_graph::{FunctionTable, SymbolicContext};
use crate::{BinaryOp, BooleanNetwork, FnUpdate, ParameterId, VariableId, VariableIdIterator};
use crate::{
BinaryOp, BooleanNetwork, FnUpdate, ParameterId, ParameterIdIterator, VariableId,
VariableIdIterator,
};
use biodivine_lib_bdd::op_function::{and, and_not};
use biodivine_lib_bdd::{
bdd, Bdd, BddValuation, BddVariable, BddVariableSet, BddVariableSetBuilder,
Expand Down Expand Up @@ -132,6 +135,11 @@ impl SymbolicContext {
})
}

/// Iterator over all [VariableId] network variables managed by this [SymbolicContext].
pub fn network_variables(&self) -> VariableIdIterator {
(0..self.num_state_variables()).map(VariableId::from_index)
}

/// Obtain a [VariableId] of a state variable, assuming such state variable exists.
pub fn find_network_variable(&self, name: &str) -> Option<VariableId> {
self.bdd
Expand All @@ -144,9 +152,27 @@ impl SymbolicContext {
self.bdd.name_of(self.state_variables[variable.to_index()])
}

/// Iterator over all [VariableId] network variables managed by this [SymbolicContext].
pub fn network_variables(&self) -> VariableIdIterator {
(0..self.num_state_variables()).map(VariableId::from_index)
/// Iterator over all [ParameterId] of the parameter functions managed by this [SymbolicContext].
pub fn network_parameters(&self) -> ParameterIdIterator {
(0..self.explicit_function_tables.len()).map(ParameterId::from_index)
}

/// Obtain a [ParameterId] of a parameter function based on a name.
pub fn find_network_parameter(&self, name: &str) -> Option<ParameterId> {
self.explicit_function_tables
.iter()
.position(|it| it.name.as_str() == name)
.map(ParameterId::from_index)
}

/// Obtain the arity of an underlying parameter function.
pub fn get_network_parameter_arity(&self, id: ParameterId) -> u16 {
self.explicit_function_tables[id.to_index()].arity
}

/// Obtain the name of an underlying parameter function.
pub fn get_network_parameter_name(&self, id: ParameterId) -> String {
self.explicit_function_tables[id.to_index()].name.clone()
}

/// Create a new [SymbolicContext] which is compatible with the current context (it uses the same
Expand Down

0 comments on commit d352b20

Please sign in to comment.