scenic.core.dynamics

Support for dynamic behaviors and modular scenarios.

Summary of Module Members

Module Attributes

stuckBehaviorWarningTimeout

Timeout in seconds after which a StuckBehaviorWarning will be raised.

Functions

runTryInterrupt

Classes

Behavior

Dynamic behaviors of agents.

BlockConclusion

An enumeration.

DynamicScenario

Internal class for scenarios which can execute during dynamic simulations.

InterruptBlock

Invocable

Abstract class with common code for behaviors and modular scenarios.

Monitor

Monitors for dynamic simulations.

Exceptions

GuardViolation

Abstract exception raised when a guard of a behavior is violated.

InvariantViolation

Exception raised when an invariant is violated

PreconditionViolation

Exception raised when a precondition is violated

StuckBehaviorWarning

Warning issued when a behavior/scenario may have gotten stuck.

Member Details

exception StuckBehaviorWarning[source]

Bases: UserWarning

Warning issued when a behavior/scenario may have gotten stuck.

When a behavior or compose block of a modular scenario executes for a long time without yielding control, there is no way to tell whether it has entered an infinite loop with no take/wait statements, or is actually doing some long computation. But since forgetting a wait statement in a wait loop is an easy mistake, we raise this warning after a behavior/scenario has run for stuckBehaviorWarningTimeout seconds without yielding.

stuckBehaviorWarningTimeout = 10

Timeout in seconds after which a StuckBehaviorWarning will be raised.

class Invocable(*args, **kwargs)[source]

Abstract class with common code for behaviors and modular scenarios.

Both of these types of objects can be called like functions, can have guards, and can suspend their own execution to invoke sub-behaviors/scenarios.

_invokeInner(agent, subs)[source]

Run the given sub-behavior/scenario(s) in parallel.

Implemented by subclasses.

class DynamicScenario(*args, **kwargs)[source]

Bases: Invocable

Internal class for scenarios which can execute during dynamic simulations.

Provides additional information complementing Scenario, which originally only supported static scenarios. The two classes should probably eventually be merged.

classmethod _requiresArguments()[source]

Whether this scenario cannot be instantiated without arguments.

_bindTo(scene)[source]

Bind this scenario to a sampled scene when starting a new simulation.

_prepare(delayPreconditionCheck=False)[source]

Prepare the scenario for execution, executing its setup block.

_start()[source]

Start the scenario, starting its compose block, behaviors, and monitors.

_step()[source]

Execute the (already-started) scenario for one time step.

Returns:

None if the scenario will continue executing; otherwise a string describing why it has terminated.

_stop(reason, quiet=False)[source]

Stop the scenario’s execution, for the given reason.

_addRequirement(ty, reqID, req, line, name, prob)[source]

Save a requirement defined at compile-time for later processing.

_addDynamicRequirement(ty, req, line, name)[source]

Add a requirement defined during a dynamic simulation.

_addMonitor(monitor)[source]

Add a monitor during a dynamic simulation.

class Behavior(*args, **kwargs)[source]

Bases: Invocable, Samplable

Dynamic behaviors of agents.

Behavior statements are translated into definitions of subclasses of this class.

class Monitor(*args, **kwargs)[source]

Bases: Behavior

Monitors for dynamic simulations.

Monitor statements are translated into definitions of subclasses of this class.

exception GuardViolation(behavior, lineno)[source]

Bases: Exception

Abstract exception raised when a guard of a behavior is violated.

This will never be raised directly; either of the subclasses PreconditionViolation or InvariantViolation will be used, as appropriate.

exception PreconditionViolation(behavior, lineno)[source]

Bases: GuardViolation

Exception raised when a precondition is violated

Raised when a precondition is violated when invoking a behavior or when a precondition encounters a RejectionException, so that rejections count as precondition violations.

exception InvariantViolation(behavior, lineno)[source]

Bases: GuardViolation

Exception raised when an invariant is violated

Raised when an invariant is violated when invoking/resuming a behavior or when an invariant encounters a RejectionException, so that rejections count as invariant violations.

class BlockConclusion(value)[source]

Bases: Enum

An enumeration.