def get_inputs(): """The designer specifies a mission using the predefined catalogue of patterns In addition to the patterns to use the designer specifies also in which context each goal can be active""" print("CUSTOM SPEC c2:") print(os.path.dirname(os.path.abspath(__file__))) """ Atomic propositions divided in s - sensor propositions (uncontrollable) l - location propositions (controllable e.g. goto) a - action propositions (controllable)""" ap = { "s": { "night_time": LTL("night_time"), "day_time": LTL("day_time"), "low_battery": LTL("low_battery"), "full_battery": LTL("full_battery"), "entrance": LTL("entrance"), "shop": LTL("shop"), "get_med": LTL("get_med"), "warehouse": LTL("warehouse"), "human_entered": LTL("human_entered"), "guard_entered": LTL("guard_entered"), "door_alarm": LTL("door_alarm"), "fire_alarm": LTL("fire_alarm") }, "l": { "go_entrace": LTL("go_entrace"), "go_counter": LTL("go_counter"), "go_back": LTL("go_back"), "go_warehouse": LTL("go_warehouse"), "go_charging_point": LTL("go_charging_point"), "go_safe_loc": LTL("go_safe_loc") }, "a": { "contact_station": LTL("contact_station"), "welcome_client": LTL("welcome_client"), "take_med": LTL("take_med"), "give_med": LTL("give_med") } } """ Contexts rules, e.g. shop xor warehouse etc.. Domain rules, e.g. different locations Liveness rules, i.e. assumptions when generating the controller e.g. GF alarm, GF !alarm""" rules = { "context": { "mutex": [[ap["s"]["shop"], ap["s"]["warehouse"]], [ap["s"]["day_time"], ap["s"]["night_time"]]], "inclusion": [ [ap["s"]["entrance"], ap["s"]["shop"]], [ap["s"]["human_entered"], ap["s"]["shop"]], [ap["s"]["get_med"], ap["s"]["entrance"]], [ap["s"]["fire_alarm"], ap["s"]["warehouse"]], [ap["s"]["door_alarm"], ap["s"]["shop"]], [ap["s"]["guard_entered"], ap["s"]["shop"]], ] }, "domain": { "mutex": [[ ap["l"]["go_entrace"], ap["l"]["go_counter"], ap["l"]["go_back"], ap["l"]["go_warehouse"], ap["l"]["go_charging_point"], ap["l"]["go_safe_loc"] ]], "inclusion": [] }, "environment": { "mutex": [], "inclusion": [], "liveness": [NotLTL(ap["s"]["fire_alarm"])] } } """List of specifications / goals""" list_of_goals = [ CGTGoal(name="night-time-patroling", description="patrol warehouse and shop during the night", context=(Context(ap["s"]["night_time"])), contracts=[ PContract([ SequencedPatroling([ ap["l"]["go_entrace"], ap["l"]["go_counter"], ap["l"]["go_back"], ap["l"]["go_warehouse"] ]) ]) ]), CGTGoal( name="get-meds-to-clients", description= "if a clients request a medicine go to the warehouse, take the medicine and come back", context=(Context(AndLTL([ap["s"]["shop"], ap["s"]["day_time"]]))), contracts=[ PContract([ DelayedReaction( trigger=ap["s"]["get_med"], reaction=AndLTL([ StrictOrderVisit([ ap["l"]["go_back"], ap["l"]["go_warehouse"], ap["l"]["go_entrace"] ]), InstantReaction(trigger=ap["l"]["go_warehouse"], reaction=ap["a"]["take_med"]), InstantReaction(trigger=ap["l"]["go_entrace"], reaction=ap["a"]["give_med"]) ])) ]) ]), CGTGoal( name="low-battery", description= "always go the charging point and contact the main station when the battery is low", contracts=[ PContract([ Recurrence_P_between_Q_and_R( q=ap["s"]["low_battery"], p=ap["l"]["go_charging_point"], r=ap["s"]["full_battery"]) ]) ]), CGTGoal(name="welcome-visitors", description="welcome people at the entrance", context=(Context( AndLTL([ap["s"]["day_time"], ap["s"]["entrance"]]))), contracts=[ PContract([ DelayedReaction(trigger=ap["s"]["human_entered"], reaction=ap["a"]["welcome_client"]), ]) ]), CGTGoal( name="shop-alarm", description="if the door_alarm goes off at any time go to safety " "location and stay there until there is no more door_alarm", context=(Context(ap["s"]["night_time"])), contracts=[ PContract([ P_after_Q(q=ap["s"]["door_alarm"], p=ap["l"]["go_entrace"]) ]) ]), CGTGoal( name="fire-alarm", description="if the door_alarm goes off at any time go to safety " "location and stay there until there is no more door_alarm", contracts=[ PContract([ InstantReaction(trigger=ap["s"]["fire_alarm"], reaction=ap["l"]["go_safe_loc"]) ]) ]) ] return ap, rules, list_of_goals
def get_inputs(): """The designer specifies a mission using the predefined catalogue of patterns In addition to the patterns to use the designer specifies also in which context each goal can be active""" print("CUSTOM SPEC c2:") print(os.path.dirname(os.path.abspath(__file__))) """ Atomic propositions divided in s - sensor propositions (uncontrollable) l - location propositions (controllable e.g. goto) a - action propositions (controllable)""" ap = { "s": { "night_time": LTL("night_time"), "day_time": LTL("day_time"), "low_battery": LTL("low_battery"), "entrance": LTL("entrance"), "shop": LTL("shop"), "get_med": LTL("get_med"), "warehouse": LTL("warehouse"), "human_entered": LTL("human_entered"), "alarm": LTL("alarm") }, "l": { "wlocA": LTL("wlocA"), "wlocB": LTL("wlocB"), "slocA": LTL("slocA"), "slocB": LTL("slocB"), "safe_loc": LTL("safe_loc"), "charging_point": LTL("charging_point") }, "a": { "contact_station": LTL("contact_station"), "welcome_client": LTL("welcome_client"), "take_med": LTL("take_med"), "give_med": LTL("give_med") } } """ Contexts rules, e.g. shop xor warehouse etc.. Domain rules, e.g. different locations Liveness rules, i.e. assumptions when generating the controller e.g. GF alarm, GF !alarm""" rules = { "context": { "mutex": [ [ap["s"]["shop"], ap["s"]["warehouse"]], [ap["s"]["day_time"], ap["s"]["night_time"]] ], "inclusion": [ [ap["s"]["entrance"], ap["s"]["shop"]], [ap["s"]["human_entered"], ap["s"]["shop"]], [ap["s"]["get_med"], ap["s"]["entrance"]], ] }, "domain": { "mutex": [[ ap["l"]["wlocA"], ap["l"]["wlocB"], ap["l"]["slocA"], ap["l"]["slocB"], ap["l"]["safe_loc"], ap["l"]["charging_point"] ]], "inclusion": [ ] }, "environment": { "liveness": [ ap["s"]["alarm"], NotLTL(ap["s"]["alarm"]) ] } } """List of specifications / goals""" list_of_goals = [ CGTGoal( name="night-time-patroling", description="patrol warehouse and shop during the night", context=(Context( P_global( ap["s"]["night_time"] ) )), contracts=[PContract([ StrictOrderPatroling([ ap["l"]["wlocA"], ap["l"]["wlocB"], ap["l"]["slocA"], ap["l"]["slocB"] ]) ])] ), CGTGoal( name="order-visit", description="patrol warehouse and shop during the night", context=(Context( P_global( ap["s"]["shop"] ) )), contracts=[PContract([ StrictOrderVisit([ ap["l"]["wlocB"], ap["l"]["wlocA"], ap["l"]["slocB"], ap["l"]["slocA"] ]) ])] ), ] return ap, rules, list_of_goals
def get_inputs(): """The designer specifies a mission using the predefined catalogue of patterns In addition to the patterns to use the designer specifies also in which context each goal can be active""" print("CUSTOM SPEC c2:") print(os.path.dirname(os.path.abspath(__file__))) """ Atomic propositions divided in s - sensor propositions (uncontrollable) l - location propositions (controllable e.g. goto) a - action propositions (controllable)""" ap = { "s": { # "night_time": LTL("night_time"), # "day_time": LTL("day_time"), # "low_battery": LTL("low_battery"), # "entrance": LTL("entrance"), # "shop": LTL("shop"), # "get_med": LTL("get_med"), # "warehouse": LTL("warehouse"), # "human_entered": LTL("human_entered"), "alarm": LTL("alarm") }, "l": { # "wlocA": LTL("wlocA"), # "wlocB": LTL("wlocB"), # "slocA": LTL("slocA"), # "slocB": LTL("slocB"), "safe_loc": LTL("safe_loc"), # "charging_point": LTL("charging_point") }, "a": { # "contact_station": LTL("contact_station"), # "welcome_client": LTL("welcome_client"), # "take_med": LTL("take_med"), # "give_med": LTL("give_med") } } """ Contexts rules, e.g. shop xor warehouse etc.. Domain rules, e.g. different locations Liveness rules, i.e. assumptions when generating the controller e.g. GF alarm, GF !alarm""" rules = { "context": { # "mutex": [ # [ap["s"]["shop"], ap["s"]["warehouse"]], # [ap["s"]["day_time"], ap["s"]["night_time"]] # ], # "inclusion": [ # [ap["s"]["entrance"], ap["s"]["shop"]], # [ap["s"]["human_entered"], ap["s"]["shop"]], # [ap["s"]["get_med"], ap["s"]["entrance"]], # # ] }, "domain": { # "mutex": [[ # ap["l"]["wlocA"], # ap["l"]["wlocB"], # ap["l"]["slocA"], # ap["l"]["slocB"], # ap["l"]["safe_loc"], # ap["l"]["charging_point"] # ]], # "inclusion": [ # ] }, "environment": { # "liveness": [ # ap["s"]["alarm"], # NotLTL(ap["s"]["alarm"]) # ] } } """List of specifications / goals""" list_of_goals = [ CGTGoal( name="FP_after_Q(P_until_R)", description="if the alarm goes off at any time go to safety location and stay there until there is no more alarm", contracts=[PContract([ FP_after_Q( p=P_until_R( p=ap["l"]["safe_loc"], r=NotLTL(ap["s"]["alarm"])), q=ap["s"]["alarm"]) ])] ), CGTGoal( name="FP_after_Q_until_R", description="if the alarm goes off at any time go to safety location and stay there until there is no more alarm", contracts=[PContract([ FP_after_Q_until_R( p=ap["l"]["safe_loc"], q=ap["s"]["alarm"], r=NotLTL(ap["s"]["alarm"]) ) ])] ), CGTGoal( name="FP_between_Q_and_R", description="if the alarm goes off at any time go to safety location and stay there until there is no more alarm", contracts=[PContract([ FP_between_Q_and_R( p=ap["l"]["safe_loc"], q=ap["s"]["alarm"], r=NotLTL(ap["s"]["alarm"]) ) ])] ), CGTGoal( name="P_after_Q(P_until_R)", description="if the alarm goes off at any time go to safety location and stay there until there is no more alarm", contracts=[PContract([ P_after_Q( p=P_until_R( p=ap["l"]["safe_loc"], r=NotLTL(ap["s"]["alarm"])), q=ap["s"]["alarm"]) ])] ), CGTGoal( name="P_after_Q_until_R", description="if the alarm goes off at any time go to safety location and stay there until there is no more alarm", contracts=[PContract([ P_after_Q_until_R( p=ap["l"]["safe_loc"], q=ap["s"]["alarm"], r=NotLTL(ap["s"]["alarm"]) ) ])] ), CGTGoal( name="P_between_Q_and_R", description="if the alarm goes off at any time go to safety location and stay there until there is no more alarm", contracts=[PContract([ P_between_Q_and_R( p=ap["l"]["safe_loc"], q=ap["s"]["alarm"], r=NotLTL(ap["s"]["alarm"]) ) ])] ) ] return ap, rules, list_of_goals
def examples(): # generate_buchi( # P_after_Q( # q=LTL("low_battery"), # p=AndLTL([ # Visit([ # LTL("charging_point") # ]), # LTL("contact_station") # ]) # ), # "pattern_with_scope_case_1" # ) # # generate_buchi( # DelayedReaction( # trigger=LTL("low_battery"), # reaction=AndLTL([ # Visit([ # LTL("charging_point") # ]), # LTL("contact_station") # ]) # ), # "pattern_without_scope_case_2" # ) # # generate_buchi( # AndLTL([ # P_between_Q_and_R( # q=LTL("day"), # r=LTL("night"), # p=LTL("entrance") # ), # LTL("((day & !night) | (!day & night))", Variables([Boolean("day"), Boolean("night")])) # ]), # "context_with_scope" # ) # # generate_buchi( # AndLTL([ # P_after_Q_until_R( # q=LTL("day"), # r=LTL("night"), # p=LTL("entrance") # ), # LTL("((day & !night) | (!day & night))", Variables([Boolean("day"), Boolean("night")])) # ]), # "context_with_scope_after_until" # ) # # generate_buchi( # AndLTL([ # P_global( # p=LTL("entrance") # ), # P_global( # p=LTL("day") # ), # LTL("((day & !night) | (!day & night))", Variables([Boolean("day"), Boolean("night")])) # ]), # "context_without_scope" # ) # # generate_buchi( # ImpliesLTL( # LTL("G(F( alarm )) & G(F( !alarm ))", Variables([Boolean("alarm")])), # P_after_Q( # p=P_until_R( # p=Visit([LTL("safe_loc")]), # r=NotLTL(LTL("alarm"))), # q=LTL("alarm") # ) # ), # "pattern_with_scope") # # generate_buchi( # ImpliesLTL( # LTL("G(F( alarm )) & G(F( !alarm ))", Variables([Boolean("alarm")])), # InstantReaction( # trigger=LTL("alarm"), # reaction=LTL("safe_loc") # ) # ), # "pattern_without_scope") # generate_buchi( # P_after_Q( # p=P_until_R( # p=Visit([LTL("safe_loc")]), # r=NotLTL(LTL("alarm"))), # q=LTL("alarm") # ), # "pattern_with_scope-visit") generate_buchi( P_after_Q(p=P_until_R(p=LTL("safe_loc"), r=NotLTL(LTL("alarm"))), q=LTL("alarm")), "pattern_with_scope-new") generate_buchi( P_after_Q_until_R(p=LTL("safe_loc"), q=LTL("alarm"), r=NotLTL(LTL("alarm"))), "pattern_with_scope-dwer")