bppy.model package

Subpackages

Submodules

bppy.model.b_event module

class bppy.model.b_event.BEvent(name='', data=None)[source]

Bases: object

A class to represent a Behavioral Event (BEvent) object.

Attributes

namestr

The name of the event.

datadict

Additional data associated with the event.

bppy.model.b_thread module

bppy.model.b_thread.analysis_thread(func)[source]
bppy.model.b_thread.b_thread(func)[source]
bppy.model.b_thread.execution_thread(func)[source]
bppy.model.b_thread.thread(func, mode='execution')[source]

A decorator to wrap bthread generator with, in order to handle data transmission and bthread termination.

bppy.model.bprogram module

class bppy.model.bprogram.BProgram(bthreads=None, source_name=None, event_selection_strategy=None, listener=None)[source]

Bases: object

A class to represent a Behavioral Program (BProgram) object.

Attributes

source_namestr

A file name from which bthreads are imported.

new_btlist

A list of new bthreads that have not been loaded yet.

bthreadslist

A list of bthreads to be run in the BProgram.

event_selection_strategyEventSelectionStrategy

A strategy object to select events and advance bthreads.

listenerBProgramRunnerListener

A listener object to be invoked at the start and end of the program, and at each event selection.

variablesdict

A dictionary of variables declared in the source module (for SMT based event selection startegy).

ticketslist

A list of bthread tickets (used in execution).

external_events_queuelist

A queue to handle external events introduced into the BProgram.

add_bthread(bt)[source]

Adds a new bthread to the BProgram (should be loaded after using load_new_bthreads).

Parameters

btAny

The bthread to be added.

advance_bthreads(tickets, m)[source]

Advances bthreads based on the selected event (m), using the event selection strategy satisfactions criteria (e.g., event was requested or waited for).

Parameters

ticketslist

A list of bthread tickets.

mBEvent

The selected event to be sent as message to the bthreads.

enqueue_external_event(event)[source]

Enqueues an external event into the BProgram.

Parameters

eventBEvent

The external event to be enqueued.

load_new_bthreads()[source]

Loads all new bthreads into the BProgram.

The method uses advance_bthreads to load bthreads.

next_event()[source]

Selects the next event in the BProgram using the event selection strategy.

If there are new bthreads that haven’t been loaded, a warning will be raised.

Returns

eventBEvent

The selected event to be processed.

run()[source]

Runs the BProgram.

It sets up the BProgram, selects events, and advance the bthreads until no event can be selected or until interrupted by the listener. At the start and end of the run, and after each event selection, the listener (if provided) is invoked.

setup()[source]

Sets up the BProgram.

If a source file is provided, this method imports all bthreads and variables into the BProgram. All bthreads are then loaded.

bppy.model.event_set module

class bppy.model.event_set.All[source]

Bases: EventSet

A class to represent the set of all events.

class bppy.model.event_set.AllExcept(event)[source]

Bases: EventSet

A class to represent a set of all events except some specified event or event set.

class bppy.model.event_set.EmptyEventSet[source]

Bases: EventSet

A class to represent an empty event set.

class bppy.model.event_set.EventSet(predicate, **kwargs)[source]

Bases: object

A class to represent a symbolically defined set of events using a given predicate.

Attributes

predicatecallable

The predicate that tests if an event is a member of this event set.

datadict

Additional keyword arguments that could be used by the predicate.

class bppy.model.event_set.EventSetList(lst)[source]

Bases: EventSet

A class to represent a union of event sets and events.

bppy.model.sync_statement module

class bppy.model.sync_statement.choice(data, repeat=1, replace=True, sorted=False, *args, **kwargs)[source]

Bases: dict

A class to represent a discrete choice object.

Keys correspond to the possible choices, and values correspond to the probability of each choice.

options()[source]
sample()[source]
class bppy.model.sync_statement.sync(*, request=None, waitFor=None, block=None, mustFinish=None, priority=None, localReward=None, **kwargs)[source]

Bases: dict

Module contents