Skip to content

Commit

Permalink
calculate fitness independet of tokens (#298)
Browse files Browse the repository at this point in the history
transitions without incoming arcs can always fire, therefore the fitness can be 1 without any produced or consumed tokens.
this is now reflected in the code
  • Loading branch information
phi1-h authored Dec 14, 2021
1 parent cf72dfe commit 413cee0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pm4py/evaluation/replay_fitness/variants/token_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def evaluate(aligned_traces, parameters=None):
total_c = sum([x["consumed_tokens"] for x in aligned_traces])
total_r = sum([x["remaining_tokens"] for x in aligned_traces])
total_p = sum([x["produced_tokens"] for x in aligned_traces])
if no_traces > 0 and total_c > 0 and total_p > 0:
if no_traces > 0:
perc_fit_traces = float(100.0 * fit_traces) / float(no_traces)
average_fitness = float(sum_of_fitness) / float(no_traces)
log_fitness = 0.5 * (1 - total_m / total_c) + 0.5 * (1 - total_r / total_p)
if total_c > 0 and total_p > 0:
log_fitness = 0.5 * (1 - total_m / total_c) + 0.5 * (1 - total_r / total_p)
return {"perc_fit_traces": perc_fit_traces, "average_trace_fitness": average_fitness, "log_fitness": log_fitness,
"percentage_of_fitting_traces": perc_fit_traces }

Expand Down

0 comments on commit 413cee0

Please sign in to comment.