Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly rename TaskManagement #126

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-sola.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
build/tests/unittests/DaisiDatastructureDirectedGraphTest
build/tests/unittests/DaisiDatastructureWeightedDirectedGraphTest
build/tests/unittests/DaisiDatastructureSimpleTemporalNetworkTest
build/tests/unittests/DaisiCppsOrderManagementStnOrderManagement
build/tests/unittests/DaisiCppsTaskManagementStnTaskManagement
build/tests/unittests/DaisiCppsLogicalAuctionParticipantState
build/tests/unittests/network_tcp/daisi_network_tcp_framing_manager_test
- name: Run MINHTON integrationtest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AuctionParticipantTaskState::AuctionParticipantTaskState(daisi::material_flow::T

void AuctionParticipantTaskState::setInformation(
const MetricsComposition &metrics_composition,
std::shared_ptr<AuctionBasedOrderManagement::InsertionPoint> insertion_point) {
std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> insertion_point) {
metrics_composition_ = metrics_composition;
insertion_point_ = insertion_point;
}
Expand All @@ -42,7 +42,7 @@ const MetricsComposition &AuctionParticipantTaskState::getMetricsComposition() c
return metrics_composition_.value();
}

const std::shared_ptr<AuctionBasedOrderManagement::InsertionPoint>
const std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint>
AuctionParticipantTaskState::getInsertionPoint() const {
return insertion_point_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ struct AuctionParticipantTaskState {

const MetricsComposition &getMetricsComposition() const;

const std::shared_ptr<AuctionBasedOrderManagement::InsertionPoint> getInsertionPoint() const;
const std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> getInsertionPoint() const;

/// @brief Checking whether both metrics and insertion point are initialized.
bool isValid() const;

/// @brief Setting information for both metrics and insertion point.
void setInformation(const MetricsComposition &metrics_composition,
std::shared_ptr<AuctionBasedOrderManagement::InsertionPoint> insertion_point);
std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> insertion_point);

/// @brief Making metrics and insertion point uninitialized.
void removeInformation();
Expand All @@ -61,7 +61,7 @@ struct AuctionParticipantTaskState {

/// @brief Storing information about how to insert the task into an auction based order
/// management by the participant.
std::shared_ptr<AuctionBasedOrderManagement::InsertionPoint> insertion_point_;
std::shared_ptr<AuctionBasedTaskManagement::InsertionPoint> insertion_point_;
};

/// @brief Helper struct for the IteratedAuctionAssignmentParticipant to store the state of open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace daisi::cpps::logical {

CentralizedParticipant::CentralizedParticipant(
daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<SimpleOrderManagement> task_management)
std::shared_ptr<SimpleTaskManagement> task_management)
: AssignmentParticipant(communicator), task_management_(std::move((task_management))){};

bool CentralizedParticipant::process(const AssignmentNotification &assignment_notification) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace daisi::cpps::logical {
class CentralizedParticipant : public AssignmentParticipant {
public:
CentralizedParticipant(daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<SimpleOrderManagement> task_management);
std::shared_ptr<SimpleTaskManagement> task_management);
~CentralizedParticipant() override = default;

/// @brief React on new task assignment and respond to it.
Expand All @@ -39,7 +39,7 @@ class CentralizedParticipant : public AssignmentParticipant {

private:
/// @brief the AMR's task management. Simply accepts a new task assignment.
std::shared_ptr<SimpleOrderManagement> task_management_;
std::shared_ptr<SimpleTaskManagement> task_management_;
};
} // namespace daisi::cpps::logical

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace daisi::cpps::logical {

IteratedAuctionAssignmentParticipant::IteratedAuctionAssignmentParticipant(
daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<AuctionBasedOrderManagement> task_management, AmrDescription description)
std::shared_ptr<AuctionBasedTaskManagement> task_management, AmrDescription description)
: AssignmentParticipant(communicator),
task_management_(std::move(task_management)),
description_(std::move(description)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class IteratedAuctionAssignmentParticipant : public AssignmentParticipant {
public:
explicit IteratedAuctionAssignmentParticipant(
daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<AuctionBasedOrderManagement> task_management, AmrDescription description);
std::shared_ptr<AuctionBasedTaskManagement> task_management, AmrDescription description);

~IteratedAuctionAssignmentParticipant() override = default;

Expand All @@ -65,7 +65,7 @@ class IteratedAuctionAssignmentParticipant : public AssignmentParticipant {

/// @brief Pointer to the task management of the corresponding AmrLogicalAgent.
/// We need access to calculate bids and add tasks after receiving WinnerNotifications.
std::shared_ptr<AuctionBasedOrderManagement> task_management_;
std::shared_ptr<AuctionBasedTaskManagement> task_management_;

/// @brief Calculating bids for each open task in a state.
/// @param state Relevant auction state.
Expand Down
4 changes: 2 additions & 2 deletions daisi/src/cpps/logical/amr/amr_logical_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void AmrLogicalAgent::initAlgorithms() {
for (const auto &algo_type : algorithm_config_.algorithm_types) {
switch (algo_type) {
case AlgorithmType::kIteratedAuctionAssignmentParticipant: {
auto stn_task_management = std::make_shared<StnOrderManagement>(
auto stn_task_management = std::make_shared<StnTaskManagement>(
description_, topology_, daisi::util::Pose{execution_state_.getPosition()});
task_management_ = stn_task_management;

Expand All @@ -66,7 +66,7 @@ void AmrLogicalAgent::initAlgorithms() {
break;
}
case AlgorithmType::kRoundRobinParticipant: {
auto simple_task_management = std::make_shared<SimpleOrderManagement>(
auto simple_task_management = std::make_shared<SimpleTaskManagement>(
description_, topology_, daisi::util::Pose{execution_state_.getPosition()});
task_management_ = simple_task_management;

Expand Down
2 changes: 1 addition & 1 deletion daisi/src/cpps/logical/amr/amr_logical_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class AmrLogicalAgent : public LogicalAgent {
/// @brief The address of the AmrPhysicalAsset after it connected to AmrLogicalAgent.
ns3::Address physical_address_;

std::shared_ptr<OrderManagement> task_management_;
std::shared_ptr<TaskManagement> task_management_;
};
} // namespace daisi::cpps::logical

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

namespace daisi::cpps::logical {

class AuctionBasedOrderManagement : public OrderManagement {
class AuctionBasedTaskManagement : public TaskManagement {
public:
struct InsertionPoint {};

AuctionBasedOrderManagement(const AmrDescription &amr_description, const Topology &topology,
const daisi::util::Pose &pose)
: OrderManagement(amr_description, topology, pose) {}
AuctionBasedTaskManagement(const AmrDescription &amr_description, const Topology &topology,
const daisi::util::Pose &pose)
: TaskManagement(amr_description, topology, pose) {}

~AuctionBasedOrderManagement() override = default;
~AuctionBasedTaskManagement() override = default;

virtual bool addTask(const daisi::material_flow::Task &task,
std::shared_ptr<InsertionPoint> insertion_point = nullptr) = 0;
Expand Down
33 changes: 16 additions & 17 deletions daisi/src/cpps/logical/task_management/simple_task_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,38 @@
using namespace daisi::material_flow;
namespace daisi::cpps::logical {

SimpleOrderManagement::SimpleOrderManagement(const AmrDescription &amr_description,
const Topology &topology,
const daisi::util::Pose &pose)
: OrderManagement(amr_description, topology, pose), expected_end_position_(pose.position) {
SimpleTaskManagement::SimpleTaskManagement(const AmrDescription &amr_description,
const Topology &topology, const daisi::util::Pose &pose)
: TaskManagement(amr_description, topology, pose), expected_end_position_(pose.position) {
final_metrics_.setStartTime(0);
}

Metrics SimpleOrderManagement::getFinalMetrics() const { return final_metrics_; }
Metrics SimpleTaskManagement::getFinalMetrics() const { return final_metrics_; }

daisi::util::Position SimpleOrderManagement::getExpectedEndPosition() const {
daisi::util::Position SimpleTaskManagement::getExpectedEndPosition() const {
if (!expected_end_position_.has_value()) {
throw std::logic_error("There must exist at least a position for the AMR to start from.");
}
return expected_end_position_.value();
}

void SimpleOrderManagement::setCurrentTime(const daisi::util::Duration &now) {
void SimpleTaskManagement::setCurrentTime(const daisi::util::Duration &now) {
if (now < time_now_) {
throw std::invalid_argument("New time must be later than current time.");
}
time_now_ = now;
}

bool SimpleOrderManagement::hasTasks() const { return active_task_.has_value(); }
bool SimpleTaskManagement::hasTasks() const { return active_task_.has_value(); }

Task SimpleOrderManagement::getCurrentTask() const {
Task SimpleTaskManagement::getCurrentTask() const {
if (!hasTasks()) {
throw std::logic_error("No tasks available!");
}
return active_task_.value();
}

bool SimpleOrderManagement::setNextTask() {
bool SimpleTaskManagement::setNextTask() {
if (!queue_.empty()) {
active_task_ = queue_.front();
queue_.erase(queue_.begin());
Expand All @@ -61,14 +60,14 @@ bool SimpleOrderManagement::setNextTask() {
return false;
}

bool SimpleOrderManagement::canAddTask(const Task &task) {
SimpleOrderManagement copy(*this);
bool SimpleTaskManagement::canAddTask(const Task &task) {
SimpleTaskManagement copy(*this);
bool result = copy.addTask(task);

return result;
}

bool SimpleOrderManagement::addTask(const Task &task) {
bool SimpleTaskManagement::addTask(const Task &task) {
// simply add all orders in the given order
const auto orders = task.getOrders();
if (orders.empty()) {
Expand All @@ -92,13 +91,13 @@ bool SimpleOrderManagement::addTask(const Task &task) {
if (!final_order.has_value()) {
throw std::logic_error("Task must contain at least one TransportOrder or MoveOrder.");
}
auto end_location = OrderManagementHelper::getEndLocationOfOrder(final_order.value());
auto end_location = TaskManagementHelper::getEndLocationOfOrder(final_order.value());
expected_end_position_ = end_location->getPosition();

return true;
}

void SimpleOrderManagement::updateFinalMetrics() {
void SimpleTaskManagement::updateFinalMetrics() {
// calculate the start time and metrics for the new task
auto start_time = std::max(final_metrics_.getMakespan(), time_now_);

Expand All @@ -117,7 +116,7 @@ void SimpleOrderManagement::updateFinalMetrics() {
final_metrics_ = new_current_metrics;
}

void SimpleOrderManagement::insertOrderPropertiesIntoMetrics(
void SimpleTaskManagement::insertOrderPropertiesIntoMetrics(
const Order &order, Metrics &metrics, const Task &task,
const daisi::util::Duration &start_time) {
if (!metrics.isStartTimeSet()) {
Expand All @@ -131,7 +130,7 @@ void SimpleOrderManagement::insertOrderPropertiesIntoMetrics(
std::optional<Location> previous_location;
order_it++;
for (; order_it != orders.rend(); order_it++) {
previous_location = OrderManagementHelper::getEndLocationOfOrder(*order_it);
previous_location = TaskManagementHelper::getEndLocationOfOrder(*order_it);
if (previous_location.has_value()) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "task_management.h"

namespace daisi::cpps::logical {
class SimpleOrderManagement : public OrderManagement {
class SimpleTaskManagement : public TaskManagement {
public:
SimpleOrderManagement(const AmrDescription &amr_description, const Topology &topology,
const daisi::util::Pose &pose);
SimpleTaskManagement(const AmrDescription &amr_description, const Topology &topology,
const daisi::util::Pose &pose);

~SimpleOrderManagement() override = default;
~SimpleTaskManagement() override = default;

/// @brief return the metrics of the final order contained in the last task that has been added to
/// the management
Expand Down
Loading