@@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
33use itertools:: Itertools ;
44use process_mining:: ocel:: linked_ocel:: { IndexLinkedOCEL , LinkedOCELAccess } ;
55
6- use crate :: discovery:: advanced:: EventOrObjectType ;
6+ use crate :: discovery:: advanced:: EventOrObjectTypeRef ;
77
88use super :: {
99 structs:: { BindingBox , BindingStep , Filter , Qualifier , Variable } ,
@@ -14,53 +14,58 @@ pub fn get_expected_relation_count(
1414 bound_by : & Variable ,
1515 bbox : & BindingBox ,
1616 parent_binding_opt : Option < & Binding > ,
17- ocel : Option < & IndexLinkedOCEL > ,
18- ) -> Option < f32 > {
19- if ocel. is_none ( ) {
20- eprintln ! ( "NO OCEL?! for step order" ) ;
21- return None ;
22- }
17+ ocel : & IndexLinkedOCEL ,
18+ ) -> Option < usize > {
2319 let mut bound_by_types = Vec :: new ( ) ;
2420 // First check if bound_by is already bound by parent
2521 if let Some ( bound_by_index) = parent_binding_opt. and_then ( |b| b. get_any_index ( bound_by) ) {
26- if let Some ( ocel) = ocel {
27- let bound_by_type = match bound_by_index {
28- process_mining:: ocel:: linked_ocel:: index_linked_ocel:: EventOrObjectIndex :: Event ( event_index) => EventOrObjectType :: Event ( ocel. get_ev ( & event_index) . event_type . clone ( ) ) ,
29- process_mining:: ocel:: linked_ocel:: index_linked_ocel:: EventOrObjectIndex :: Object ( object_index) => EventOrObjectType :: Object ( ocel. get_ob ( & object_index) . object_type . clone ( ) ) ,
30- } ;
31- bound_by_types. push ( bound_by_type) ;
32- }
22+ let bound_by_type = match bound_by_index {
23+ process_mining:: ocel:: linked_ocel:: index_linked_ocel:: EventOrObjectIndex :: Event (
24+ event_index,
25+ ) => EventOrObjectTypeRef :: Event ( ocel. get_ev ( & event_index) . event_type . as_str ( ) ) ,
26+ process_mining:: ocel:: linked_ocel:: index_linked_ocel:: EventOrObjectIndex :: Object (
27+ object_index,
28+ ) => EventOrObjectTypeRef :: Object ( ocel. get_ob ( & object_index) . object_type . as_str ( ) ) ,
29+ } ;
30+ bound_by_types. push ( bound_by_type) ;
3331 } else {
3432 bound_by_types = match bound_by {
3533 Variable :: Event ( var_ev) => bbox
3634 . new_event_vars
3735 . get ( var_ev)
3836 . unwrap ( )
3937 . iter ( )
40- . map ( |t| EventOrObjectType :: Event ( t. clone ( ) ) )
38+ . map ( |t| EventOrObjectTypeRef :: Event ( t. as_str ( ) ) )
4139 . collect ( ) ,
4240 Variable :: Object ( var_ob) => bbox
4341 . new_object_vars
4442 . get ( var_ob)
4543 . unwrap ( )
4644 . iter ( )
47- . map ( |t| EventOrObjectType :: Object ( t. clone ( ) ) )
45+ . map ( |t| EventOrObjectTypeRef :: Object ( t. as_str ( ) ) )
4846 . collect ( ) ,
4947 }
5048 }
5149 let res = bound_by_types
5250 . into_iter ( )
5351 . map ( |bound_by_type| {
54- // TODO
55- 0.0
56- // ocel.unwrap()
57- // .avg_rels_of_type_per_type
58- // .get(&bound_by_type)
59- // .copied()
60- // .unwrap_or_default()
52+ // Previously this was based on the average relations of an object/event
53+ // Now it's simply the count (how many exist)
54+ match bound_by_type {
55+ EventOrObjectTypeRef :: Event ( t) => ocel
56+ . events_per_type
57+ . get ( t)
58+ . map ( |es| es. len ( ) )
59+ . unwrap_or_default ( ) ,
60+ EventOrObjectTypeRef :: Object ( t) => ocel
61+ . objects_per_type
62+ . get ( t)
63+ . map ( |es| es. len ( ) )
64+ . unwrap_or_default ( ) ,
65+ }
6166 } )
6267 . sum ( ) ;
63- // println!("{res} for {var:?} {bound_by:?}");
68+ println ! ( "{res} for {bound_by:?}" ) ;
6469 Some ( res)
6570}
6671impl BindingStep {
@@ -75,7 +80,7 @@ impl BindingStep {
7580 pub fn get_binding_order (
7681 bbox : & BindingBox ,
7782 parent_binding_opt : Option < & Binding > ,
78- ocel : Option < & IndexLinkedOCEL > ,
83+ ocel : & IndexLinkedOCEL ,
7984 ) -> Vec < Self > {
8085 let mut ret = Vec :: new ( ) ;
8186
@@ -251,8 +256,7 @@ impl BindingStep {
251256 } )
252257 . sorted_by_cached_key ( |( bound_by_var, ( _v, _q, _filter_index, _reversed) ) | {
253258 get_expected_relation_count ( bound_by_var, bbox, parent_binding_opt, ocel)
254- . unwrap_or ( 10.0 )
255- . round ( ) as usize
259+ . unwrap_or ( 10 )
256260 } )
257261 . next ( )
258262 {
0 commit comments