smartOneRunECT, smartRunECT
This commit is contained in:
@ -330,8 +330,8 @@ impl RSsystem {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RSlabel {
|
||||
available_entities: RSset,
|
||||
c: RSset, /// TODO: what is c? what is t? (c comes from choices, t is
|
||||
t: RSset, /// the union of available_entities and c)
|
||||
context: RSset,
|
||||
t: RSset, /// union of available_entities and context
|
||||
reactants: RSset,
|
||||
reactantsi: RSset,
|
||||
inihibitors: RSset,
|
||||
@ -342,7 +342,7 @@ pub struct RSlabel {
|
||||
impl RSlabel {
|
||||
pub fn new() -> Self {
|
||||
RSlabel { available_entities: RSset::new(),
|
||||
c: RSset::new(),
|
||||
context: RSset::new(),
|
||||
t: RSset::new(),
|
||||
reactants: RSset::new(),
|
||||
reactantsi: RSset::new(),
|
||||
@ -353,7 +353,7 @@ impl RSlabel {
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn from(available_entities: RSset,
|
||||
c: RSset,
|
||||
context: RSset,
|
||||
t: RSset,
|
||||
reactants: RSset,
|
||||
reactantsi: RSset,
|
||||
@ -361,7 +361,7 @@ impl RSlabel {
|
||||
ireactants: RSset,
|
||||
products: RSset,) -> Self {
|
||||
RSlabel { available_entities,
|
||||
c,
|
||||
context,
|
||||
t,
|
||||
reactants,
|
||||
reactantsi,
|
||||
@ -369,6 +369,11 @@ impl RSlabel {
|
||||
ireactants,
|
||||
products }
|
||||
}
|
||||
|
||||
pub fn get_context(&self) -> (RSset, RSset, RSset) {
|
||||
// FIXME clone?
|
||||
(self.available_entities.clone(), self.context.clone(), self.t.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ pub fn all_transitions(
|
||||
}
|
||||
|
||||
// see oneTarget, smartOneTarget, target, smartTarget
|
||||
pub fn one_target(system: &RSsystem) -> Result<(i64, RSset), String> {
|
||||
pub fn target(system: &RSsystem) -> Result<(i64, RSset), String> {
|
||||
let current = one_transition(system)?;
|
||||
if current.is_none() {
|
||||
return Ok((0, system.get_available_entities().clone()));
|
||||
@ -119,10 +119,27 @@ pub fn one_target(system: &RSsystem) -> Result<(i64, RSset), String> {
|
||||
}
|
||||
|
||||
// see oneRun, run, smartOneRunEK, smartRunEK
|
||||
pub fn one_run(system: RSsystem) -> Result<Vec<Rc<RSsystem>>, String> {
|
||||
pub fn run(system: RSsystem) -> Result<Vec<Rc<RSsystem>>, String> {
|
||||
let mut res = vec![Rc::new(system)];
|
||||
while let Some((_, next_sys)) = one_transition(res.last().unwrap())? {
|
||||
res.push(Rc::new(next_sys));
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// see smartOneRunECT, smartRunECT
|
||||
pub fn run_separated(system: &RSsystem) -> Result<Vec<(RSset, RSset, RSset)>, String> {
|
||||
let mut res = vec![];
|
||||
let current = one_transition(system)?;
|
||||
if current.is_none() {
|
||||
return Ok(res);
|
||||
}
|
||||
let current = current.unwrap();
|
||||
res.push(current.0.get_context());
|
||||
let mut current = current.1;
|
||||
while let Some((label, next)) = one_transition(¤t)? {
|
||||
current = next;
|
||||
res.push(label.get_context());
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user