********************************************************** @Name("TempIncrease") insert into TempIncrease select h2.ts as ts, h1.id as id, h2.temp as temp, com.cor.cep.util.UReals.minus(h2.temp, h1.temp) as incr, h1.prob * h1.prob * UReals.ge(com.cor.cep.util.UReals.minus(h2.temp,h1.temp), 2.0).getC() * UReals.lt(h1.ts,h2.ts).getC() * P_TempIncreaseRule as prob from pattern [(every (h1 = HomeEvent() -> h2=HomeEvent(UBooleans.toBoolean(UReals.ge(UReals.minus(h2.temp, h1.temp), 2)) and h2.id = h1.id)) ) where timer:within(1 minutes)]; ********************************************************** @Name ("TempWarning") insert into TempWarning select t4.ts as ts, t1.id as id, t4.temp as temp, t1.prob * t2.prob * t3.prob * t4.prob * " UBooleans.uand(UReals.ge(t1.temp, 33.0), UBooleans.uand(UBooleans.uand(UReals.gt(t2.temp,t1.temp),UReals.gt(t3.temp,t2.temp)),UReals.gt(t4.temp,t3.temp))).getC() * UBooleans.uand(UReals.lt(t1.ts,t2.ts),UBooleans.uand(UReals.lt(t2.ts,t3.ts),UReals.lt(t3.ts,t4.ts))).getC() * P_TempWarningRule as prob from pattern [(every (t1=TempIncrease(UBooleans.toBoolean(UReals.ge(t1.temp, 33.0)))) -> (t2=TempIncrease(UBooleans.toBoolean(UReals.gt(t2.temp,t1.temp)) and t2.id = t1.id)) -> (t3=TempIncrease(UBooleans.toBoolean(UReals.gt(t3.temp,t2.temp)) and t3.id = t1.id)) -> (t4=TempIncrease(UBooleans.toBoolean(UReals.gt(t4.temp,t3.temp)) and t4.id = t1.id))) where timer:within(5 minutes)]; ********************************************************** @Name("HighCo") insert into HighCo select h1.co as co, h1.ts as ts, h1.id as id, h1.prob * h1.prob * UReals.ge(h1.co,5000.0).getC() * P_HighCORule as prob from pattern [(every (h1 = HomeEvent(UBooleans.toBoolean(UReals.ge(h1.co,5000)))))]; ********************************************************** @Name("FireWarning") insert into FireWarning select tw.id as id, coh.ts as ts, tw.prob * coh.prob * UReals.lt(coh.ts,tw.ts).getC() * P_FireWarningRule as prob from pattern [(every (every (coh = HighCo()) -> every (tw = TempWarning(tw.id = coh.id)))) where timer:within(5 seconds)]; ********************************************************** @Name("NobodyHome") insert into NobodyHome\r\n" + select p.ts as ts, h.x as x, h.y as y, h.id as id, p.pid as pid, " h.prob * p.prob * " UBooleans.uand(UBooleans.unot(h.dopen), UBooleans.uor(UBooleans.uor(UBooleans.uor(UReals.le(p.x, UReals.minus(h.x, UReals.divideBy(UReals.sqrt(h.sqre),2))), UReals.ge(p.x, UReals.add(h.x, UReals.divideBy(UReals.sqrt(h.sqre),2)))), UReals.le(p.y, UReals.minus(h.y, UReals.divideBy(UReals.sqrt(h.sqre),2)))), UReals.ge(p.y, UReals.add(h.y, UReals.divideBy(UReals.sqrt(h.sqre),2))))).getC() * UReals.lt(h.ts,p.ts).getC() * P_NobodyHomeRule as prob from pattern [(every h=HomeEvent(UBooleans.toBoolean(UBooleans.unot(h.dopen))) -> (p=PersonEvent( UBooleans.toBoolean(UReals.le(p.x, UReals.minus(h.x,UReals.divideBy(UReals.sqrt(h.sqre),4)))) or UBooleans.toBoolean(UReals.ge(p.x, UReals.add(h.x,UReals.divideBy(UReals.sqrt(h.sqre),4)))) or UBooleans.toBoolean(UReals.le(p.y, UReals.minus(h.y,UReals.divideBy(UReals.sqrt(h.sqre),4)))) or UBooleans.toBoolean(UReals.ge(p.y, UReals.add(h.y,UReals.divideBy(UReals.sqrt(h.sqre),4))))))) where timer:within(10 seconds)]; ********************************************************** @Name("CallFireDepartment") insert into NotifyFireDepartment select fw.id as id, fw.ts as ts, nh.prob * fw.prob * UReals.lt(nh.ts,fw.ts).getC() * P_CallFireDepartmentRule as prob from pattern [(every (nh = NobodyHome())-> (fw = FireWarning(fw.id = nh.id))) where timer:within(5 seconds)];