-
Notifications
You must be signed in to change notification settings - Fork 13
Implement Alignments #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4e7b8b1
Initial alignment impl
aarkue 068d9f6
Add more tests
aarkue 7a8bdda
Make dijkstra search generic, and expose alignments as bindings
aarkue dd9649d
Type aliases for token count and trace lengths + bench for alignments
aarkue e776c11
Fix typos
aarkue 5b0ce20
Merge remote-tracking branch 'origin/main' into feat/alignments
aarkue d6273ff
Improve comments and docs
aarkue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| //! Benchmark the time taken to compute optimal alignments of a log against a Petri net | ||
| use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
| use process_mining::{ | ||
| conformance::alignments::{align_log, AlignmentOptions}, | ||
| core::event_data::case_centric::utils::activity_projection::{ | ||
| log_to_activity_projection, EventLogActivityProjection, | ||
| }, | ||
| test_utils::get_test_data_path, | ||
| EventLog, Importable, PetriNet, | ||
| }; | ||
| use std::time::Duration; | ||
|
|
||
| fn load(log_name: &str, net_name: &str) -> (PetriNet, EventLogActivityProjection) { | ||
| let root = get_test_data_path(); | ||
| let log = EventLog::import_from_path(root.join("xes").join(log_name)).unwrap(); | ||
| let net = PetriNet::import_pnml(root.join("petri-net").join(net_name)).unwrap(); | ||
| (net, log_to_activity_projection(&log)) | ||
| } | ||
|
|
||
| fn bench_alignments(c: &mut Criterion) { | ||
| let options = AlignmentOptions::default(); | ||
|
|
||
| let (sepsis_net, sepsis_proj) = | ||
| load("Sepsis Cases - Event Log.xes.gz", "sepsis-DISCovered.apnml"); | ||
| let mut sepsis = c.benchmark_group("alignments"); | ||
| sepsis.sample_size(25); | ||
| sepsis.measurement_time(Duration::from_secs(20)); | ||
| sepsis.bench_function("sepsis", |b| { | ||
| b.iter(|| black_box(align_log(&sepsis_net, &sepsis_proj, &options))) | ||
| }); | ||
| sepsis.finish(); | ||
|
|
||
| let (rtfm_net, rtfm_proj) = load( | ||
| "Road_Traffic_Fine_Management_Process.xes.gz", | ||
| "rtfm-imf-02.apnml", | ||
| ); | ||
| let mut rtfm = c.benchmark_group("alignments"); | ||
| rtfm.sample_size(10); | ||
| rtfm.measurement_time(Duration::from_secs(60)); | ||
| rtfm.bench_function("rtfm", |b| { | ||
| b.iter(|| black_box(align_log(&rtfm_net, &rtfm_proj, &options))) | ||
| }); | ||
| rtfm.finish(); | ||
| } | ||
|
|
||
| criterion_group!(benches, bench_alignments); | ||
| criterion_main!(benches); |
31 changes: 31 additions & 0 deletions
31
process_mining/src/conformance/case_centric/alignments/cost.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| //! Cost functions for alignments | ||
|
|
||
| use schemars::JsonSchema; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| /// Cost function for alignment moves. | ||
| /// | ||
| /// Defines the cost of model moves, log moves, synchronous moves, and silent moves. | ||
| #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)] | ||
| pub struct CostFunction { | ||
| /// Default cost for a model move (visible transition fires without matching log event) | ||
| pub model_move_cost: u32, | ||
| /// Default cost for a log move (log event not matched by model) | ||
| pub log_move_cost: u32, | ||
| /// Default cost for a synchronous move | ||
| pub sync_move_cost: u32, | ||
| /// Default cost for a silent/tau move | ||
| pub silent_move_cost: u32, | ||
| } | ||
|
|
||
| impl CostFunction { | ||
| /// Standard cost function: model and log moves cost 1, sync and silent moves cost 0. | ||
| pub fn standard() -> Self { | ||
| Self { | ||
| model_move_cost: 1, | ||
| log_move_cost: 1, | ||
| sync_move_cost: 0, | ||
| silent_move_cost: 0, | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.