-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from AutomatedProcessImprovement/conditions
Conditions
- Loading branch information
Showing
61 changed files
with
1,535 additions
and
2,539 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "simod" | ||
version = "4.1.1" | ||
version = "5.0.0" | ||
authors = [ | ||
"Ihar Suvorau <[email protected]>", | ||
"David Chapela <[email protected]>", | ||
|
@@ -34,10 +34,10 @@ scipy = "^1.9.2" | |
statistics = "^1.0.3.5" | ||
tqdm = "^4.64.1" | ||
xmltodict = "^0.13.0" | ||
prosimos = "^2.0.3" | ||
prosimos = "^2.0.5" | ||
extraneous-activity-delays = "^2.1.21" | ||
openxes-cli-py = "^0.1.15" | ||
pix-framework = "^0.13.8" | ||
pix-framework = "^0.13.16" | ||
log-distance-measures = "^1.0.2" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
|
File renamed without changes.
This file contains 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,30 @@ | ||
import pandas as pd | ||
from typing import List | ||
|
||
from simod.branch_rules.types import BranchRules | ||
|
||
from pix_framework.io.event_log import EventLogIDs | ||
from pix_framework.discovery.gateway_probabilities import GatewayProbabilities | ||
from pix_framework.discovery.gateway_conditions.gateway_conditions import discover_gateway_conditions | ||
|
||
|
||
def discover_branch_rules(bpmn_graph, log: pd.DataFrame, log_ids: EventLogIDs, f_score=0.7) -> list[BranchRules]: | ||
""" | ||
Discover branch_rules from a log. | ||
""" | ||
rules = discover_gateway_conditions(bpmn_graph, log, log_ids, f_score_threshold=f_score) | ||
|
||
rules = list(map(lambda x: BranchRules.from_dict(x), rules)) | ||
|
||
return rules | ||
|
||
|
||
def map_branch_rules_to_flows(gateway_probabilities: List[GatewayProbabilities], branch_rules: List[BranchRules]): | ||
condition_lookup = {rule.id: rule for rule in branch_rules} | ||
|
||
for gateway in gateway_probabilities: | ||
for path in gateway.outgoing_paths: | ||
if path.path_id in condition_lookup: | ||
path.condition_id = condition_lookup[path.path_id].id | ||
|
||
return gateway_probabilities |
This file contains 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,45 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class BranchRule: | ||
attribute: str | ||
comparison: str | ||
value: str | ||
|
||
@staticmethod | ||
def from_dict(data: dict) -> "BranchRule": | ||
return BranchRule( | ||
attribute=data["attribute"], | ||
comparison=data["comparison"], | ||
value=data["value"] | ||
) | ||
|
||
def to_dict(self): | ||
return { | ||
"attribute": self.attribute, | ||
"comparison": self.comparison, | ||
"value": self.value | ||
} | ||
|
||
|
||
@dataclass | ||
class BranchRules: | ||
id: str | ||
rules: list[list[BranchRule]] | ||
|
||
@staticmethod | ||
def from_dict(data: dict) -> "BranchRules": | ||
return BranchRules( | ||
id=data["id"], | ||
rules=[ | ||
[BranchRule.from_dict(rule) for rule in rule_set] | ||
for rule_set in data["rules"] | ||
] | ||
) | ||
|
||
def to_dict(self): | ||
return { | ||
"id": self.id, | ||
"rules": [[rule.to_dict() for rule in rule_set] for rule_set in self.rules] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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
Empty file.
This file contains 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 @@ | ||
import pandas as pd | ||
|
||
from simod.data_attributes.types import GlobalAttribute, CaseAttribute, EventAttribute | ||
|
||
from pix_framework.io.event_log import EventLogIDs | ||
from pix_framework.discovery.attributes.attribute_discovery import discover_attributes | ||
|
||
|
||
def discover_data_attributes(log: pd.DataFrame, log_ids: EventLogIDs) -> (list[CaseAttribute], list[GlobalAttribute], list[EventAttribute]): | ||
""" | ||
Discover data attributes from a log ignoring common non-case columns. | ||
""" | ||
attributes = discover_attributes( | ||
event_log=log, | ||
log_ids=log_ids, | ||
avoid_columns=[ | ||
log_ids.case, | ||
log_ids.activity, | ||
log_ids.enabled_time, | ||
log_ids.start_time, | ||
log_ids.end_time, | ||
log_ids.resource, | ||
], | ||
confidence_threshold=0.95, | ||
) | ||
|
||
global_attributes = list(map(GlobalAttribute.from_dict, attributes["global_attributes"])) | ||
case_attributes = list(map(CaseAttribute.from_dict, attributes["case_attributes"])) | ||
event_attributes = list(map(EventAttribute.from_dict, attributes["event_attributes"])) | ||
|
||
return global_attributes, case_attributes, event_attributes |
Oops, something went wrong.