def resetExternalSampler(self): """Reset the scenario's external sampler, if any. If the Python random seed is reset before calling this function, this should cause the sequence of generated scenes to be deterministic.""" self.externalSampler = ExternalSampler.forParameters( self.externalParams, self.params)
def __init__(self, workspace, simulator, objects, egoObject, params, externalParams, requirements, requirementDeps, monitors, behaviorNamespaces, dynamicScenario): if workspace is None: workspace = Workspace() # default empty workspace self.workspace = workspace self.simulator = simulator # simulator for dynamic scenarios # make ego the first object, while otherwise preserving order ordered = [] for obj in objects: if obj is not egoObject: ordered.append(obj) self.objects = (egoObject, ) + tuple(ordered) if egoObject else tuple( ordered) self.egoObject = egoObject self.params = dict(params) self.externalParams = tuple(externalParams) self.externalSampler = ExternalSampler.forParameters( self.externalParams, self.params) self.monitors = tuple(monitors) self.behaviorNamespaces = behaviorNamespaces self.dynamicScenario = dynamicScenario staticReqs, alwaysReqs, terminationConds = [], [], [] self.requirements = tuple( dynamicScenario._requirements) # TODO clean up self.alwaysRequirements = tuple(dynamicScenario._alwaysRequirements) self.terminationConditions = tuple( dynamicScenario._terminationConditions) self.terminateSimulationConditions = tuple( dynamicScenario._terminateSimulationConditions) self.initialRequirements = self.requirements + self.alwaysRequirements assert all(req.constrainsSampling for req in self.initialRequirements) # dependencies must use fixed order for reproducibility paramDeps = tuple(p for p in self.params.values() if isinstance(p, Samplable)) behaviorDeps = [] for namespace in self.behaviorNamespaces.values(): for value in namespace.values(): if isinstance(value, Samplable): behaviorDeps.append(value) self.dependencies = self.objects + paramDeps + tuple( requirementDeps) + tuple(behaviorDeps) self.validate()
def __init__(self, workspace, objects, egoObject, params, externalParams, requirements, requirementDeps): if workspace is None: workspace = Workspace() # default empty workspace self.workspace = workspace ordered = [] for obj in objects: ordered.append(obj) if obj is egoObject: # make ego the first object ordered[0], ordered[-1] = ordered[-1], ordered[0] assert ordered[0] is egoObject self.objects = tuple(ordered) self.egoObject = egoObject self.params = dict(params) self.externalParams = tuple(externalParams) self.requirements = tuple(requirements) self.externalSampler = ExternalSampler.forParameters( self.externalParams, self.params) # dependencies must use fixed order for reproducibility paramDeps = tuple(p for p in self.params.values() if isinstance(p, Samplable)) self.dependencies = self.objects + paramDeps + tuple(requirementDeps) self.validate()