SOLA
Loading...
Searching...
No Matches
layered_precedence_graph.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_LAYERED_PRECEDENCE_GRAPH_H_
18#define DAISI_CPPS_LOGICAL_ALGORITHMS_ASSIGNMENT_LAYERED_PRECEDENCE_GRAPH_H_
19
20#include <memory>
21#include <optional>
22
23#include "cpps/common/cpps_logger_ns3.h"
24#include "datastructure/directed_graph.tpp"
25#include "layered_precedence_graph_components.h"
26#include "material_flow/model/material_flow.h"
27#include "utils/structure_helpers.h"
28
29namespace daisi::cpps::logical {
30
40class LayeredPrecedenceGraph : private datastructure::DirectedGraph<LPCVertex, std::monostate> {
41public:
42 explicit LayeredPrecedenceGraph(std::shared_ptr<material_flow::MFDLScheduler> scheduler,
43 const std::string &connection_string);
44
45 ~LayeredPrecedenceGraph() = default;
46
50 void next();
51
55 std::vector<material_flow::Task> getAuctionableTasks() const;
56
60 void setEarliestValidStartTime(const std::string &task_uuid, const util::Duration &time);
61
65 void setLatestFinishTime(const std::string &task_uuid, const util::Duration &time);
66
67 util::Duration getEarliestValidStartTime(const std::string &task_uuid) const;
68
69 util::Duration getLatestFinishTime(const std::string &task_uuid) const;
70
71 material_flow::Task getTask(const std::string &task_uuid) const;
72
76 bool areAllTasksScheduled() const;
77
81 bool areAllFreeTasksScheduled() const;
82
85 void setTaskScheduled(const std::string &task_uuid);
86
91 bool isFreeTaskScheduled(const std::string &task_uuid) const;
92
93 bool isTaskFree(const std::string &task_uuid) const;
94
95 std::vector<material_flow::Task> getTasks() const;
96
97private:
100 void initLayers();
101
104 void updateLayersSecondToFree(const LPCVertex &t);
105
108 void updateLayersHiddenToSecond(const LPCVertex &t_dash);
109
113 std::vector<LPCVertex> getLayerVertices(PrecedenceGraphLayer layer) const;
114
115 LPCVertex getVertex(const std::string &task_uuid) const;
116};
117
118} // namespace daisi::cpps::logical
119
120#endif
Helper class to implement the pIA algorithm. A directed graph is layered into a free,...
Definition layered_precedence_graph.h:40
void setTaskScheduled(const std::string &task_uuid)
Setting the scheduled flag of a task.
Definition layered_precedence_graph.cpp:311
void setLatestFinishTime(const std::string &task_uuid, const util::Duration &time)
Setting the latest finish time, in pIA represented as F[t], of a task.
Definition layered_precedence_graph.cpp:245
bool isFreeTaskScheduled(const std::string &task_uuid) const
Checking whether a free task has already been scheduled in this iteration before the layers get updat...
Definition layered_precedence_graph.cpp:327
bool areAllTasksScheduled() const
Checks whether all tasks are on the scheduled layer. The scheduled flag is not considered in this.
Definition layered_precedence_graph.cpp:261
bool areAllFreeTasksScheduled() const
Checks whether for all free tasks the scheduled flag is set. If yes, this means that the iteration is...
Definition layered_precedence_graph.cpp:267
std::vector< material_flow::Task > getAuctionableTasks() const
In this modification of pIA we do not consider prioritizations yet. Therefore, all free tasks are auc...
Definition layered_precedence_graph.cpp:198
void setEarliestValidStartTime(const std::string &task_uuid, const util::Duration &time)
Setting the earliest valid start time, in pIA represented as PC[t], of a task.
Definition layered_precedence_graph.cpp:229
void next()
Taking the next step in the algorithm. Updating the graph by assuming that all tasks of the free laye...
Definition layered_precedence_graph.cpp:123
Definition directed_graph.h:27
Definition task.h:34
Modified Round Robin Algorithm that centrally assigns tasks of incoming material flows to the corresp...
Definition algorithm_config.h:22
PrecedenceGraphLayer
Enum to represent the different layers tasks can be on in this precedence graph. The free layer is al...
Definition layered_precedence_graph_components.h:32
Definition layered_precedence_graph_components.h:34