SOLA
Loading...
Searching...
No Matches
cpps_scenariofile.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_COMMON_SCENARIOFILE_CPPS_SCENARIOFILE_H_
18#define DAISI_CPPS_COMMON_SCENARIOFILE_CPPS_SCENARIOFILE_H_
19
20#include <numeric>
21#include <string>
22
23#include "amr_description_scenario.h"
24#include "cpps/amr/amr_topology.h"
25#include "cpps/logical/algorithms/algorithm_config.h"
26#include "manager/general_scenariofile.h"
27#include "material_flow_scenario.h"
28#include "spawn_info_scenario.h"
29
30namespace daisi::cpps {
31
33 double width = 0.0;
34 double height = 0.0;
35 double depth = 0.0;
36
37 void parse(const YAML::Node &node) {
38 SERIALIZE_VAR(width);
39 SERIALIZE_VAR(height);
40 SERIALIZE_VAR(depth);
41 }
42
43 Topology getTopology() const { return Topology(util::Dimensions(width, height, depth)); }
44};
45
47 std::string assignment_strategy;
48
49 const std::unordered_map<std::string, logical::AlgorithmType>
50 assignment_strategy_to_initiator_algorithm_type = {
51 {"iterated_auction", logical::AlgorithmType::kIteratedAuctionAssignmentInitiator},
52 {"round_robin", logical::AlgorithmType::kRoundRobinInitiator},
53 };
54
55 const std::unordered_map<std::string, logical::AlgorithmType>
56 assignment_strategy_to_participant_algorithm_type = {
57 {"iterated_auction", logical::AlgorithmType::kIteratedAuctionAssignmentParticipant},
58 {"round_robin", logical::AlgorithmType::kRoundRobinParticipant},
59 };
60
61 void parse(const YAML::Node &node) { SERIALIZE_VAR(assignment_strategy); }
62
63 logical::AlgorithmConfig getInitiatorAlgorithmConfig() const {
64 logical::AlgorithmConfig algorithm_config;
65
66 algorithm_config.algorithm_types.push_back(
67 assignment_strategy_to_initiator_algorithm_type.at(assignment_strategy));
68
69 return algorithm_config;
70 }
71
72 logical::AlgorithmConfig getParticipantAlgorithmConfig() const {
73 logical::AlgorithmConfig algorithm_config;
74
75 algorithm_config.algorithm_types.push_back(
76 assignment_strategy_to_participant_algorithm_type.at(assignment_strategy));
77
78 return algorithm_config;
79 }
80};
81
83 explicit CppsScenariofile(const std::string &path_to_file) : GeneralScenariofile(path_to_file) {
84 SERIALIZE_VAR(initial_number_of_amrs);
85 SERIALIZE_VAR(number_of_material_flow_agents);
86
87 SERIALIZE_VAR(algorithm);
88 SERIALIZE_VAR(topology);
89
90 SERIALIZE_VAR(autonomous_mobile_robots);
91 SERIALIZE_VAR(material_flows);
92 SERIALIZE_VAR(scenario_sequence);
93
94 verifyScenarioSequenceOfMaterialFlows();
95 verifyScenarioSequenceOfAmrs();
96 calcNumbersOfRelativeAmrDistribution();
97 }
98
99 uint16_t initial_number_of_amrs = 0;
100 uint16_t number_of_material_flow_agents = 0;
101
102 AlgorithmScenario algorithm;
103 TopologyScenario topology;
104
105 std::vector<AmrDescriptionScenario> autonomous_mobile_robots;
106 std::vector<MaterialFlowDescriptionScenario> material_flows;
107 std::vector<SpawnInfoScenario> scenario_sequence;
108
109 std::unordered_map<std::string, AmrDescription> getAmrDescriptions() const;
110 std::unordered_map<std::string, MaterialFlowDescriptionScenario> getMaterialFlowDescriptions()
111 const;
112
113private:
114 void verifyScenarioSequenceOfMaterialFlows() const;
115 void verifyScenarioSequenceOfAmrs() const;
116 void calcNumbersOfRelativeAmrDistribution();
117};
118} // namespace daisi::cpps
119#endif
Definition amr_topology.h:26
Definition general_scenariofile.h:28
Definition cpps_scenariofile.h:46
Definition cpps_scenariofile.h:82
Definition cpps_scenariofile.h:32
Definition algorithm_config.h:31