def setUpClass(cls): causal_forest_modified = [ { "node_type": "root", "symbol_type": "fluent", "symbol": "light_on", "children": [ { "node_type": "and", "probability": .25, "children": [ #on inertially -- higher chance of occurrence? { "node_type": "leaf", "symbol": "light_on", "symbol_type": "prev_fluent" }, { "node_type": "leaf", "symbol": "A3", "symbol_type": "nonevent", "timeout": 10 }, { "node_type": "leaf", "symbol": "A4", "symbol_type": "nonevent", "timeout": 10 }, ]}, { "node_type": "and", "probability": .375, "children": [ #on by causing action { "node_type": "leaf", "symbol_type": "prev_fluent", "symbol": "light_off" }, { "node_type": "leaf", "symbol_type": "event", "symbol": "FLIPSWITCH", "timeout": 10 }, ] }, { "node_type": "and", "probability": .375, "children": [ #on by causing action { "node_type": "leaf", "symbol_type": "prev_fluent", "symbol": "light_off" }, { "node_type": "leaf", "symbol_type": "event", "symbol": "A2", "timeout": 10 }, ] }, ], }, { "node_type": "root", "symbol_type": "fluent", "symbol": "light_off", "children": [ { "node_type": "and", "probability": .25, "children": [ #off inertially { "node_type": "leaf", "symbol": "light_off", "symbol_type": "prev_fluent" }, { "node_type": "leaf", "symbol": "FLIPSWITCH", "symbol_type": "nonevent", "timeout": 10 }, { "node_type": "leaf", "symbol": "A2", "symbol_type": "nonevent", "timeout": 10 }, ]}, { "node_type": "and", "probability": .375, "children": [ #off by causing action { "node_type": "leaf", "symbol_type": "prev_fluent", "symbol": "light_on" }, { "node_type": "leaf", "symbol_type": "event", "symbol": "A3", "timeout": 10 }, ] }, { "node_type": "and", "probability": .375, "children": [ #off by causing action { "node_type": "leaf", "symbol_type": "prev_fluent", "symbol": "light_on" }, { "node_type": "leaf", "symbol_type": "event", "symbol": "A4", "timeout": 10 }, ] }, ], }, ] fluents_simple_light = { 8: { "light": causal_grammar.probability_to_energy(.9)}, #light turns on at 8 } actions_simple_light = { 5: { "FLIPSWITCH": {"energy": causal_grammar.probability_to_energy(.9), "agent": ("uuid4")} }, 6: { "A2": {"energy": causal_grammar.probability_to_energy(.6), "agent": ("uuid4")} }, } xml_string = causal_grammar.process_events_and_fluents(causal_forest_modified, fluents_simple_light, actions_simple_light, causal_grammar.kFluentThresholdOnEnergy, causal_grammar.kFluentThresholdOffEnergy, causal_grammar.kReportingThresholdEnergy,not kDebug, handle_overlapping_events = True) # !kDebug: suppress output cls.root = ET.fromstring(xml_string) if kDebug: print(xml_string)
def setUpClass(cls): fluents_simple_light = { 6: { "light": causal_grammar.probability_to_energy(.9)}, #light turns on at 6 8: { "light": causal_grammar.probability_to_energy(.6)}, #light turns on at 8 } actions_simple_light = { 5: { "FLIPSWITCH": {"energy": causal_grammar.probability_to_energy(.9), "agent": ("uuid4")} }, } xml_string = causal_grammar.process_events_and_fluents(causal_forest_light, fluents_simple_light, actions_simple_light, causal_grammar.kFluentThresholdOnEnergy, causal_grammar.kFluentThresholdOffEnergy, causal_grammar.kReportingThresholdEnergy,not kDebug, handle_overlapping_events = True) # !kDebug: suppress output cls.root = ET.fromstring(xml_string) if kDebug: print(xml_string)
def setUpClass(cls): fluents_simple_thirst = { 5: { "thirst": causal_grammar.probability_to_energy(.1)}, #thirst turns off at 5 20: { "thirst": causal_grammar.probability_to_energy(.1)}, #thirst turns off at 20 } actions_simple_thirst = { 4: { "DRINK": {"energy": causal_grammar.probability_to_energy(.9), "agent": ("uuid4")} }, #energy = .11 19: { "DRINK": {"energy": causal_grammar.probability_to_energy(.9), "agent": ("uuid4")} }, #energy = .11 } xml_string = causal_grammar.process_events_and_fluents(causal_forest_thirst, fluents_simple_thirst, actions_simple_thirst, causal_grammar.kFluentThresholdOnEnergy, causal_grammar.kFluentThresholdOffEnergy, causal_grammar.kReportingThresholdEnergy,suppress_output = not kDebug, handle_overlapping_events = False) cls.root = ET.fromstring(xml_string) if kDebug: print(xml_string)
def setUpClass(cls): causal_forest = [ { "node_type": "root", "symbol_type": "fluent", "symbol": "fluent_on", "children": [ { "node_type": "and", "probability": .6, "children": [ #on inertially - not turned off { "node_type": "leaf", "symbol": "fluent_on", "symbol_type": "prev_fluent" }, { "node_type": "leaf", "symbol": "OFFACTION", "symbol_type": "nonevent", "timeout": 3 }, ]}, { "node_type": "and", "probability": .4, "children": [ #on by causing action { "node_type": "leaf", "symbol_type": "prev_fluent", "symbol": "fluent_off" }, { "node_type": "leaf", "symbol_type": "event", "symbol": "ONACTION", "timeout": 1 }, ] }, ], }, { "node_type": "root", "symbol_type": "fluent", "symbol": "fluent_off", "children": [ { "node_type": "and", "probability": .6, "children": [ #off inertially #energy = .51 { "node_type": "leaf", "symbol": "fluent_off", "symbol_type": "prev_fluent" }, { "node_type": "leaf", "symbol": "OFFACTION", "symbol_type": "nonevent", "timeout": 3 }, ]}, { "node_type": "and", "probability": .4, "children": [ #off by causing action A1 { "node_type": "leaf", "symbol_type": "prev_fluent", "symbol": "fluent_on" }, { "node_type": "leaf", "symbol_type": "event", "symbol": "OFFACTION", "timeout": 1 }, ] }, ], }, ] fluents_simple = { 5: { "fluent": causal_grammar.probability_to_energy(.9)}, #light turns off at 5 -- energy = .51 } actions_simple = { 1: { "OFFACTION": {"energy": causal_grammar.probability_to_energy(.9), "agent": ("uuid4")} }, #energy = .11 } xml_string = causal_grammar.process_events_and_fluents(causal_forest, fluents_simple, actions_simple, causal_grammar.kFluentThresholdOnEnergy, causal_grammar.kFluentThresholdOffEnergy, causal_grammar.kReportingThresholdEnergy,not kDebug, handle_overlapping_events = True) # !kDebug: suppress output cls.root = ET.fromstring(xml_string) if kDebug: print(xml_string)