better lifetime for variables in pohibiting set
This commit is contained in:
@ -206,9 +206,9 @@ impl Set {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Computes minimized prohibiting set from reactants and inhibitors.
|
/// Computes minimized prohibiting set from reactants and inhibitors.
|
||||||
/// Computes the powerset of the smallest reactants ∪ inhibitors set and
|
/// Computes the powerset of the union of all reactants ∪ inhibitors sets
|
||||||
/// checks for each element of that set if they are also in all other
|
/// and checks for each element of that set if they are also in all other
|
||||||
/// unions.
|
/// unions. Then minimizes the result.
|
||||||
pub fn prohibiting_set(
|
pub fn prohibiting_set(
|
||||||
reactants: &[Set],
|
reactants: &[Set],
|
||||||
inhibitors: &[Set],
|
inhibitors: &[Set],
|
||||||
@ -229,6 +229,8 @@ impl Set {
|
|||||||
inhibitors: {:?}",
|
inhibitors: {:?}",
|
||||||
r, i))
|
r, i))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut t = {
|
||||||
let union = reactants.iter()
|
let union = reactants.iter()
|
||||||
.zip(inhibitors.iter())
|
.zip(inhibitors.iter())
|
||||||
.map(|(sr, si)| {
|
.map(|(sr, si)| {
|
||||||
@ -242,9 +244,12 @@ impl Set {
|
|||||||
for set in union.iter() {
|
for set in union.iter() {
|
||||||
t.retain(|el| !el.intersection(set).is_empty());
|
t.retain(|el| !el.intersection(set).is_empty());
|
||||||
}
|
}
|
||||||
|
t
|
||||||
|
};
|
||||||
|
|
||||||
// minimization
|
// minimization
|
||||||
// remove sets that contain other sets
|
// remove sets that contain other sets
|
||||||
|
{
|
||||||
let mut tmp_t = t.clone().into_iter();
|
let mut tmp_t = t.clone().into_iter();
|
||||||
let mut e = tmp_t.next().unwrap_or_default();
|
let mut e = tmp_t.next().unwrap_or_default();
|
||||||
loop {
|
loop {
|
||||||
@ -268,6 +273,7 @@ impl Set {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// replace pair of sets that have a common negative-positive element
|
// replace pair of sets that have a common negative-positive element
|
||||||
// with set without
|
// with set without
|
||||||
|
|||||||
Reference in New Issue
Block a user