Refactoring names of structures, removing useless functions
This commit is contained in:
@ -188,8 +188,8 @@ pub fn limit_freq() -> std::io::Result<()> {
|
|||||||
let (_, sets) = read_file(&mut translator, path, parser_experiment)?;
|
let (_, sets) = read_file(&mut translator, path, parser_experiment)?;
|
||||||
|
|
||||||
let res = match frequency::limit_frequency(&sets,
|
let res = match frequency::limit_frequency(&sets,
|
||||||
system.get_reaction_rules(),
|
&system.reaction_rules,
|
||||||
system.get_available_entities()) {
|
&system.available_entities) {
|
||||||
Some(e) => e,
|
Some(e) => e,
|
||||||
None => {return Ok(());}
|
None => {return Ok(());}
|
||||||
};
|
};
|
||||||
@ -216,8 +216,8 @@ pub fn fast_freq() -> std::io::Result<()> {
|
|||||||
let (weights, sets) = read_file(&mut translator, path, parser_experiment)?;
|
let (weights, sets) = read_file(&mut translator, path, parser_experiment)?;
|
||||||
|
|
||||||
let res = match frequency::fast_frequency(&sets,
|
let res = match frequency::fast_frequency(&sets,
|
||||||
system.get_reaction_rules(),
|
&system.reaction_rules,
|
||||||
system.get_available_entities(),
|
&system.available_entities,
|
||||||
&weights) {
|
&weights) {
|
||||||
Some(e) => e,
|
Some(e) => e,
|
||||||
None => {return Ok(());}
|
None => {return Ok(());}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ pub fn compute_step<'a>(
|
|||||||
reaction: &'a RSreaction
|
reaction: &'a RSreaction
|
||||||
) -> Option<&'a RSset> {
|
) -> Option<&'a RSset> {
|
||||||
if reaction.enabled(current_state) {
|
if reaction.enabled(current_state) {
|
||||||
Some(reaction.products())
|
Some(&reaction.products)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,7 @@ impl GraphMapNodesTy {
|
|||||||
format!("{}",
|
format!("{}",
|
||||||
translator::RSsetDisplay::from(
|
translator::RSsetDisplay::from(
|
||||||
&translator,
|
&translator,
|
||||||
node.get_available_entities())
|
&node.available_entities)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -94,7 +94,7 @@ impl GraphMapNodesTy {
|
|||||||
Box::new(
|
Box::new(
|
||||||
move |_, node: &RSsystem| {
|
move |_, node: &RSsystem| {
|
||||||
let masked_entities =
|
let masked_entities =
|
||||||
node.get_available_entities()
|
node.available_entities
|
||||||
.intersection(&mask);
|
.intersection(&mask);
|
||||||
format!("{}",
|
format!("{}",
|
||||||
translator::RSsetDisplay::from(
|
translator::RSsetDisplay::from(
|
||||||
@ -110,7 +110,7 @@ impl GraphMapNodesTy {
|
|||||||
format!("{}",
|
format!("{}",
|
||||||
translator::RSprocessDisplay::from(
|
translator::RSprocessDisplay::from(
|
||||||
&translator,
|
&translator,
|
||||||
node.get_context_process())
|
&node.context_process)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -373,7 +373,7 @@ pub fn default_node_formatter(
|
|||||||
Box::new(
|
Box::new(
|
||||||
move |_g, n|
|
move |_g, n|
|
||||||
String::from(
|
String::from(
|
||||||
match original_graph.node_weight(n.0).unwrap().get_context_process()
|
match original_graph.node_weight(n.0).unwrap().context_process
|
||||||
{
|
{
|
||||||
RSprocess::Nill =>
|
RSprocess::Nill =>
|
||||||
", fillcolor=white",
|
", fillcolor=white",
|
||||||
|
|||||||
@ -115,9 +115,9 @@ pub fn lollipops_decomposed(
|
|||||||
// see lollipop
|
// see lollipop
|
||||||
pub fn lollipops(system: RSsystem) -> Vec<(Vec<RSset>, Vec<RSset>)> {
|
pub fn lollipops(system: RSsystem) -> Vec<(Vec<RSset>, Vec<RSset>)> {
|
||||||
lollipops_decomposed(
|
lollipops_decomposed(
|
||||||
system.get_delta(),
|
&system.delta,
|
||||||
system.get_reaction_rules(),
|
&system.reaction_rules,
|
||||||
system.get_available_entities(),
|
&system.available_entities,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +125,12 @@ pub fn lollipops(system: RSsystem) -> Vec<(Vec<RSset>, Vec<RSset>)> {
|
|||||||
pub fn lollipops_only_loop(system: RSsystem) -> Vec<Vec<RSset>> {
|
pub fn lollipops_only_loop(system: RSsystem) -> Vec<Vec<RSset>> {
|
||||||
// FIXME: i think we are only interested in "x", not all symbols that
|
// FIXME: i think we are only interested in "x", not all symbols that
|
||||||
// satisfy X = pre(Q, rec(X))
|
// satisfy X = pre(Q, rec(X))
|
||||||
let filtered = system.get_delta().iter().filter_map(filter_delta);
|
let filtered = system.delta.iter().filter_map(filter_delta);
|
||||||
|
|
||||||
let find_loop_fn = |q| {
|
let find_loop_fn = |q| {
|
||||||
find_only_loop(
|
find_only_loop(
|
||||||
system.get_reaction_rules(),
|
&system.reaction_rules,
|
||||||
system.get_available_entities().clone(),
|
system.available_entities.clone(),
|
||||||
q,
|
q,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
@ -226,9 +226,9 @@ pub fn lollipops_named(
|
|||||||
symb: IdType
|
symb: IdType
|
||||||
) -> Option<(Vec<RSset>, Vec<RSset>)> {
|
) -> Option<(Vec<RSset>, Vec<RSset>)> {
|
||||||
lollipops_decomposed_named(
|
lollipops_decomposed_named(
|
||||||
system.get_delta(),
|
&system.delta,
|
||||||
system.get_reaction_rules(),
|
&system.reaction_rules,
|
||||||
system.get_available_entities(),
|
&system.available_entities,
|
||||||
symb,
|
symb,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -239,15 +239,15 @@ pub fn lollipops_only_loop_named(
|
|||||||
symb: IdType
|
symb: IdType
|
||||||
) -> Option<Vec<RSset>> {
|
) -> Option<Vec<RSset>> {
|
||||||
let filtered = system
|
let filtered = system
|
||||||
.get_delta()
|
.delta
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|x| filter_delta_named(x, &symb))
|
.filter_map(|x| filter_delta_named(x, &symb))
|
||||||
.next();
|
.next();
|
||||||
|
|
||||||
let find_loop_fn = |q| {
|
let find_loop_fn = |q| {
|
||||||
find_only_loop(
|
find_only_loop(
|
||||||
system.get_reaction_rules(),
|
&system.reaction_rules,
|
||||||
system.get_available_entities().clone(),
|
system.available_entities.clone(),
|
||||||
q,
|
q,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,17 +13,17 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
);
|
);
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"the initial state has {} entities:\n",
|
"the initial state has {} entities:\n",
|
||||||
system.get_available_entities().len()
|
system.available_entities.len()
|
||||||
));
|
));
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"{}\n",
|
"{}\n",
|
||||||
translator::RSsetDisplay::from(translator, system.get_available_entities())
|
translator::RSsetDisplay::from(translator, &system.available_entities)
|
||||||
));
|
));
|
||||||
|
|
||||||
let reactants = system
|
let reactants = system
|
||||||
.get_reaction_rules()
|
.reaction_rules
|
||||||
.iter()
|
.iter()
|
||||||
.fold(RSset::new(), |acc, new| acc.union(new.reactants()));
|
.fold(RSset::new(), |acc, new| acc.union(&new.reactants));
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"The reactants are {}:\n{}\n",
|
"The reactants are {}:\n{}\n",
|
||||||
reactants.len(),
|
reactants.len(),
|
||||||
@ -31,9 +31,9 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
));
|
));
|
||||||
|
|
||||||
let inhibitors = system
|
let inhibitors = system
|
||||||
.get_reaction_rules()
|
.reaction_rules
|
||||||
.iter()
|
.iter()
|
||||||
.fold(RSset::new(), |acc, new| acc.union(new.inihibitors()));
|
.fold(RSset::new(), |acc, new| acc.union(&new.inihibitors));
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"The inhibitors are {}:\n{}\n",
|
"The inhibitors are {}:\n{}\n",
|
||||||
inhibitors.len(),
|
inhibitors.len(),
|
||||||
@ -41,9 +41,9 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
));
|
));
|
||||||
|
|
||||||
let products = system
|
let products = system
|
||||||
.get_reaction_rules()
|
.reaction_rules
|
||||||
.iter()
|
.iter()
|
||||||
.fold(RSset::new(), |acc, new| acc.union(new.products()));
|
.fold(RSset::new(), |acc, new| acc.union(&new.products));
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"The products are {}:\n{}\n",
|
"The products are {}:\n{}\n",
|
||||||
products.len(),
|
products.len(),
|
||||||
@ -57,14 +57,14 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
translator::RSsetDisplay::from(translator, &total)
|
translator::RSsetDisplay::from(translator, &total)
|
||||||
));
|
));
|
||||||
|
|
||||||
let entities_env = system.get_delta().all_elements();
|
let entities_env = system.delta.all_elements();
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"The environment involves {} entities:\n{}\n",
|
"The environment involves {} entities:\n{}\n",
|
||||||
entities_env.len(),
|
entities_env.len(),
|
||||||
translator::RSsetDisplay::from(translator, &entities_env)
|
translator::RSsetDisplay::from(translator, &entities_env)
|
||||||
));
|
));
|
||||||
|
|
||||||
let entities_context = system.get_context_process().all_elements();
|
let entities_context = system.context_process.all_elements();
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"The context involves {} entities:\n{}\n",
|
"The context involves {} entities:\n{}\n",
|
||||||
entities_context.len(),
|
entities_context.len(),
|
||||||
@ -74,7 +74,7 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
let entities_all = total
|
let entities_all = total
|
||||||
.union(&entities_env)
|
.union(&entities_env)
|
||||||
.union(&entities_context)
|
.union(&entities_context)
|
||||||
.union(system.get_available_entities());
|
.union(&system.available_entities);
|
||||||
|
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"The whole RS involves {} entities:\n{}\n",
|
"The whole RS involves {} entities:\n{}\n",
|
||||||
@ -83,7 +83,7 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
));
|
));
|
||||||
|
|
||||||
let possible_e = products
|
let possible_e = products
|
||||||
.union(system.get_available_entities())
|
.union(&system.available_entities)
|
||||||
.union(&entities_context);
|
.union(&entities_context);
|
||||||
let missing_e = reactants.subtraction(&possible_e);
|
let missing_e = reactants.subtraction(&possible_e);
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
@ -101,14 +101,14 @@ pub fn of_RSsystem<'a>(translator: &'a Translator, system: &'a RSsystem) -> Stri
|
|||||||
|
|
||||||
result.push_str(&format!(
|
result.push_str(&format!(
|
||||||
"There are {} reactions in total.\n",
|
"There are {} reactions in total.\n",
|
||||||
system.get_reaction_rules().len()
|
system.reaction_rules.len()
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut admissible_reactions = vec![];
|
let mut admissible_reactions = vec![];
|
||||||
let mut nonadmissible_reactions = vec![];
|
let mut nonadmissible_reactions = vec![];
|
||||||
|
|
||||||
for reaction in system.get_reaction_rules().iter() {
|
for reaction in system.reaction_rules.iter() {
|
||||||
if reaction.reactants().is_disjoint(&missing_e) {
|
if reaction.reactants.is_disjoint(&missing_e) {
|
||||||
admissible_reactions.push(reaction);
|
admissible_reactions.push(reaction);
|
||||||
} else {
|
} else {
|
||||||
nonadmissible_reactions.push(reaction);
|
nonadmissible_reactions.push(reaction);
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use std::rc::Rc;
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct RSset {
|
pub struct RSset {
|
||||||
identifiers: BTreeSet<IdType>,
|
pub identifiers: BTreeSet<IdType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const N: usize> From<[IdType; N]> for RSset {
|
impl<const N: usize> From<[IdType; N]> for RSset {
|
||||||
@ -89,10 +89,6 @@ impl RSset {
|
|||||||
RSset { identifiers: res }
|
RSset { identifiers: res }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set(&self) -> &BTreeSet<IdType> {
|
|
||||||
&self.identifiers
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iter(&self) -> std::collections::btree_set::Iter<'_, IdType> {
|
pub fn iter(&self) -> std::collections::btree_set::Iter<'_, IdType> {
|
||||||
self.identifiers.iter()
|
self.identifiers.iter()
|
||||||
}
|
}
|
||||||
@ -134,9 +130,9 @@ impl IntoIterator for RSset {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RSreaction {
|
pub struct RSreaction {
|
||||||
reactants: RSset,
|
pub reactants: RSset,
|
||||||
inihibitors: RSset,
|
pub inihibitors: RSset,
|
||||||
products: RSset,
|
pub products: RSset,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RSreaction {
|
impl RSreaction {
|
||||||
@ -161,22 +157,6 @@ impl RSreaction {
|
|||||||
self.reactants.is_subset(current_state)
|
self.reactants.is_subset(current_state)
|
||||||
&& self.inihibitors.is_disjoint(current_state)
|
&& self.inihibitors.is_disjoint(current_state)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn products_clone(&self) -> RSset {
|
|
||||||
self.products.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn reactants(&self) -> &RSset {
|
|
||||||
&self.reactants
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn inihibitors(&self) -> &RSset {
|
|
||||||
&self.inihibitors
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn products(&self) -> &RSset {
|
|
||||||
&self.products
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for RSreaction {
|
impl Default for RSreaction {
|
||||||
@ -434,10 +414,10 @@ impl From<Vec<(IdType, RSprocess)>> for RSenvironment {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RSsystem {
|
pub struct RSsystem {
|
||||||
delta: Rc<RSenvironment>,
|
pub delta: Rc<RSenvironment>,
|
||||||
available_entities: RSset,
|
pub available_entities: RSset,
|
||||||
context_process: RSprocess,
|
pub context_process: RSprocess,
|
||||||
reaction_rules: Rc<Vec<RSreaction>>,
|
pub reaction_rules: Rc<Vec<RSreaction>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RSsystem {
|
impl RSsystem {
|
||||||
@ -463,24 +443,10 @@ impl RSsystem {
|
|||||||
reaction_rules: Rc::clone(&reaction_rules),
|
reaction_rules: Rc::clone(&reaction_rules),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_delta(&self) -> &Rc<RSenvironment> {
|
|
||||||
&self.delta
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_available_entities(&self) -> &RSset {
|
|
||||||
&self.available_entities
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_context_process(&self) -> &RSprocess {
|
|
||||||
&self.context_process
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_reaction_rules(&self) -> &Rc<Vec<RSreaction>> {
|
|
||||||
&self.reaction_rules
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Equality does not care about delta or reaction rules, only entities and
|
||||||
|
/// context is compared
|
||||||
impl PartialEq for RSsystem {
|
impl PartialEq for RSsystem {
|
||||||
// we ignore delta and reaction rules
|
// we ignore delta and reaction rules
|
||||||
fn eq(&self, other: &RSsystem) -> bool {
|
fn eq(&self, other: &RSsystem) -> bool {
|
||||||
@ -489,8 +455,12 @@ impl PartialEq for RSsystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Equality does not care about delta or reaction rules, only entities and
|
||||||
|
/// context is compared
|
||||||
impl Eq for RSsystem {}
|
impl Eq for RSsystem {}
|
||||||
|
|
||||||
|
/// Hash does not care about delta or reaction rules, only entities and
|
||||||
|
/// context is hashed
|
||||||
impl Hash for RSsystem {
|
impl Hash for RSsystem {
|
||||||
// ignores delta and reaction rules
|
// ignores delta and reaction rules
|
||||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
@ -513,11 +483,10 @@ pub struct RSlabel {
|
|||||||
pub available_entities: RSset,
|
pub available_entities: RSset,
|
||||||
pub context: RSset,
|
pub context: RSset,
|
||||||
pub t: RSset,
|
pub t: RSset,
|
||||||
/// union of available_entities and context
|
|
||||||
pub reactants: RSset,
|
pub reactants: RSset,
|
||||||
pub reactantsi: RSset, // reactants absent
|
pub reactants_absent: RSset,
|
||||||
pub inihibitors: RSset,
|
pub inihibitors: RSset,
|
||||||
pub ireactants: RSset, // inhibitors present
|
pub inihibitors_present: RSset,
|
||||||
pub products: RSset,
|
pub products: RSset,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,9 +497,9 @@ impl RSlabel {
|
|||||||
context: RSset::new(),
|
context: RSset::new(),
|
||||||
t: RSset::new(),
|
t: RSset::new(),
|
||||||
reactants: RSset::new(),
|
reactants: RSset::new(),
|
||||||
reactantsi: RSset::new(),
|
reactants_absent: RSset::new(),
|
||||||
inihibitors: RSset::new(),
|
inihibitors: RSset::new(),
|
||||||
ireactants: RSset::new(),
|
inihibitors_present: RSset::new(),
|
||||||
products: RSset::new(),
|
products: RSset::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,9 +510,9 @@ impl RSlabel {
|
|||||||
context: RSset,
|
context: RSset,
|
||||||
t: RSset,
|
t: RSset,
|
||||||
reactants: RSset,
|
reactants: RSset,
|
||||||
reactantsi: RSset,
|
reactants_absent: RSset,
|
||||||
inihibitors: RSset,
|
inihibitors: RSset,
|
||||||
ireactants: RSset,
|
inihibitors_present: RSset,
|
||||||
products: RSset,
|
products: RSset,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
RSlabel {
|
RSlabel {
|
||||||
@ -551,19 +520,18 @@ impl RSlabel {
|
|||||||
context,
|
context,
|
||||||
t,
|
t,
|
||||||
reactants,
|
reactants,
|
||||||
reactantsi,
|
reactants_absent,
|
||||||
inihibitors,
|
inihibitors,
|
||||||
ireactants,
|
inihibitors_present,
|
||||||
products,
|
products,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_context(&self) -> (RSset, RSset, RSset) {
|
pub fn get_context(&self) -> (&RSset, &RSset, &RSset) {
|
||||||
// TODO remove clone?
|
|
||||||
(
|
(
|
||||||
self.available_entities.clone(),
|
&self.available_entities,
|
||||||
self.context.clone(),
|
&self.context,
|
||||||
self.t.clone(),
|
&self.t,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ impl<'a> TransitionsIterator<'a> {
|
|||||||
pub fn from(
|
pub fn from(
|
||||||
system: &'a RSsystem
|
system: &'a RSsystem
|
||||||
) -> Result<TransitionsIterator<'a>, String> {
|
) -> Result<TransitionsIterator<'a>, String> {
|
||||||
match unfold(system.get_delta(), system.get_context_process()) {
|
match unfold(&system.delta, &system.context_process) {
|
||||||
Ok(o) => Ok(TransitionsIterator {
|
Ok(o) => Ok(TransitionsIterator {
|
||||||
choices_iterator: o.into_iter(),
|
choices_iterator: o.into_iter(),
|
||||||
system,
|
system,
|
||||||
@ -28,9 +28,9 @@ impl<'a> Iterator for TransitionsIterator<'a> {
|
|||||||
|
|
||||||
fn next(&mut self) -> Option<(RSlabel, RSsystem)> {
|
fn next(&mut self) -> Option<(RSlabel, RSsystem)> {
|
||||||
let (c, k) = self.choices_iterator.next()?;
|
let (c, k) = self.choices_iterator.next()?;
|
||||||
let t = self.system.get_available_entities().union(c.as_ref());
|
let t = self.system.available_entities.union(c.as_ref());
|
||||||
let (reactants, reactantsi, inihibitors, ireactants, products) =
|
let (reactants, reactantsi, inihibitors, ireactants, products) =
|
||||||
self.system.get_reaction_rules().iter().fold(
|
self.system.reaction_rules.iter().fold(
|
||||||
(
|
(
|
||||||
RSset::new(), // reactants
|
RSset::new(), // reactants
|
||||||
RSset::new(), // reactantsi
|
RSset::new(), // reactantsi
|
||||||
@ -41,18 +41,18 @@ impl<'a> Iterator for TransitionsIterator<'a> {
|
|||||||
|acc, reaction| {
|
|acc, reaction| {
|
||||||
if reaction.enabled(&t) {
|
if reaction.enabled(&t) {
|
||||||
(
|
(
|
||||||
acc.0.union(reaction.reactants()),
|
acc.0.union(&reaction.reactants),
|
||||||
acc.1,
|
acc.1,
|
||||||
acc.2.union(reaction.inihibitors()),
|
acc.2.union(&reaction.inihibitors),
|
||||||
acc.3,
|
acc.3,
|
||||||
acc.4.union(reaction.products()),
|
acc.4.union(&reaction.products),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
acc.0,
|
acc.0,
|
||||||
acc.1.union(&reaction.inihibitors().intersection(&t)),
|
acc.1.union(&reaction.inihibitors.intersection(&t)),
|
||||||
acc.2,
|
acc.2,
|
||||||
acc.3.union(&reaction.reactants().subtraction(&t)),
|
acc.3.union(&reaction.reactants.subtraction(&t)),
|
||||||
acc.4,
|
acc.4,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ impl<'a> Iterator for TransitionsIterator<'a> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let label = RSlabel::from(
|
let label = RSlabel::from(
|
||||||
self.system.get_available_entities().clone(),
|
self.system.available_entities.clone(),
|
||||||
(*c).clone(),
|
(*c).clone(),
|
||||||
t,
|
t,
|
||||||
reactants,
|
reactants,
|
||||||
@ -70,10 +70,10 @@ impl<'a> Iterator for TransitionsIterator<'a> {
|
|||||||
products.clone(),
|
products.clone(),
|
||||||
);
|
);
|
||||||
let new_system = RSsystem::from(
|
let new_system = RSsystem::from(
|
||||||
Rc::clone(self.system.get_delta()),
|
Rc::clone(&self.system.delta),
|
||||||
products,
|
products,
|
||||||
(*k).clone(),
|
(*k).clone(),
|
||||||
Rc::clone(self.system.get_reaction_rules()),
|
Rc::clone(&self.system.reaction_rules),
|
||||||
);
|
);
|
||||||
Some((label, new_system))
|
Some((label, new_system))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,7 +115,7 @@ pub fn target(
|
|||||||
) -> Result<(i64, RSset), String> {
|
) -> Result<(i64, RSset), String> {
|
||||||
let current = one_transition(system)?;
|
let current = one_transition(system)?;
|
||||||
if current.is_none() {
|
if current.is_none() {
|
||||||
return Ok((0, system.get_available_entities().clone()));
|
return Ok((0, system.available_entities.clone()));
|
||||||
}
|
}
|
||||||
let mut n = 1;
|
let mut n = 1;
|
||||||
let mut current = current.unwrap().1;
|
let mut current = current.unwrap().1;
|
||||||
@ -123,7 +123,7 @@ pub fn target(
|
|||||||
current = next;
|
current = next;
|
||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
Ok((n, current.get_available_entities().clone()))
|
Ok((n, current.available_entities.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// see oneRun, run, smartOneRunEK, smartRunEK
|
// see oneRun, run, smartOneRunEK, smartRunEK
|
||||||
@ -145,11 +145,13 @@ pub fn run_separated(
|
|||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
let current = current.unwrap();
|
let current = current.unwrap();
|
||||||
res.push(current.0.get_context());
|
let (available_entities, context, t) = current.0.get_context();
|
||||||
|
res.push((available_entities.clone(), context.clone(), t.clone()));
|
||||||
let mut current = current.1;
|
let mut current = current.1;
|
||||||
while let Some((label, next)) = one_transition(¤t)? {
|
while let Some((label, next)) = one_transition(¤t)? {
|
||||||
current = next;
|
current = next;
|
||||||
res.push(label.get_context());
|
let (available_entities, context, t) = label.get_context();
|
||||||
|
res.push((available_entities.clone(), context.clone(), t.clone()));
|
||||||
}
|
}
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,9 +121,9 @@ fn print_reaction(
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"(r: {}, i: {}, p: {})",
|
"(r: {}, i: {}, p: {})",
|
||||||
RSsetDisplay::from(translator, reaction.reactants()),
|
RSsetDisplay::from(translator, &reaction.reactants),
|
||||||
RSsetDisplay::from(translator, reaction.inihibitors()),
|
RSsetDisplay::from(translator, &reaction.inihibitors),
|
||||||
RSsetDisplay::from(translator, reaction.products())
|
RSsetDisplay::from(translator, &reaction.products)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,11 +294,11 @@ fn print_system(
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"[delta: {}, available_entities: {}, context_process: {}, reaction_rules: [",
|
"[delta: {}, available_entities: {}, context_process: {}, reaction_rules: [",
|
||||||
RSenvironmentDisplay::from(translator, system.get_delta()),
|
RSenvironmentDisplay::from(translator, &system.delta),
|
||||||
RSsetDisplay::from(translator, system.get_available_entities()),
|
RSsetDisplay::from(translator, &system.available_entities),
|
||||||
RSprocessDisplay::from(translator, system.get_context_process())
|
RSprocessDisplay::from(translator, &system.context_process)
|
||||||
)?;
|
)?;
|
||||||
let mut it = system.get_reaction_rules().iter().peekable();
|
let mut it = system.reaction_rules.iter().peekable();
|
||||||
while let Some(el) = it.next() {
|
while let Some(el) = it.next() {
|
||||||
if it.peek().is_none() {
|
if it.peek().is_none() {
|
||||||
write!(f, "{}", RSreactionDisplay::from(translator, el))?;
|
write!(f, "{}", RSreactionDisplay::from(translator, el))?;
|
||||||
@ -327,9 +327,9 @@ fn print_label(
|
|||||||
RSsetDisplay::from(translator, &label.context),
|
RSsetDisplay::from(translator, &label.context),
|
||||||
RSsetDisplay::from(translator, &label.t),
|
RSsetDisplay::from(translator, &label.t),
|
||||||
RSsetDisplay::from(translator, &label.reactants),
|
RSsetDisplay::from(translator, &label.reactants),
|
||||||
RSsetDisplay::from(translator, &label.reactantsi),
|
RSsetDisplay::from(translator, &label.reactants_absent),
|
||||||
RSsetDisplay::from(translator, &label.inihibitors),
|
RSsetDisplay::from(translator, &label.inihibitors),
|
||||||
RSsetDisplay::from(translator, &label.ireactants),
|
RSsetDisplay::from(translator, &label.inihibitors_present),
|
||||||
RSsetDisplay::from(translator, &label.products),
|
RSsetDisplay::from(translator, &label.products),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
Environment: [x = {a}.y, y =({a}.x + {b}.y)]
|
Environment: [x = {a}.😵, 😵 =({a}.x + {b}.😵)]
|
||||||
Initial Entities: {a, b}
|
Initial Entities: {a, b}
|
||||||
Context: [({a,b}.{a}.{a,c}.x + {a,b}.{a}.{a}.nill)]
|
Context: [({a,b}.{a}.{a,c}.x + {a,b}.{a}.{a}.nill)]
|
||||||
Reactions: ([r: {a,b}, i: {c}, p: {b}])
|
Reactions: ([{a,b}, {c}, {b}])
|
||||||
|
|||||||
Reference in New Issue
Block a user