SOLA
Loading...
Searching...
No Matches
auction_participant_state.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_AUCTION_PARTICIPANT_STATE_H_
18#define DAISI_CPPS_LOGICAL_ALGORITHMS_ASSIGNMENT_AUCTION_PARTICIPANT_STATE_H_
19
20#include <memory>
21#include <unordered_map>
22
23#include "cpps/logical/message/auction_based/bid_submission.h"
24#include "cpps/logical/message/auction_based/winner_response.h"
25#include "cpps/logical/task_management/auction_based_task_management.h"
26#include "material_flow/model/task.h"
27
28namespace daisi::cpps::logical {
29
34 friend class AuctionParticipantState;
35
37
38 const material_flow::Task &getTask() const;
39
40 const MetricsComposition &getMetricsComposition() const;
41
42 std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> getInsertionPoint() const;
43
45 bool isValid() const;
46
48 void setInformation(const MetricsComposition &metrics_composition,
49 std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> insertion_point);
50
52 void removeInformation();
53
54private:
57
60 std::optional<MetricsComposition> metrics_composition_;
61
64 std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> insertion_point_;
65};
66
74 explicit AuctionParticipantState(const std::vector<daisi::material_flow::Task> &tasks);
75
80
83 void prune();
84
87 bool hasEntries() const;
88
90 std::unordered_map<std::string, AuctionParticipantTaskState> task_state_mapping;
91
96
97private:
99 bool checkAllTaskStatesValid();
100};
101
102} // namespace daisi::cpps::logical
103
104#endif
Definition metrics_composition.h:25
Definition task.h:34
Modified Round Robin Algorithm that centrally assigns tasks of incoming material flows to the corresp...
Definition algorithm_config.h:22
Helper struct for the IteratedAuctionAssignmentParticipant to store the state of open auction process...
Definition auction_participant_state.h:71
bool hasEntries() const
Checking whether there are valid entries.
Definition auction_participant_state.cpp:101
AuctionParticipantTaskState pickBest()
Given the information from the task_state_mapping, the best possible task is picked depending on stor...
Definition auction_participant_state.cpp:62
std::unordered_map< std::string, AuctionParticipantTaskState > task_state_mapping
Storing the state of each open task. The key is the task uuid.
Definition auction_participant_state.h:90
std::string previously_submitted
Task uuid of the lastest previously submitted task. If a task was submitted before,...
Definition auction_participant_state.h:95
void prune()
Removing task states with invalid stored information (= empty metrics and insertion point) from the m...
Definition auction_participant_state.cpp:86
Helper struct for the IteratedAuctionAssignmentParticipant, used inside of the AuctionParticipantStat...
Definition auction_participant_state.h:33
bool isValid() const
Checking whether both metrics and insertion point are initialized.
Definition auction_participant_state.cpp:50
void setInformation(const MetricsComposition &metrics_composition, std::shared_ptr< AuctionBasedTaskManagement::InsertionPoint > insertion_point)
Setting information for both metrics and insertion point.
Definition auction_participant_state.cpp:24
void removeInformation()
Making metrics and insertion point uninitialized.
Definition auction_participant_state.cpp:31