SOLA
Loading...
Searching...
No Matches
bid_submission.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_MESSAGE_AUCTION_BASED_BID_SUBMISSION_H_
18#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_BID_SUBMISSION_H_
19
20#include <string>
21
22#include "cpps/amr/model/amr_static_ability.h"
23#include "cpps/logical/task_management/metrics_composition.h"
24#include "solanet/serializer/serialize.h"
25#include "solanet/uuid.h"
26#include "solanet/uuid_generator.h"
27
28namespace daisi::cpps::logical {
29
31public:
32 BidSubmission() = default;
33
34 BidSubmission(std::string task_uuid, std::string participant_connection,
35 const amr::AmrStaticAbility &participant_ability,
36 const MetricsComposition &metrics_composition)
37 : task_uuid_(std::move(task_uuid)),
38 participant_connection_(std::move(participant_connection)),
39 participant_ability_(participant_ability),
40 metrics_composition_(metrics_composition) {}
41
42 const std::string &getTaskUuid() const { return task_uuid_; }
43
44 const std::string &getParticipantConnection() const { return participant_connection_; }
45
46 const amr::AmrStaticAbility &getParticipantAbility() const { return participant_ability_; }
47
48 const MetricsComposition &getMetricsComposition() const { return metrics_composition_; }
49
50 bool operator>(const BidSubmission &other) const {
51 if (metrics_composition_ != other.metrics_composition_) {
52 return metrics_composition_ > other.metrics_composition_;
53 }
54
55 // if metrics are the same, it does not matter whether which one is selected
56 // but for comparability a unique ordering is necessary
57
58 // if abilities are unequal, ability can be used for ordering
59 if (participant_ability_ != other.participant_ability_) {
60 return participant_ability_ < other.participant_ability_;
61 }
62
63 // if ability is equal, at least the connection strings are different
64 return participant_connection_ > other.participant_connection_;
65 }
66
67 solanet::UUID getUUID() const { return uuid_; }
68
69 SERIALIZE(uuid_, task_uuid_, participant_connection_, participant_ability_, metrics_composition_);
70
71private:
72 solanet::UUID uuid_ = solanet::generateUUID();
73
74 std::string task_uuid_;
75
76 std::string participant_connection_;
77
78 amr::AmrStaticAbility participant_ability_;
79
80 MetricsComposition metrics_composition_;
81};
82
83} // namespace daisi::cpps::logical
84
85#endif
Definition amr_static_ability.h:32
Definition bid_submission.h:30
Definition metrics_composition.h:25
Modified Round Robin Algorithm that centrally assigns tasks of incoming material flows to the corresp...
Definition algorithm_config.h:22