Download presentation
Presentation is loading. Please wait.
Published byEvan Dunlap Modified over 11 years ago
1
Conflict resolution
2
Background Input: set of « fireable instances » –Instance = (, substitution) –Substitution = {(c i /?x i )} for all ?x i in Var(rule) –Firable = instantiated condition is satisfied Output: set of instances to be fired E.g. –Remove according to « no-repeat » –Order according to XYZ –Keep only first
3
No-repeat Proposal 1 –Remove instance such that rule has already been fired with same instantiated action part and a instance of the rule with that same instantiated action part has always been firable since
4
Example 1 Rules –R1: IF Alarm(?x) THEN printRed(« Alarm ») Facts –Alarm(D1) –Alarm(D2) Execution –Cycle1: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}} FireOne: (R1 {(D1/?x)}) Alarm –Cycle2: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}} No-repeat: Fireable = {} Stop!
5
Example 1 Rules –R1: IF Alarm(?x) THEN printRed(« Alarm ») Facts –Alarm(D1) –Alarm(D2) Execution –Cycle1: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}} FireAll: {(R1 {(D1/?x)}), (R1 {(D2/?x)}} Alarm Alarm –Cycle2: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}} No-repeat: Fireable = {} Stop!
6
Example 1 Rules –R1: IF Alarm(?x) THEN printRed(« Alarm ») –R2: IF Alarm(?Y) THEN printRed(« Alarm ») Facts –Alarm(D1) –Alarm(D2) Execution –Cycle1: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}), (R2 {(D1/?y)}), (R2 {(D2/?Y)})} FireOne (R1 {(D1/?x)})Alarm –Cycle2: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}), (R2 {(D1/?y)}), (R2 {(D2/?Y)})} No-repeat: Fireable = {(R2 {(D1/?y)}), (R2 {(D2/?Y)})} FireOne (R2 {(D1/?x)})Alarm –Cycle3: Fireable = {(R1 {(D1/?x)}), (R1 {(D2/?x)}), (R2 {(D1/?y)}), (R2 {(D2/?Y)})} No-repeat: Fireable = {} Stop
7
Example 2 Rules –R1: ?s#Sensor IF ?s[reading->?v] & ?v>100 THEN printRed (« Alarm » ?s) Facts –S1[value->200] Execution –Cycle1: Fireable = {(R1 {(S1/?s)})} FireOne (R1 {(S1/?s)}) Alarm S1 –Cycle2: Fireable = {(R1 {(S1/?s)})} No-repeat: Fireable = {} Stop!
8
Example 3 Rules –R1: ?s#Sensor IF ?s[reading->?v] & ?v>100 THEN printRed (« Alarm » ?s) Facts –S1[value->200] Execution –Cycle1: Facts: S1[value->200] Fireable = {(R1 {(S1/?s)})} FireOne (R1 {(S1/?s)}) Alarm S1 –Cycle2: Facts: S1[value->300] Fireable = {(R1 {(S1/?s)})} No-repeat: Fireable = {} Stop!
9
Example 4 Rules –R1: ?s#Sensor IF ?s[reading->?v] & ?v>100 THEN printRed (« Alarm » ?s ?v) Facts –S1[value->200] Execution –Cycle1: Facts: S1[value->200] Fireable = {(R1 {(S1/?s), (200/?v)})} FireOne (R1 {(S1/?s), (200/?v)}) Alarm S1 200 –Cycle2: Facts: S1[value->300] No-repeat: Fireable = {(R1 {(S1/?s), (300/?v)})} FireOne (R1 {(S1/?s), (300/?v)}) Alarm S1 300 –…
10
No-repeat Proposal 2 –Remove instance such that rule has already been fired with same instantiation for listed variables and a instance of the rule with that same instantiation for listed variables has always been firable since.
11
Example 4 (specify variables) Rules –R1: (no-loop: ?s) ?s#Sensor IF ?s[reading->?v] & ?v>100 THEN printRed (« Alarm » ?s ?v) Facts –S1[value->200] Execution –Cycle1: Facts: S1[value->200] Fireable = {(R1 {(S1/?s), (200/?v)})} FireOne (R1 {(S1/?s), (200/?v)}) Alarm S1 200 –Cycle2: Facts: S1[value->300] No-repeat: Fireable = {} Stop!
12
No-repeat Proposal 2 –Remove instance such that rule has already been fired with same instantiation for listed variables and a instance of the rule with that same instantiation for listed variables has always been firable since. –Keys only?
13
Example 5 Rules –R1: ?e#employee IF ?e[salary->?s] & ?s>100 THEN Retract(?e[salary->?s]), Assert(?e[salary->?s*1.1]) Execution –Cycle1: Facts: John[salary->50] Fireable = {(R1 {(S1John/?e), (50/?s)})} FireOne (R1 {(S1John/?e), (50/?s)}) Facts: John[salary->55] –Cycle2: Facts: John[salary->55] Fireable = {(R1 {(S1John/?e), (55/?s)})} FireOne (R1 {(S1John/?e), (55/?s)}) Facts: John[salary->60.5] –…
14
No-repeat Proposal 3 –Remove instance such that rule has already been fired with same [instantiated action part| instantiation for listed variables] and a instance of the rule with that same [instantiated action part | instantiation for listed variables] has always been firable since, where the new values of MODIFYed variables are carried on.
15
Example 5 (modified) Rules –R1: ?e#employee IF ?e[salary->?s] & ?s>100 THEN Retract(?e[salary->?s]), Assert(?e[salary->?s*1.1]) Execution –Cycle1: Facts: John[salary->50] Fireable = {(R1 {(S1John/?e), (50/?s)})} FireOne (R1 {(S1John/?e), (50/?s)}) Facts: John[salary->55] Fired = {(R1 {(S1John/?e), (55/?s)})} –Cycle2: Facts: John[salary->55] No-repeat: Fireable = {} Stop!
16
Problems with import No-repeat on single rules No-repeat on variables
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.