def __init__(self): super(FSAStrategy, self).__init__() # A collection of state objects belonging to the automaton self.states = strategy.StateCollection() # A data structure for recording valid transitions between states self.transitions = defaultdict( lambda: defaultdict(bool)) # (state1, state2) -> T/F
def __init__(self): super(BDDStrategy, self).__init__() # We will have a state collection just in order to provide a context # for states (FIXME?) self.states = strategy.StateCollection() self.strategy = None self.var_name_to_BDD = {} self.BDD_to_var_name = {} self.strat_type_var = None self.mgr = pycudd.DdManager() self.mgr.SetDefault() # TODO: why is garbage collection crashing?? :( [e.g. on firefighting] self.mgr.DisableGarbageCollection()
def renameSpecAndStoreNewMapping(self): """ Rename specs and store mapping. """ """ Rename specs """ for specType in self.spec.keys(): # e.region to s.region (region heading) # TODO: duplicates with robClient? for robot in self.coordinatingRobots: for reg in self.regionList.keys(): for otherRobot in self.coordinatingRobots: self.spec[specType][robot] = re.sub( '(?<=[! &|(\t\n])' + 'e.' + otherRobot + '_' + reg + '(?=[ &|)\t\n])', 's.' + otherRobot + '_' + reg, self.spec[specType][robot]) # append robot name in front of actuators and sensors props, but not regions ## sensor props ## e.g: sensorProp -> robotName_sensorProp for robot, ePropList in self.envPropList.iteritems(): for eProp, eValue in ePropList.iteritems(): #ignore any region related props if eProp in [ otherRobot + '_' + reg + '_rc' for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots ] or eProp in [ otherRobot + '_' + reg for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots if otherRobot != robot ]: continue self.spec[specType][robot] = re.sub( '(?<=[! &|(\t\n])' + 'e.' + eProp + '(?=[ &|)\t\n])', 'e.' + robot + '_' + eProp, self.spec[specType][robot]) ## actuator props ## e.g: actuatorProp -> robotName_actuatorProp for robot, sPropList in self.sysPropList.iteritems(): for sProp, sValue in sPropList.iteritems(): #ignore any region related props if sProp in [ otherRobot + '_' + reg for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots ]: continue self.spec[specType][robot] = re.sub( '(?<=[! &|(\t\n])' + 's.' + sProp + '(?=[ &|)\t\n])', 's.' + robot + '_' + sProp, self.spec[specType][robot]) # also just for sysGoalsOld # TODO: combine with the one above for specStr in self.sysGoalsOld.keys(): # e.region to s.region (region heading) for robot in self.coordinatingRobots: for reg in self.regionList.keys(): for otherRobot in self.coordinatingRobots: self.sysGoalsOld[robot] = re.sub( '(?<=[! &|(\t\n])' + 'e.' + otherRobot + '_' + reg + '(?=[ &|)\t\n])', 's.' + otherRobot + '_' + reg, self.sysGoalsOld[robot]) # append robot name in front of actuators and sensors props, but not regions ## sensor props ## e.g: sensorProp -> robotName_sensorProp for robot, ePropList in self.envPropList.iteritems(): for eProp, eValue in ePropList.iteritems(): #ignore any region related props if eProp in [ otherRobot + '_' + reg + '_rc' for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots ] or eProp in [ otherRobot + '_' + reg for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots if otherRobot != robot ]: continue self.sysGoalsOld[robot] = re.sub( '(?<=[! &|(\t\n])' + 'e.' + eProp + '(?=[ &|)\t\n])', 'e.' + robot + '_' + eProp, self.sysGoalsOld[robot]) ## actuator props ## e.g: actuatorProp -> robotName_actuatorProp for robot, sPropList in self.sysPropList.iteritems(): for sProp, sValue in sPropList.iteritems(): #ignore any region related props if sProp in [ otherRobot + '_' + reg for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots ]: continue self.sysGoalsOld[robot] = re.sub( '(?<=[! &|(\t\n])' + 's.' + sProp + '(?=[ &|)\t\n])', 's.' + robot + '_' + sProp, self.sysGoalsOld[robot]) """ Store mapping """ states = strategy.StateCollection() # store env props for robot, ePropList in self.envPropList.iteritems(): for eProp, eValue in ePropList.iteritems(): if eProp in [ robot + '_' + reg + '_rc' for reg in self.regionList.keys() ]: # keep original name self.smvEnvPropList.append(eProp) self.currentAssignment.update({eProp: eValue}) # e.g: remove alice_r4 in bob's sensors. However, for robot not coorindating, we might have alice_charlie_r1 and bob_charlie_r1 in our smv file elif eProp in [ otherRobot + '_' + reg for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots if otherRobot != robot ]: continue # the similar case of _rc elif eProp in [ otherRobot + '_' + reg + '_rc' for reg in self.regionList.keys() for otherRobot in self.coordinatingRobots if otherRobot != robot ]: continue else: # store and update prop mapping self.propMappingNewToOld[robot].pop(eProp) self.propMappingNewToOld[robot][robot + '_' + eProp] = eProp self.propMappingOldToNew[robot][ eProp] = robot + '_' + eProp self.smvEnvPropList.append(robot + '_' + eProp) self.currentAssignment.update( {robot + '_' + eProp: eValue}) # add input props to states collection states.addInputPropositions(self.smvEnvPropList) # stroe sys props for robot, sPropList in self.sysPropList.iteritems(): for sProp, sValue in sPropList.iteritems(): if sProp in [ robot + '_' + reg for reg in self.regionList.keys() ]: # keep original name self.smvSysPropList.append(sProp) self.currentAssignment.update({sProp: sValue}) else: # store and update prop mapping self.propMappingNewToOld[robot].pop(sProp) self.propMappingNewToOld[robot][robot + '_' + sProp] = sProp self.propMappingOldToNew[robot][ sProp] = robot + '_' + sProp self.smvSysPropList.append(robot + '_' + sProp) self.currentAssignment.update( {robot + '_' + sProp: sValue}) # add input props to states collection states.addOutputPropositions(self.smvSysPropList) # store current state self.currentState = states.addNewState(self.currentAssignment)
def __init__(self, slugsOptions): super(SLUGSInteractiveStrategy, self).__init__() self.states = strategy.StateCollection() self.slugsOptions = slugsOptions