matching API#
Simple matching functionalities for RSML MTG trees
- openalea.rsml.matching.match_plants(t1, t2, max_distance=None)[source]#
Find a 1-to-1 matching between plants in t1 & t2
The matching is done to minimize distance between plants “seed”: the mean of the first node of all primary axes.
- This function returns:
the set of matched (t1-plant-id,t2-plant-id,distance)
the set of unmatch t1 plant id
the set of unmatch t2 plant id
The matching is done usinf one_to_one_match
- openalea.rsml.matching.match_roots(t1, t2, plant_match, max_distance=None)[source]#
Iteratively match root axes following the trees topology
This function iteratively match root axes from 1st to last (topological) order. The matching is selected using one_to_one_match using hausdorff distance.
- Inputs:
t1: 1st rsml-mtg t2: 2nd rsml-mtg plant_match: match between plants in t1 and t2
- Outputs:
the set of root matches as (t1_root_id, t2_root_id, hausdorff-distance)
the set of unmatched root in t1
the set of unmatched root in t2
Note
Children of unmatched elements are not listed in unmatched sets
- openalea.rsml.matching.one_to_one_match(distance, max_distance=None)[source]#
select minimal 1-to-1 matching in distance matrix, iteratively
Iteratively select the match (i,j) with minimum value in distance but only if both i and j were not matched at a previous step.
If max_distance is not None, don’t match pairs with a distance value higher than given max_distance
- Return:
the set match {(i0,j0,d0),(i1,j1,d1),…} where i*,j*,d* are the 1st, 2nd indices, and their distance
the set of unmatch i
the set of unmatch j
example:
d = np.random.randint(0,10,5,4) m,i,j = direct_match(d) print '
‘.join(str(ij)+’ matched with d=’+str(di) for ij,di in zip(m,d[zip(*m)]))
Download the source file ../../src/openalea/rsml/matching.py.