faudes::ProposingExecutor Class Reference
[Simulator PlugIn]

Executer that proposes which transition to execute. More...

#include <sp_plpexecutor.h>

List of all members.

Public Member Functions

Constructors & Destructor

 ProposingExecutor ()
 Creates an emtpy ProposingExecutor.
 ProposingExecutor (const ProposingExecutor &)
 Copy constrcutor.
Simulation Event Attributes

const SimEventAttributeEventAttribute (Idx index) const
 Simulation event attribute lookup.
void EventAttribute (Idx index, const SimEventAttribute &rAttr)
 Set simulation event attribute.
void Alphabet (const sEventSet &rAlphabet)
 Set all simulation event attributes.
const sEventSetAlphabet (void) const
 Access alphabet (incl simulation event attributes).
Execution Proposal

TimedEvent ExecuteNextTransition ()
 Execute next transition.
const TimedEventProposeNextTransition ()
 Propose next transition.
std::string EventStatesToString (void) const
 Inspect stochastic event states (debugging).
Re-implemenented from ParallelExecutor

virtual void Reset (long int seed=0)
 Reset the ProposingExecutor.
virtual void Clear (void)
 Clear all data (generators, simulation attributes etc).
bool ExecuteTime (tpTime::Type duration)
 Execute time duration.
bool ExecuteEvent (Idx event)
 Execute event.
bool ExecuteTransition (const TimedEvent &tevent)
 Execute event by transition.
bool RevertToStep (Idx step)
 Revert executor to past step.

Protected Member Functions

virtual void DoRead (TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
 Reads proposing executor from TokenReader, see also public wrappers Type::Read.
virtual void DoWrite (TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
 Write to TokenWriter, see also public wrappers Type::Write.
virtual void DoAssign (const ProposingExecutor &rSrc)
 Assignment method.

Private Member Functions

void ResetProposer (long int seed=0)
 Reset stochastic state of events.
tpTime::Type Schedule (Idx event, SimEventAttribute *pattr)
 Evaluate random variable to schedule event.

Private Attributes

sEventSet mSimEvents
 Simulation event attributes, incl stochastic and priority data.
bool mPValid
 Valid proposal available.
TimedEvent mProposal
 Available proposal.

Detailed Description

Executer that proposes which transition to execute.

Priority and Stochastic Semantics

Whilst the LoggingExecutor (and all lower level executors) is aware of which transitions are enabled, the ProposingExecutor actually proposes either one particular transition for execution or a particular amount of time to let pass. The proposal refers to additional semantics parametrised by data from SimEventAttribute. The decision procedure is organized in four stages, were the first stage that yields a proposal wins:

1.) SimPriorityEventAttribute, positive priority

  • if one or more events with positive priority are enabled, those with maximum priority form the candidate set
  • if the candidate set is non-emty propose one event by random (uniformly distributed) to be executed immediately

2.) SimStochasticEventAttribute, stochastic timing

  • if within the interval at which the set of enabled events remains constant (EnabledInterval) an event with stochastic timing is scheduled to occur, the earliest of such events form the candidate set.
  • if the candidate set is non-emty propose one event by random (uniformly distributed) to be executed at the scheduled clock time.

3.) passing by clock time

  • if the EnabledInterval is of positive duration, let this duration pass by.
  • if the EnabledInterval is of infinite duration, let all clock time pass and stop the simulation

4.) SimPriorityEventAttribute, negative priority

  • if one or more events with negative priority are enabled, those with maximum priority form the candidate set
  • if the candidate set is non-emty propose one event by random (uniformly distributed) to be executed immediately

Note that the above procedure will never come up with a proposal that fails to satisfy invariant and guard conditions. In this sense, the above procedure is compliant with Alur semantics of timed automata.

If the above procedure fails to indicate a transition to execute or clock time to let pass, the system is deadlocked. If the procedure sticks with case 3) and infinite duration, it might be either life locked (no enabled events) or just unwilling/unable to execute a negative priority event. The latter case can be used for sensor events in a hardware-in-the-loop simulation.

Scheduling Stochastic Events

The mechnism to schedule events with stochastic timing comes in three flavors.

  • SimStochasticEventAttribute::Extern The random variable models an external stochastic process. A sample is taken when the executor is reset to determine the first scheduled occurence. The schedule expires when it matched the current clock time, regardless whether the event is executed or not. When the schedule expires, a new sample is taken to determine the next scheduled occurence.
  • SimStochasticEventAttribute::Trigger The random variable is used to narrow down the effective guard interval to a point. By "effective guard interval" we refer to the interval of time in which the guard is satisfied w.r.t. the current timed state. A sample is taken when the executor enters a timed state with a non-empty the effective guard interval. In order to guarantee that the scheduled occurence lies within the guard, the density function is shaped accordingly. The schedule expires when either the event is actually executed or when the effective guard interval changes due to a transition.
  • SimStochasticEventAttribute::Delay The random variable models a delay relative to the clock time when the event is enabled. A sample is taken when the executor is reset to determine the initial amount of delay. During the execution sequence the executor accumulates the durations for which the event is enabled. The event is scheduled when the accumulated durations matches the delay. When the event is executed the schedule expires and the random variable is sampled to re-initialised the delay.

Note that type Extern or Delay schedules can disable the respective event in a way that potentially leads to blocking behaviour even if the timed automata is non-blocking by Alur semantics. This is a consequence of the fact that both types model additional phenomena that are synchronized with the timed automata, and it is perferctly reasonable that this synchronisation introduces blocking situations. In contrast, events of type Trigger are not affected by the blocking issue provided that guards lie within the respective invariant.

File IO

For token IO, the ProposingExecutor reads and writes a section with default label "Executor". It contains a ParallelExecutor section to define a vector of generators, a SimConditionSet section to define relevant conditions, and a SimEventSet section to define the above event attributes. Example:

 <Executor> 

 <Generators> 
 "./some_generator.gen"
 "./other_generator.gen" 
 </Generators> 

 <Conditions> 

 "IdleCond"      
 <EventCondition>
 <StartEvents> "beta" "mue" </StartEvents>
 <StopEvents>  "alpha"      </StopEvents>
 </EventCondition>

 "DownCond"     
 <StateCondition>
 <StateSet> "down" </StateSet>           % refers to first generator
 <StateSet> "down" "repair" </StateSet>  % refers to second generator
 </StateCondition>

 </Conditions> 

 <SimEvents> 

 "alpha"    
 <Priority> 100  </Priority>  

 "beta"   
 <Stochastic> +Trigger+  +Gauss+  <Parameter> 10  5  </Parameter> </Stochastic>

 "mue"   
 <Stochastic> +Delay+  +Gauss+  <Parameter> 20  5  </Parameter> </Stochastic>

 "lambda"    
 <Priority> 100  </Priority>  

 </SimEvents> 

 </Executor> 

Technical detail: since the trace buffer only covers the dynamic state of the parallel executor, the RevertToStep method cannot recover the stochastic event states. Including stochastic states with the trace buffer is considered to expensive.

Definition at line 165 of file sp_plpexecutor.h.


Constructor & Destructor Documentation

faudes::ProposingExecutor::ProposingExecutor ( void   ) 

Creates an emtpy ProposingExecutor.

doxygen group

Definition at line 22 of file sp_plpexecutor.cpp.

faudes::ProposingExecutor::ProposingExecutor ( const ProposingExecutor rOther  ) 

Copy constrcutor.

Definition at line 27 of file sp_plpexecutor.cpp.


Member Function Documentation

const sEventSet& faudes::ProposingExecutor::Alphabet ( void   )  const [inline]

Access alphabet (incl simulation event attributes).

Returns:
Overall alphabet

Reimplemented from faudes::ParallelExecutor.

Definition at line 245 of file sp_plpexecutor.h.

void faudes::ProposingExecutor::Alphabet ( const sEventSet rAlphabet  ) 

Set all simulation event attributes.

Any previous attributes are removed. Any events not in rAlphabet become the default attribute attached (which is priority 0) Requires Reset().

Parameters:
rAlphabet EventSet with SimEventAttrute data

Definition at line 60 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::Clear ( void   )  [virtual]

Clear all data (generators, simulation attributes etc).

Reimplemented from faudes::LoggingExecutor.

Reimplemented in faudes::DeviceExecutor.

Definition at line 34 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::DoAssign ( const ProposingExecutor rSrc  )  [protected, virtual]

Assignment method.

Parameters:
rSrc Source to assign from

Definition at line 41 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::DoRead ( TokenReader rTr,
const std::string &  rLabel = "",
const Type pContext = 0 
) [protected, virtual]

Reads proposing executor from TokenReader, see also public wrappers Type::Read.

Parameters:
rTr TokenReader to read from
rLabel Section to read, defaults to "LoggingExecutor"
pContext Read context to provide contextual information (ignored)
Exceptions:
Exception 
  • non-deterministic generator(s) (id 501)
  • token mismatch (id 502)
  • IO error (id 1)

Reimplemented from faudes::LoggingExecutor.

Definition at line 618 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::DoWrite ( TokenWriter rTw,
const std::string &  rLabel = "",
const Type pContext = 0 
) const [protected, virtual]

Write to TokenWriter, see also public wrappers Type::Write.

Parameters:
rTw Reference to TokenWriter
rLabel Label of section to write, defaults to "LoggingExecutor"
pContext Write context to provide contextual information (ignored)
Exceptions:
Exception 
  • IO errors (id 2)

Reimplemented from faudes::LoggingExecutor.

Definition at line 606 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::EventAttribute ( Idx  index,
const SimEventAttribute rAttr 
)

Set simulation event attribute.

Requires Reset().

Parameters:
index Event index
rAttr New attribute
Exceptions:
Exception Index not found in EventSymbolMap (id 42)

Definition at line 55 of file sp_plpexecutor.cpp.

const SimEventAttribute & faudes::ProposingExecutor::EventAttribute ( Idx  index  )  const

Simulation event attribute lookup.

doxygen group

Parameters:
index 
Returns:
reference to attribute

Definition at line 50 of file sp_plpexecutor.cpp.

std::string faudes::ProposingExecutor::EventStatesToString ( void   )  const

Inspect stochastic event states (debugging).

return EventInfoMap string

Definition at line 102 of file sp_plpexecutor.cpp.

bool faudes::ProposingExecutor::ExecuteEvent ( Idx  event  )  [virtual]

Execute event.

Returns:
True on success

Reimplemented from faudes::LoggingExecutor.

Reimplemented in faudes::DeviceExecutor.

Definition at line 165 of file sp_plpexecutor.cpp.

TimedEvent faudes::ProposingExecutor::ExecuteNextTransition ( void   ) 

Execute next transition.

doxygen group

Choose the transition to execute by priorities and stochastic properties.

Returns:
Executed TimedEvent

Definition at line 428 of file sp_plpexecutor.cpp.

bool faudes::ProposingExecutor::ExecuteTime ( tpTime::Type  duration  )  [virtual]

Execute time duration.

Returns:
True on success

Reimplemented from faudes::LoggingExecutor.

Definition at line 120 of file sp_plpexecutor.cpp.

bool faudes::ProposingExecutor::ExecuteTransition ( const TimedEvent tevent  ) 

Execute event by transition.

Returns:
True on success

Definition at line 247 of file sp_plpexecutor.cpp.

const TimedEvent & faudes::ProposingExecutor::ProposeNextTransition ( void   ) 

Propose next transition.

Propose a transition to execute by priorities and stochastic properties.

Returns:
Proposed TimedEvent

Definition at line 260 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::Reset ( long int  seed = 0  )  [virtual]

Reset the ProposingExecutor.

doxygen group This includes a reset of the ParallelExecutor and the simulation event states.

Parameters:
seed Seed for random generator, 0<>system time

Reimplemented in faudes::DeviceExecutor.

Definition at line 92 of file sp_plpexecutor.cpp.

void faudes::ProposingExecutor::ResetProposer ( long int  seed = 0  )  [private]

Reset stochastic state of events.

Definition at line 68 of file sp_plpexecutor.cpp.

bool faudes::ProposingExecutor::RevertToStep ( Idx  step  )  [virtual]

Revert executor to past step.

This will revert only the executor dynamic state (incl clock values, current time). The condition and event states, however, will not be reverted.

Returns:
True on success

Reimplemented from faudes::LoggingExecutor.

Definition at line 668 of file sp_plpexecutor.cpp.

tpTime::Type faudes::ProposingExecutor::Schedule ( Idx  event,
SimEventAttribute pattr 
) [private]

Evaluate random variable to schedule event.

Referring to the specified stochastic attribute, take a random sample to schedule the next occurence of the event. The result is given as return value and is also recorded in the simulation state of the event attribute.

Parameters:
event Event to schedule, by index
pattr Pointer to event attribute
Returns:
Time of next event occurrence

Definition at line 472 of file sp_plpexecutor.cpp.


Member Data Documentation

Available proposal.

Definition at line 366 of file sp_plpexecutor.h.

Valid proposal available.

Definition at line 361 of file sp_plpexecutor.h.

Simulation event attributes, incl stochastic and priority data.

Definition at line 356 of file sp_plpexecutor.h.


The documentation for this class was generated from the following files:

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen