SOLA
Loading...
Searching...
No Matches
round_robin_initiator.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_CPPS_LOGICAL_ALGORITHMS_ASSIGNMENT_ROUND_ROBIN_INITIATOR_H_
18#define DAISI_CPPS_LOGICAL_ALGORITHMS_ASSIGNMENT_ROUND_ROBIN_INITIATOR_H_
19
20#include <map>
21#include <queue>
22#include <random>
23#include <unordered_map>
24
25#include "centralized_initiator.h"
26#include "cpps/common/cpps_communicator.h"
27
30namespace daisi::cpps::logical {
32public:
33 RoundRobinInitiator(daisi::cpps::common::CppsCommunicatorPtr communicator,
34 std::shared_ptr<CppsLoggerNs3> logger);
35 ~RoundRobinInitiator() override = default;
36
38 REGISTER_IMPLEMENTATION(AssignmentResponse)
39
40
41 REGISTER_IMPLEMENTATION(StatusUpdate)
42
43
44 void logMaterialFlowContent(const std::string &material_flow_uuid) override;
45
46private:
48 struct ParticipantInfoRoundRobin : public ParticipantInfo {
50 uint32_t assignment_counter = 0;
51
52 bool operator<(const ParticipantInfoRoundRobin &other) const {
53 return assignment_counter < other.assignment_counter;
54 }
55 bool operator>(const ParticipantInfoRoundRobin &other) const {
56 return assignment_counter > other.assignment_counter;
57 }
58 };
59
62 void storeParticipant(ParticipantInfo &info) override;
63
68 void distributeMFTasks(uint32_t index, bool previously_allocated) override;
69
72 void assignTask(const material_flow::Task &task);
73
78 std::shared_ptr<ParticipantInfoRoundRobin> chooseParticipantForTask(
79 const material_flow::Task &task);
80
84 void processAssignmentAcceptions(uint32_t index);
85
88 std::map<std::string, std::vector<material_flow::Task>> unallocated_tasks_per_mf_;
89
92 std::unordered_map<amr::AmrStaticAbility,
93 std::priority_queue<ParticipantInfoRoundRobin,
94 std::vector<ParticipantInfoRoundRobin>, std::greater<>>,
96 participants_per_ability_;
97};
98} // namespace daisi::cpps::logical
99
100#endif
Definition amr_static_ability.h:32
Response of a central participant as a reaction of a task assignment. Consists of the task_uuid,...
Definition assignment_response.h:32
Algorithm that centrally assigns tasks of incoming material flows to the corresponding centralized pa...
Definition centralized_initiator.h:28
Definition round_robin_initiator.h:31
void logMaterialFlowContent(const std::string &material_flow_uuid) override
React on a participant's response to a task assignment.
Definition round_robin_initiator.cpp:49
might need some revision / additions in the future
Definition status_update.h:33
Definition task.h:34
Modified Round Robin Algorithm that centrally assigns tasks of incoming material flows to the corresp...
Definition algorithm_config.h:22
Definition amr_static_ability.h:57
Helper that stores all relevant information about the task assignment participants....
Definition centralized_initiator.h:46