13 : config(
std::move(config))
14 , flattenedGraph(flattenedGraph)
18 std::iota(
seed.begin(),
seed.end(), 1);
34 seed = std::move(initialSeed);
58 for (
auto& [_,predecessor] : vertex->
inflows ) {
60 if ( !predecessors.contains(predecessor) && std::ranges::contains(
pendingVertices,predecessor) ) {
62 predecessors.emplace(predecessor);
67 if ( !predecessors.contains(predecessor) && std::ranges::contains(
pendingVertices,predecessor) ) {
69 predecessors.emplace(predecessor);
76 std::unordered_set<const Vertex*> pendingPredecessors;
80 auto it = pendingPredecessors.begin();
81 while ( it != pendingPredecessors.end() ) {
82 const Vertex* predecessor = *it;
84 pendingPredecessors.erase(it);
85 it = pendingPredecessors.begin();
98 pendingPredecessors.erase(it);
99 it = pendingPredecessors.begin();
110 assert( vertex ==
entry(vertex) );
111 std::list<const Vertex*> successors;
113 if ( successor ==
entry(successor) ) {
114 successors.push_back(successor);
117 auto it = successors.begin();
118 while ( it != successors.end() ) {
123 successors.erase(it);
124 it = successors.begin();
133 assert( vertex ==
entry(vertex) );
137 auto finalizeExit = [&]() {
218 assert( vertex ==
exit(vertex) );
246 auto entryVertex =
entry(vertex);
248 auto gateway = entryVertex->inflows.front().second;
249 for (
auto& [ _, target ] : gateway->outflows ) {
250 if ( target != entryVertex ) {
289 if ( performerToken->performing ) {
306 std::list<Vertex*> vertices;
307 for (
auto index :
seed ) {
310 while ( vertices.size() ) {
311 for (
auto it = vertices.begin(); it != vertices.end(); it++ ) {
314 for (
auto& [_,predecessor] : vertex->inflows ) {
320 for (
auto predecessor : vertex->predecessors ) {
339 for (
auto& [_,predecessor] : vertex->
inflows ) {
358 if ( !node )
return false;
365 ( !catchEvent->incoming.empty() && catchEvent->incoming.front()->source->represents<
BPMN::EventBasedGateway>() )
372 auto node = (*it)->node;
373 auto parentEntry = (*it)->
parent.value().first;
378 return (node == other->node && parentEntry == other->parent.value().first );
383 if ( (*it2)->type ==
Vertex::Type::EXIT && node == (*it2)->node && parentEntry == (*it2)->parent.value().first ) {
397 for (
auto recipient :
entry(vertex)->recipients ) {
417 for (
const auto& [token_ptr, request_ptr] : pendingDecisions) {
418 if (
auto request = request_ptr.lock()) {
421 request->token->node == vertex->
node &&
424 return request.get();
431 auto waitingForSequentialPerformer = [&](
const Vertex* vertex) ->
bool {
432 assert( vertex->
parent.has_value() );
435 return other !=
entry(vertex);
457 std::shared_ptr<Event> event;
459 if ( request->type == EntryRequest ) {
462 else if ( request->type == ExitRequest ) {
465 else if ( request->type == MessageDeliveryRequest ) {
468 else if ( request->type == ChoiceRequest ) {
472 assert(!
"Unexpected request type");
520 else if (
auto request = hasRequest(vertex) ) {
522 if (
auto event = createEvent(vertex,request) ) {
545 return std::make_shared<TerminationEvent>();
568 waitingForSequentialPerformer( vertex )
610 return std::make_shared<TerminationEvent>();
616 std::vector<size_t> sequence;
621 sequence.push_back( vertex->index + 1 );
627 sequence.push_back( vertex->index + 1 );
void notice(const Observable *observable) override
virtual void connect(Mediator *mediator)
std::vector< Vertex * > successors
Container holding predecessors according to the execution logic (excl. sequence flows)
std::vector< std::pair< const BPMN::SequenceFlow *, Vertex * > > inflows
Parent vertices.
std::vector< Vertex * > predecessors
Container holding vertices connecting by an outgoing sequence flow, for loop activities the sequence ...
const Vertex * performer() const
Container holding all entry vertices of nodes owning at least one data attribute.
std::optional< std::pair< Vertex *, Vertex * > > parent
const BPMNOS::number instanceId
Represents a graph containing all BPMN nodes that may receive a token during execution of a scenario.
std::unordered_set< const Vertex * > dummies
Container holding entry and exit vertices of each possible instantiation of a node.
const Vertex * getVertex(const Token *token) const
Method returning true if the vertex modifies a global attribute.
std::vector< std::unique_ptr< Vertex > > vertices
Returns a topologically sorted vector of all vertices reachable from the initial vertices.
void addSubscriber(Observer *subscriber, ObservableTypes... observableTypes)
std::list< constVertex * >::iterator finalizeUnvisitedTypedStartEvents(std::list< const Vertex * >::iterator it)
bool withdrawableEntry(const BPMN::Node *node) const
Method finalizing the sequence position of a unvisited vertices belonging to typed start events.
void synchronizeSolution(const Token *token)
const FlattenedGraph * flattenedGraph
const Vertex * entry(const Vertex *vertex) const
Method creating a message delivery event.
virtual std::shared_ptr< Event > createChoiceEvent(const SystemState *systemState, const Token *token, const Vertex *vertex)=0
Method creating a choice event.
virtual std::shared_ptr< Event > createExitEvent(const SystemState *systemState, const Token *token, const Vertex *vertex)=0
Method creating a choice event.
void finalizePredecessorPositions(const Vertex *vertex)
std::list< const Vertex * > pendingVertices
void initializePendingVertices()
Method returning the number of processed vertices.
void fetchPendingPredecessors(std::unordered_set< const Vertex * > &predecessors, const Vertex *vertex) const
bool setSeed(const std::vector< size_t > initialSeed)
size_t getProgress() const
Method providing the vertex sequence in the solution.
void notice(const Observable *observable) override
void subscribe(Engine *engine)
std::unordered_map< const Vertex *, const Vertex * > performing
std::vector< size_t > getSequence() const
Method return true if a token entering a catch event node may be withdrawn.
std::shared_ptr< Event > dispatchEvent(const SystemState *systemState)
virtual std::shared_ptr< Event > createEntryEvent(const SystemState *systemState, const Token *token, const Vertex *vertex)=0
Method creating an initial sequence of vertices.
bool hasPendingRecipient(const Vertex *vertex) const
std::vector< size_t > seed
std::shared_ptr< TerminationEvent > terminationEvent
Observable::Type RequestType
void connect(Mediator *mediator)
std::list< const Vertex * > processedVertices
The list of vertices to be processed.
const Vertex * exit(const Vertex *vertex) const
std::list< constVertex * >::iterator finalizeVertexPosition(const Vertex *vertex)
std::list< constVertex * >::iterator finalizeUnvisited(const Vertex *vertex)
Method finalizing the sequence position of a pending vertex and removing it from the list.
void finalizeUnvisitedChildren(const Vertex *vertex)
SeededController(const BPMNOS::Execution::FlattenedGraph *flattenedGraph, Config config=default_config())
virtual std::shared_ptr< Event > createMessageDeliveryEvent(const SystemState *systemState, const Token *token, const Vertex *vertex)=0
Method creating a choice event.
bool hasPendingPredecessor(const Vertex *vertex) const
The list of vertices already processed.
A class representing the state that the execution or simulation of a given scenario is in.
auto_list< std::weak_ptr< Token >, std::weak_ptr< DecisionRequest > > pendingEntryDecisions
auto_list< std::weak_ptr< Token >, std::weak_ptr< DecisionRequest > > pendingExitDecisions
auto_list< std::weak_ptr< Token >, std::weak_ptr< DecisionRequest > > pendingMessageDeliveryDecisions
auto_list< std::weak_ptr< Token >, std::weak_ptr< DecisionRequest > > pendingChoiceDecisions
Represents a token running through a (sub)process.
const BPMN::FlowNode * node
Class representing a task in which one or more choices have to be made.
Class representing adhoc subprocesses with sequential ordering.
T * get()
Casts the element to the specified type T.
Scope * parent
Reference to the parent node.
T * as()
Casts the element to the specified type T.
T * represents()
Attempts to cast the element to the specified type T.
std::vector< SequenceFlow * > incoming
Vector containing all incoming sequence flows of the node.
Base class for all nodes in a BPMN model.
Base class for BPMN elements that may contain a ChildNode elements.
Base class for all start events with an event definition.
Represents a pending decision.
@ SequentialPerformerUpdate
virtual constexpr Type getObservableType() const =0
static constexpr size_t Instance