29 auto decision = std::make_shared<ChoiceDecision>(request->token,
Values(),
evaluator);
39 if ( systemState->currentTime >
timestamp ) {
45 auto request = request_ptr.lock();
48 auto decision = determineBestChoices( request );
50 addEvaluation( token_ptr, request_ptr, std::move(decision), decision->evaluation );
57 return event_ptr.lock();
64std::shared_ptr<Decision> BestLimitedChoice::determineBestChoices(std::shared_ptr<const DecisionRequest> request) {
65 auto token = request->token;
66 assert( token->node );
70 assert( extensionElements->choices.size() );
75 std::vector< BPMNOS::Values > alternativeChoices;
77 tmp.resize(extensionElements->choices.size());
78 determineAlternatives( alternativeChoices, extensionElements, status, data, globals, tmp );
80 std::shared_ptr<Decision> bestDecision =
nullptr;
81 for (
auto& choices : alternativeChoices ) {
82 auto decision = std::make_shared<ChoiceDecision>(token,choices,
evaluator);
85 decision->evaluation.has_value() &&
86 ( !bestDecision || decision->evaluation.value() < bestDecision->evaluation.value() )
88 bestDecision = decision;
98 assert(index < choices.size());
99 auto& choice = extensionElements->
choices[index];
102 choices[index] = value;
103 choice->attributeRegistry.setValue(choice->attribute, status, data, globals, choices[index]);
104 if ( index + 1 == choices.size() ) {
105 alternatives.push_back(choices);
108 determineAlternatives(alternatives, extensionElements, status, data, globals, choices, index + 1);
112 if ( !choice->enumeration.empty() ) {
114 for (
auto value : choice->getEnumeration(status,data,globals) ) {
118 else if ( choice->lowerBound.has_value() && choice->upperBound.has_value() ) {
119 auto [min,max] = choice->getBounds(status,data,globals);
123 else if ( min < max ) {
BestLimitedChoice(Evaluator *evaluator)
void notice(const Observable *observable) override
void connect(Mediator *mediator) override
std::shared_ptr< Event > dispatchEvent(const SystemState *systemState) override
Represents an abstract base class for a pending Evaluator.
Class for dispatching the event with the best evaluation.
void addEvaluation(WeakPtrs..., std::shared_ptr< Decision > decision, std::optional< double > reward)
void notice(const Observable *observable) override
void connect(Mediator *mediator) override
auto_set< double, WeakPtrs..., std::weak_ptr< Event > > evaluatedDecisions
auto_list< WeakPtrs..., std::shared_ptr< Decision > > decisionsWithoutEvaluation
void addSubscriber(Observer *subscriber, ObservableTypes... observableTypes)
A class representing the state that the execution or simulation of a given scenario is in.
Class representing a task in which one or more choices have to be made.
Class holding extension elements representing execution data for nodes.
std::vector< std::unique_ptr< Choice > > choices
BPMNOS_NUMBER_TYPE number
Represents a pending decision.
virtual constexpr Type getObservableType() const =0