steiner tree: eliminate identity loops

This commit is contained in:
Michael Sippel 2024-12-24 12:54:43 +01:00
parent b7fb889dbf
commit ad4b23d40e
Signed by: senvas
GPG key ID: F96CF119C34B64A6
3 changed files with 13 additions and 6 deletions

View file

@ -98,7 +98,12 @@ impl<M: Morphism + Clone> MorphismBase<M> {
&src_type.clone().param_normalize(),
&m.get_type().src_type.param_normalize(),
) {
dst_types.push(MorphismInstance{ halo, m: m.clone(), σ });
let dst_type =
m.get_type().dst_type.clone()
.apply_substitution( &|x| σ.get(x).cloned() )
.clone();
dst_types.push( (σ, dst_type) );
}
}
dst_types

View file

@ -107,8 +107,13 @@ impl PathApproxSteinerTreeSolver {
let mut new_path_iter = new_path.into_iter().peekable();
// check all existing nodes..
if new_path_iter.peek().unwrap() == &src_type {
new_path_iter.next();
}
for mt in tree.iter() {
// assert!( mt.src_type == &src_type );
//assert!( mt.src_type == &src_type );
if let Some(t) = new_path_iter.peek() {
if &mt.dst_type == t {
// eliminate this node from new path

View file

@ -14,8 +14,6 @@ pub enum TypeTerm {
Num(i64),
Char(char),
/* Complex Terms */
// Type Parameters
@ -47,10 +45,9 @@ impl TypeTerm {
*self = TypeTerm::App(vec![
self.clone(),
t.into()
])
])
}
}
self
}