ebi 0.3.12

A stochastic process mining utility and library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
use crate::{
    ebi_framework::{
        ebi_command::EbiCommand,
        ebi_input::{EbiInput, EbiInputType},
        ebi_output::{EbiOutput, EbiOutputType},
        ebi_trait::EbiTrait, ebi_trait_object::EbiTraitObject,
    },
    ebi_traits::{
        ebi_trait_activities::EbiTraitActivities, ebi_trait_event_log_event_attributes::EbiTraitEventLogEventAttributes, ebi_trait_finite_language::EbiTraitFiniteLanguage, ebi_trait_semantics::EbiTraitSemantics
    },
    techniques::{
        any_traces::AnyTraces, bounded::Bounded, empty_traces::HasEmptyTraces, executions::FindExecutions, infinitely_many_traces::InfinitelyManyTraces, medoid_non_stochastic::MedoidNonStochastic, timestamps_ordered::TimestampsOrdered
    }, 
};
use ebi_objects::{EbiObject, EbiObjectType, ProcessTree, anyhow::anyhow};
use std::io::Write;

pub const EBI_ANALYSE_NON_STOCHASTIC: EbiCommand = EbiCommand::Group {
    name_short: "anans",
    name_long: Some("analyse-non-stochastic"),
    explanation_short: "Analyse a language without considering its stochastic perspective.",
    explanation_long: None,
    children: &[
        &EBI_ANALYSE_NON_STOCHASTIC_ACTIVITIES,
        &EBI_ANALYSE_NON_STOCHASTIC_ANY_TRACES,
        &EBI_ANALYSE_NON_STOCHASTIC_BOUNDED,
        &EBI_ANALYSE_NON_STOCHASTIC_CLUSTER,
        &EBI_ANALYSE_NON_STOCHASTIC_EMPTY_TRACES,
        &EBI_ANALYSE_NON_STOCHASTIC_EXECUTIONS,
        &EBI_ANALYSE_NON_STOCHASTIC_INFINITELY_MANY_TRACES,
        &EBI_ANALYSE_NON_STOCHASTIC_MEDOID,
        &EBI_ANALYSE_NON_STOCHASTIC_TIMESTAMPS_ORDERED,
    ],
};

pub const EBI_ANALYSE_NON_STOCHASTIC_ACTIVITIES: EbiCommand = EbiCommand::Command {
    name_short: "act",
    name_long: Some("activities"),
    explanation_short: "Shows the activities that are declared in the object.",
    explanation_long: None,
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[&[&EbiInputType::Trait(EbiTrait::Activities)]],
    input_names: &["FILE"],
    input_helps: &["Any object with activities"],
    execute: |mut objects, _| {
        let activities = objects.remove(0).to_type::<dyn EbiTraitActivities>()?;
        let mut f = vec![];
        for label in &activities.activity_key().activity2name {
            writeln!(f, "{}", label)?;
        }
        Ok(EbiOutput::String(String::from_utf8(f)?))
    },
    output_type: &EbiOutputType::String,
};

pub const EBI_ANALYSE_NON_STOCHASTIC_BOUNDED: EbiCommand = EbiCommand::Command {
    name_short: "bnd",
    name_long: Some("bounded"),
    explanation_short: "Compute whether the model has a bounded state space.",
    explanation_long: Some(
        "Compute whether the model has a bounded state space. 
        For Petri nets, a coverability graph is computed~\\cite{esparza2019petri}. 
        For other types of models, `true' is returned.",
    ),
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[&[
        // &EbiInputType::Object(EbiObjectType::BusinessProcessModelAndNotation),
        &EbiInputType::Object(EbiObjectType::DirectlyFollowsGraph),
        &EbiInputType::Object(EbiObjectType::StochasticProcessTree),
        &EbiInputType::Object(EbiObjectType::ProcessTree),
        &EbiInputType::Object(EbiObjectType::StochasticDirectlyFollowsModel),
        &EbiInputType::Object(EbiObjectType::DirectlyFollowsModel),
        &EbiInputType::Object(EbiObjectType::EventLog),
        &EbiInputType::Object(EbiObjectType::FiniteStochasticLanguage),
        &EbiInputType::Object(EbiObjectType::FiniteLanguage),
        &EbiInputType::Object(EbiObjectType::StochasticDeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::StochasticNondeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::DeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::StochasticLabelledPetriNet),
        &EbiInputType::Object(EbiObjectType::LabelledPetriNet),
    ]],
    input_names: &["MODEL"],
    input_helps: &["The model."],
    execute: |mut objects, _| {
        let model = objects.remove(0);
        let result = match model {
            EbiInput::Object(EbiObject::ProcessTree(tree), _) => tree.bounded()?,
            EbiInput::Object(EbiObject::StochasticProcessTree(tree), _) => tree.bounded()?,
            EbiInput::Object(EbiObject::LabelledPetriNet(lpn), _) => lpn.bounded()?,
            EbiInput::Object(EbiObject::StochasticLabelledPetriNet(slpn), _) => slpn.bounded()?,
            EbiInput::Object(EbiObject::DeterministicFiniteAutomaton(dfa), _) => dfa.bounded()?,
            EbiInput::Object(EbiObject::StochasticDeterministicFiniteAutomaton(sdfa), _) => {
                sdfa.bounded()?
            }
            EbiInput::Object(EbiObject::StochasticNondeterministicFiniteAutomaton(sdfa), _) => {
                sdfa.bounded()?
            }
            EbiInput::Object(EbiObject::EventLog(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::EventLogCsv(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::EventLogEventAttributes(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::EventLogOcel(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::EventLogPython(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::EventLogTraceAttributes(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::EventLogXes(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::FiniteLanguage(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::FiniteStochasticLanguage(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::FiniteStochasticPartiallyOrderedLanguage(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::DirectlyFollowsModel(object), _) => object.bounded()?,
            EbiInput::Object(EbiObject::StochasticDirectlyFollowsModel(object), _) => {
                object.bounded()?
            }
            EbiInput::Object(EbiObject::DirectlyFollowsGraph(object), _) => object.bounded()?,

            EbiInput::Object(EbiObject::BusinessProcessModelAndNotation(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::StochasticBusinessProcessModelAndNotation(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Trait(_, _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::String(_, _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Usize(_, _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::FileHandler(_) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Fraction(_, _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::Executions(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::LanguageOfAlignments(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::StochasticLanguageOfAlignments(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::ScalableVectorGraphics(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::PortableDocumentFormat(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
            EbiInput::Object(EbiObject::PortableNetworkGraphics(_), _) => {
                return Err(anyhow!("Cannot compute whether object is bounded."));
            }
        };
        if result {
            log::debug!("The model has a bounded state space.");
        } else {
            log::debug!("The model has an unbounded state space.")
        }
        return Ok(EbiOutput::Bool(result));
    },
    output_type: &EbiOutputType::Bool,
};

pub const EBI_ANALYSE_NON_STOCHASTIC_CLUSTER: EbiCommand = EbiCommand::Command {
    name_short: "clus",
    name_long: Some("cluster"),
    explanation_short: "Apply k-medoid clustering on a finite set of traces, without considering the stochastic perspective.",
    explanation_long: Some(
        "Apply k-medoid clustering: group the traces into a given number of clusters, such that the average distance of each trace to its closest medoid is minimal. The computation is random and does not take into account how often each trace occurs.",
    ),
    latex_link: Some("~\\cite{DBLP:journals/is/SchubertR21}"),
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[
        &[&EbiInputType::Trait(EbiTrait::FiniteLanguage)],
        &[&EbiInputType::Usize(Some(1), None, None)],
    ],
    input_names: &["LANGUAGE", "NUMBER_OF_CLUSTERS"],
    input_helps: &["The finite stochastic language.", "The number of clusters."],
    execute: |mut objects, _| {
        let language = objects.remove(0).to_type::<dyn EbiTraitFiniteLanguage>()?;
        let number_of_clusters = objects.remove(0).to_type::<usize>()?;
        let result = language.k_medoids_clustering(*number_of_clusters)?;
        return Ok(EbiOutput::Object(EbiObject::FiniteLanguage(result)));
    },
    output_type: &EbiOutputType::ObjectType(EbiObjectType::FiniteLanguage),
};

pub const EBI_ANALYSE_NON_STOCHASTIC_EMPTY_TRACES: EbiCommand = EbiCommand::Command { 
    name_short: "et", 
    name_long: Some("empty-traces"), 
    explanation_short: "Returns wheter the log or model contains empty traces.",
    explanation_long: None, 
    latex_link: None, 
    cli_command: None, 
    exact_arithmetic: true, 
    input_types: &[
        &[&EbiInputType::Object(EbiObjectType::ProcessTree)],
    ], 
    input_names: &["FILE"], 
    input_helps: &["A file"], 
    execute: |mut objects, _| {
        let model = objects.remove(0).to_type::<ProcessTree>()?;

        Ok(EbiOutput::Bool(model.has_empty_traces()))
    }, 
    output_type: &EbiOutputType::Bool
};



pub const EBI_ANALYSE_NON_STOCHASTIC_EXECUTIONS: EbiCommand = EbiCommand::Command {
    name_short: "exs",
    name_long: Some("executions"),
    explanation_short: "Compute the executions of each transition of the model in the log.",
    explanation_long: Some(
        "Compute executions.\nNB 1: the model must be able to terminate and its states must be bounded.\nNB 2: the search performed is not optimised. For Petri nets, the ProM implementation may be more efficient.",
    ),
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[
        &[&EbiInputType::Trait(EbiTrait::EventLogEventAttributes)],
        &[&EbiInputType::Trait(EbiTrait::Semantics)],
    ],
    input_names: &["LOG", "MODEL"],
    input_helps: &["The event log.", "The model."],
    execute: |mut objects, _| {
        let mut log: Box<dyn EbiTraitEventLogEventAttributes> = objects.remove(0).to_type::<dyn EbiTraitEventLogEventAttributes>()?;
        let mut model = objects.remove(0).to_type::<EbiTraitSemantics>()?;

        let result = model.find_executions(&mut log)?;

        return Ok(EbiOutput::Object(EbiObject::Executions(result)));
    },
    output_type: &EbiOutputType::ObjectType(EbiObjectType::Executions),
};

pub const EBI_ANALYSE_NON_STOCHASTIC_ANY_TRACES: EbiCommand = EbiCommand::Command {
    name_short: "at",
    name_long: Some("any-traces"),
    explanation_short: "Compute whether the model has any traces.",
    explanation_long: Some(
        "Compute whether the model has any traces.
        Reasons for a model not to have any traces could be if the initial state is part of a livelock, or if there is no initial state.
        'true' means that the model has traces, 'false' means that the model has no traces.
        The computation may not terminate if the model is unbounded.",
    ),
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[&[
        // &EbiInputType::Object(EbiObjectType::BusinessProcessModelAndNotation),
        &EbiInputType::Object(EbiObjectType::DirectlyFollowsGraph),
        &EbiInputType::Object(EbiObjectType::StochasticProcessTree),
        &EbiInputType::Object(EbiObjectType::ProcessTree),
        &EbiInputType::Object(EbiObjectType::StochasticDirectlyFollowsModel),
        &EbiInputType::Object(EbiObjectType::DirectlyFollowsModel),
        &EbiInputType::Object(EbiObjectType::EventLog),
        &EbiInputType::Object(EbiObjectType::FiniteStochasticLanguage),
        &EbiInputType::Object(EbiObjectType::FiniteLanguage),
        &EbiInputType::Object(EbiObjectType::StochasticDeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::DeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::StochasticNondeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::StochasticLabelledPetriNet),
        &EbiInputType::Object(EbiObjectType::LabelledPetriNet),
    ]],
    input_names: &["MODEL"],
    input_helps: &["The model."],
    execute: |mut objects, _| {
        let model = objects.remove(0);
        let result = match model {
            EbiInput::Object(EbiObject::ProcessTree(tree), _) => tree.any_traces()?,
            EbiInput::Object(EbiObject::StochasticProcessTree(tree), _) => tree.any_traces()?,
            EbiInput::Object(EbiObject::LabelledPetriNet(lpn), _) => lpn.any_traces()?,
            EbiInput::Object(EbiObject::StochasticLabelledPetriNet(slpn), _) => {
                slpn.any_traces()?
            }
            EbiInput::Object(EbiObject::DeterministicFiniteAutomaton(dfa), _) => {
                dfa.any_traces()?
            }
            EbiInput::Object(EbiObject::StochasticDeterministicFiniteAutomaton(sdfa), _) => {
                sdfa.any_traces()?
            }
            EbiInput::Object(EbiObject::StochasticNondeterministicFiniteAutomaton(sdfa), _) => {
                sdfa.any_traces()?
            }
            EbiInput::Object(EbiObject::EventLog(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::EventLogCsv(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::EventLogEventAttributes(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::EventLogOcel(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::EventLogPython(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::EventLogTraceAttributes(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::EventLogXes(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::FiniteLanguage(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::FiniteStochasticLanguage(object), _) => {
                object.any_traces()?
            }
            EbiInput::Object(EbiObject::FiniteStochasticPartiallyOrderedLanguage(object), _) => {
                object.any_traces()?
            }
            EbiInput::Object(EbiObject::DirectlyFollowsModel(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::StochasticDirectlyFollowsModel(object), _) => object.any_traces()?,
            EbiInput::Object(EbiObject::DirectlyFollowsGraph(object), _) => object.any_traces()?,
            
            EbiInput::Object(EbiObject::BusinessProcessModelAndNotation(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::StochasticBusinessProcessModelAndNotation(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Trait(_, _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::String(_, _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Usize(_, _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::FileHandler(_) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Fraction(_, _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::Executions(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::LanguageOfAlignments(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::StochasticLanguageOfAlignments(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::ScalableVectorGraphics(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::PortableDocumentFormat(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
            EbiInput::Object(EbiObject::PortableNetworkGraphics(_), _) => {
                return Err(anyhow!("Cannot compute whether object has traces."));
            }
        };
        if result {
            log::debug!("The model cannot terminate and has an empty language.");
        } else {
            log::debug!("The model can terminate and has traces.")
        }
        return Ok(EbiOutput::Bool(result));
    },
    output_type: &EbiOutputType::Bool,
};

pub const EBI_ANALYSE_NON_STOCHASTIC_INFINITELY_MANY_TRACES: EbiCommand = EbiCommand::Command {
    name_short: "inft",
    name_long: Some("infinitely-many-traces"),
    explanation_short: "Compute whether the model has infinitely many traces.",
    explanation_long: Some(
        "Compute whether the model has infinitely many traces. The computation may not terminate if the model is unbounded.",
    ),
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[&[
        &EbiInputType::Object(EbiObjectType::EventLog),
        &EbiInputType::Object(EbiObjectType::FiniteStochasticLanguage),
        &EbiInputType::Object(EbiObjectType::FiniteLanguage),
        &EbiInputType::Object(EbiObjectType::DirectlyFollowsGraph),
        &EbiInputType::Object(EbiObjectType::StochasticDirectlyFollowsModel),
        &EbiInputType::Object(EbiObjectType::DirectlyFollowsModel),
        &EbiInputType::Object(EbiObjectType::StochasticProcessTree),
        &EbiInputType::Object(EbiObjectType::ProcessTree),
        &EbiInputType::Object(EbiObjectType::StochasticDeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::DeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::StochasticNondeterministicFiniteAutomaton),
        &EbiInputType::Object(EbiObjectType::StochasticLabelledPetriNet),
        &EbiInputType::Object(EbiObjectType::LabelledPetriNet),
    ]],
    input_names: &["MODEL"],
    input_helps: &["The model."],
    execute: |mut objects, _| {
        let model = objects.remove(0);
        let result = match model {
            EbiInput::Object(EbiObject::EventLog(object), _) => object.infinitely_many_traces()?,
            EbiInput::Object(EbiObject::FiniteLanguage(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::FiniteStochasticLanguage(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::StochasticProcessTree(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::ProcessTree(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::DeterministicFiniteAutomaton(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::StochasticDeterministicFiniteAutomaton(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::StochasticNondeterministicFiniteAutomaton(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::LabelledPetriNet(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::StochasticLabelledPetriNet(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::DirectlyFollowsGraph(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::DirectlyFollowsModel(object), _) => {
                object.infinitely_many_traces()?
            }
            EbiInput::Object(EbiObject::StochasticDirectlyFollowsModel(object), _) => {
                object.infinitely_many_traces()?
            }
            _ => return Err(anyhow!("Unsupported object {:?} provided.", model.get_type())),
        };
        if result {
            log::debug!("The language of the model has infinitely many traces.");
        } else {
            log::debug!("The language of the model has finitely many traces.")
        }
        return Ok(EbiOutput::Bool(result));
    },
    output_type: &EbiOutputType::Bool,
};

pub const EBI_ANALYSE_NON_STOCHASTIC_MEDOID: EbiCommand = EbiCommand::Command {
    name_short: "med",
    name_long: Some("medoid"),
    explanation_short: "Find the traces with the least distance to the other traces, without considering the stochastic perspective.",
    explanation_long: Some(
        "Find the traces with the lowest average normalised Levenshtein distance to the other traces; ties are resolved arbritrarily. The computation is random and does not take into account how often each trace occurs.",
    ),
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[
        &[&EbiInputType::Trait(EbiTrait::FiniteLanguage)],
        &[&EbiInputType::Usize(Some(1), None, Some(1))],
    ],
    input_names: &["FILE", "NUMBER_OF_TRACES"],
    input_helps: &[
        "The finite stochastic language.",
        "The number of traces that should be extracted.",
    ],
    execute: |mut objects, _| {
        let language = objects.remove(0).to_type::<dyn EbiTraitFiniteLanguage>()?;
        let number_of_traces = objects.remove(0).to_type::<usize>()?;
        let language: Box<dyn EbiTraitFiniteLanguage> = language;
        let result = language.medoid(*number_of_traces)?;
        return Ok(EbiOutput::Object(EbiObject::FiniteLanguage(result)));
    },
    output_type: &EbiOutputType::ObjectType(EbiObjectType::FiniteLanguage),
};

pub const EBI_ANALYSE_NON_STOCHASTIC_TIMESTAMPS_ORDERED: EbiCommand = EbiCommand::Command {
    name_short: "to",
    name_long: Some("timestamps-ordered"),
    explanation_short: "Check whether all timestamps are in a correct order.",
    explanation_long: None,
    latex_link: None,
    cli_command: None,
    exact_arithmetic: true,
    input_types: &[
        &[
            &EbiInputType::Trait(EbiTrait::EventLogEventAttributes), 
            &EbiInputType::Object(EbiObjectType::Executions)
        ]
    ],
    input_names: &["LOG"],
    input_helps: &["The event log"],
    execute: |mut objects, _| {
        let result = match objects.remove(0) {
            EbiInput::Trait(EbiTraitObject::EventLogEventAttributes(log), _) => log.are_timestamps_ordered(),
            EbiInput::Object(EbiObject::Executions(exs), _) => exs.are_timestamps_ordered(),
            o => return Err(anyhow!("Unsupported object {:?} provided.", o.get_type()))
        };
        Ok(EbiOutput::Bool(result?))
    }, 
    output_type: &EbiOutputType::Bool,
};