def mp_exclusive_choice(trace, done, a, b, rules): activation_rules = rules["activation"] a_occurs = False b_occurs = False for A in trace: if not a_occurs and A["concept:name"] == a: if eval(activation_rules): a_occurs = True if not b_occurs and A["concept:name"] == b: if eval(activation_rules): b_occurs = True if a_occurs and b_occurs: break state = None if not done and (not a_occurs and not b_occurs): state = TraceState.POSSIBLY_VIOLATED elif not done and (a_occurs ^ b_occurs): state = TraceState.POSSIBLY_SATISFIED elif (a_occurs and b_occurs) or (done and (not a_occurs and not b_occurs)): state = TraceState.VIOLATED elif done and (a_occurs ^ b_occurs): state = TraceState.SATISFIED return CheckerResult(num_fulfillments=None, num_violations=None, num_pendings=None, num_activations=None, state=state)
def mp_init(trace, done, a, rules): activation_rules = rules["activation"] state = TraceState.VIOLATED if trace[0]["concept:name"] == a: A = trace[0] if eval(activation_rules): state = TraceState.SATISFIED return CheckerResult(num_fulfillments=None, num_violations=None, num_pendings=None, num_activations=None, state=state)
def mp_responded_existence(trace, done, a, b, rules): activation_rules = rules["activation"] correlation_rules = rules["correlation"] vacuous_satisfaction = rules["vacuous_satisfaction"] pendings = [] num_fulfillments = 0 num_violations = 0 num_pendings = 0 for event in trace: if event["concept:name"] == a: A = event if eval(activation_rules): pendings.append(event) for event in trace: if len(pendings) == 0: break if event["concept:name"] == b: T = event for A in reversed(pendings): if eval(correlation_rules): pendings.remove(A) num_fulfillments += 1 if done: num_violations = len(pendings) else: num_pendings = len(pendings) num_activations = num_fulfillments + num_violations + num_pendings state = None if not vacuous_satisfaction and num_activations == 0: if done: state = TraceState.VIOLATED else: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations > 0: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations == 0: state = TraceState.POSSIBLY_SATISFIED elif done and num_violations > 0: state = TraceState.VIOLATED elif done and num_violations == 0: state = TraceState.SATISFIED return CheckerResult(num_fulfillments=num_fulfillments, num_violations=num_violations, num_pendings=num_pendings, num_activations=num_activations, state=state)
def mp_alternate_response(trace, done, a, b, rules): activation_rules = rules["activation"] correlation_rules = rules["correlation"] vacuous_satisfaction = rules["vacuous_satisfaction"] pending = None num_activations = 0 num_fulfillments = 0 num_pendings = 0 for event in trace: if event["concept:name"] == a: A = event if eval(activation_rules): pending = event num_activations += 1 if event["concept:name"] == b and pending is not None: A = pending T = event if eval(correlation_rules): pending = None num_fulfillments += 1 if not done and pending is not None: num_pendings = 1 num_violations = num_activations - num_fulfillments - num_pendings state = None if not vacuous_satisfaction and num_activations == 0: if done: state = TraceState.VIOLATED else: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations == 0 and num_pendings > 0: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations == 0 and num_pendings == 0: state = TraceState.POSSIBLY_SATISFIED elif num_violations > 0 or (done and num_pendings > 0): state = TraceState.VIOLATED elif done and num_violations == 0 and num_pendings == 0: state = TraceState.SATISFIED return CheckerResult(num_fulfillments=num_fulfillments, num_violations=num_violations, num_pendings=num_pendings, num_activations=num_activations, state=state)
def mp_chain_response(trace, done, a, b, rules): activation_rules = rules["activation"] correlation_rules = rules["correlation"] vacuous_satisfaction = rules["vacuous_satisfaction"] num_activations = 0 num_fulfillments = 0 num_pendings = 0 for index, event in enumerate(trace): if event["concept:name"] == a: A = event if eval(activation_rules): num_activations += 1 if index < len(trace) - 1: if trace[index + 1]["concept:name"] == b: T = trace[index + 1] if eval(correlation_rules): num_fulfillments += 1 else: if not done: num_pendings = 1 num_violations = num_activations - num_fulfillments - num_pendings state = None if not vacuous_satisfaction and num_activations == 0: if done: state = TraceState.VIOLATED else: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations == 0 and num_pendings > 0: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations == 0 and num_pendings == 0: state = TraceState.POSSIBLY_SATISFIED elif num_violations > 0 or (done and num_pendings > 0): state = TraceState.VIOLATED elif done and num_violations == 0 and num_pendings == 0: state = TraceState.SATISFIED return CheckerResult(num_fulfillments=num_fulfillments, num_violations=num_violations, num_pendings=num_pendings, num_activations=num_activations, state=state)
def mp_alternate_precedence(trace, done, a, b, rules): activation_rules = rules["activation"] correlation_rules = rules["correlation"] vacuous_satisfaction = rules["vacuous_satisfaction"] num_activations = 0 num_fulfillments = 0 Ts = [] for event in trace: if event["concept:name"] == a: Ts.append(event) if event["concept:name"] == b: A = event if eval(activation_rules): num_activations += 1 for T in Ts: if eval(correlation_rules): num_fulfillments += 1 break Ts = [] num_violations = num_activations - num_fulfillments state = None if not vacuous_satisfaction and num_activations == 0: if done: state = TraceState.VIOLATED else: state = TraceState.POSSIBLY_VIOLATED elif not done and num_violations == 0: state = TraceState.POSSIBLY_SATISFIED elif num_violations > 0: state = TraceState.VIOLATED elif done and num_violations == 0: state = TraceState.SATISFIED return CheckerResult(num_fulfillments=num_fulfillments, num_violations=num_violations, num_pendings=None, num_activations=num_activations, state=state)
def mp_existence(trace, done, a, rules): activation_rules = rules["activation"] n = rules["n"][ConstraintChecker.EXISTENCE] num_activations = 0 for A in trace: if A["concept:name"] == a and eval(activation_rules): num_activations += 1 state = None if not done and num_activations < n: state = TraceState.POSSIBLY_VIOLATED elif done and num_activations < n: state = TraceState.VIOLATED elif num_activations >= n: state = TraceState.SATISFIED return CheckerResult(num_fulfillments=None, num_violations=None, num_pendings=None, num_activations=None, state=state)
def mp_choice(trace, done, a, b, rules): activation_rules = rules["activation"] a_or_b_occurs = False for A in trace: if A["concept:name"] == a or A["concept:name"] == b: if eval(activation_rules): a_or_b_occurs = True break state = None if not done and not a_or_b_occurs: state = TraceState.POSSIBLY_VIOLATED elif done and not a_or_b_occurs: state = TraceState.VIOLATED elif a_or_b_occurs: state = TraceState.SATISFIED return CheckerResult(num_fulfillments=None, num_violations=None, num_pendings=None, num_activations=None, state=state)