1#ifndef TASK_SCHEDULER_H
2#define TASK_SCHEDULER_H
7#include "../symphony.h"
46 for (
const auto &task :
tasks) {
47 std::cout <<
"Task: " << task.name <<
", Priority: " << task.priority <<
", Deadline: " << task.deadline << std::endl;
67 return scheduler_state && scheduler_state->
tasks.empty();
69 std::vector<std::shared_ptr<Action>>
actions(std::shared_ptr<State> state)
override {
70 auto scheduler_state = std::dynamic_pointer_cast<TaskSchedulerState>(state);
71 std::vector<std::shared_ptr<Action>>
actions;
73 for (
const auto &task : scheduler_state->tasks) {
74 auto new_state = std::make_shared<TaskSchedulerState>(*scheduler_state);
77 for (
const auto &t : new_state->tasks) {
79 new_state->tasks.erase(new_state->tasks.begin() + index);
84 actions.push_back(std::make_shared<Action>(
"Complete " + task.name, 1, state, new_state));
91 int total_priority = 0;
92 for (
const auto &task : scheduler_state->tasks) {
93 total_priority += task.priority;
95 return total_priority;
Represents an abstract problem that needs to be solved.
State * initial_state_
Pointer to the initial state of the problem.
Represents an abstract state in a problem.
Represents the state of the task scheduler problem.
void print() override
Prints the state details.
std::vector< Task > tasks
TaskSchedulerState(const TaskSchedulerState &other)
TaskSchedulerState(std::vector< Task > tasks)
bool goal_test(State *state) override
Tests if a given state satisfies the goal condition.
TaskScheduler()
Represents the task scheduler problem. This class defines the initial state, goal test,...
std::vector< std::shared_ptr< Action > > actions(std::shared_ptr< State > state) override
Retrieves the set of actions applicable to a given state.
double heuristic(State *state) override
Computes a heuristic estimate for a given state.
Represents a task with a name, priority, and deadline.
Task(std::string name, int priority, int deadline)
bool operator==(const Task &other) const