# Conflict resolution. Background Input: set of « fireable instances » –Instance = (, substitution) –Substitution = {(c i /?x i )} for all ?x i in Var(rule)

## Presentation on theme: "Conflict resolution. Background Input: set of « fireable instances » –Instance = (, substitution) –Substitution = {(c i /?x i )} for all ?x i in Var(rule)"— Presentation transcript:

Conflict resolution

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

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

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!

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!

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

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!

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!

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 –…

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.

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!

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?

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] –…

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.

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!

Problems with import No-repeat on single rules No-repeat on variables

Download ppt "Conflict resolution. Background Input: set of « fireable instances » –Instance = (, substitution) –Substitution = {(c i /?x i )} for all ?x i in Var(rule)"

Similar presentations