SOLA
Loading...
Searching...
No Matches
auction_initiator_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_INITIATOR_STATE_H_
18#define DAISI_CPPS_LOGICAL_ALGORITHMS_ASSIGNMENT_AUCTION_INITIATOR_STATE_H_
19
20#include <memory>
21
22#include "cpps/amr/model/amr_static_ability.h"
23#include "cpps/logical/message/auction_based/bid_submission.h"
24#include "cpps/logical/message/auction_based/winner_response.h"
25#include "layered_precedence_graph.h"
26#include "material_flow/model/material_flow.h"
27
28namespace daisi::cpps::logical {
29
33public:
35 struct Winner {
36 std::string task_uuid;
37 std::string winner_connection;
38 daisi::util::Duration latest_finish_time;
39 };
40
41 explicit AuctionInitiatorState(std::shared_ptr<LayeredPrecedenceGraph> layered_precedence_graph);
42
46
49 std::vector<Winner> selectWinner() const;
50
54
57 std::vector<daisi::material_flow::Task> processWinnerAcceptions();
58
61 void addBidSubmission(const BidSubmission &bid_submission);
62
65 void addWinnerResponse(const WinnerResponse &winner_response);
66
68 void clearIterationInfo();
69
72
73private:
78 static void removeBidsForTask(std::vector<BidSubmission> &bid_submissions,
79 const std::string &task_uuid);
80
86 static void removeBidsForWinner(std::vector<BidSubmission> &bid_submissions,
87 const std::string &task_uuid,
88 const std::string &winner_connection);
89
94 static void removeBidsWhichMeetAbilityRequirement(
95 std::vector<BidSubmission> &bid_submissions,
96 const amr::AmrStaticAbility &ability_requirement);
97
99 std::vector<BidSubmission> bid_submissions_;
100
103 std::vector<WinnerResponse> winner_acceptions_;
104
106 std::shared_ptr<LayeredPrecedenceGraph> layered_precedence_graph_;
107
109 uint8_t no_bid_submissions_counter_ = 0;
110
112 uint8_t no_winner_acceptions_counter_ = 0;
113};
114
115} // namespace daisi::cpps::logical
116
117#endif
Definition amr_static_ability.h:32
Helper class for the IteratedAuctionAssignmentInitiator to handle and store the state of received bid...
Definition auction_initiator_state.h:32
void countWinnerResponseProcessing()
Counting how many times winner responses were successful or not. Throwing an exception if there were ...
Definition auction_initiator_state.cpp:80
void clearIterationInfo()
Clearing all information from the internal state.
Definition auction_initiator_state.cpp:132
void countBidSubmissionProcessing()
Counting how many times bid submissions were successful or not. Throwing an exception if there were n...
Definition auction_initiator_state.cpp:90
void addWinnerResponse(const WinnerResponse &winner_response)
Adding a received WinnerResponse message to the internal state if it was successful.
Definition auction_initiator_state.cpp:29
void clearWinnerAcceptions()
Clearing winner acceptions from the internal state.
Definition auction_initiator_state.cpp:137
std::vector< Winner > selectWinner() const
Calculating winners for the different ability groups based on received bids.
Definition auction_initiator_state.cpp:100
std::vector< daisi::material_flow::Task > processWinnerAcceptions()
Processing each successful winner response and removing related bids.
Definition auction_initiator_state.cpp:66
void addBidSubmission(const BidSubmission &bid_submission)
Adding a received BidSubmission message to the internal state.
Definition auction_initiator_state.cpp:25
Definition bid_submission.h:30
Definition winner_response.h:28
Modified Round Robin Algorithm that centrally assigns tasks of incoming material flows to the corresp...
Definition algorithm_config.h:22
Helper struct to store information needed to send WinnerNotifications.
Definition auction_initiator_state.h:35