Symphony 1.0
Loading...
Searching...
No Matches
StudyProblem Class Reference

#include <study_path.h>

Inheritance diagram for StudyProblem:
Collaboration diagram for StudyProblem:

Public Member Functions

 StudyProblem (StudyState *initial_state, std::map< std::string, std::vector< std::string > > dependencies, std::map< std::string, double > synergies)
 
Stateinitial_state () override
 Retrieves the initial state of the problem.
 
bool goal_test (State *state) override
 Tests if a given state satisfies the goal condition.
 
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.
 
- Public Member Functions inherited from Problem
 Problem ()
 Constructor for the Problem class.
 
virtual ~Problem ()
 Virtual destructor for the Problem class.
 

Additional Inherited Members

- Public Attributes inherited from Problem
Stateinitial_state_
 Pointer to the initial state of the problem.
 

Detailed Description

Definition at line 35 of file study_path.h.

Constructor & Destructor Documentation

◆ StudyProblem()

StudyProblem::StudyProblem ( StudyState initial_state,
std::map< std::string, std::vector< std::string > >  dependencies,
std::map< std::string, double >  synergies 
)
inline

Definition at line 41 of file study_path.h.

44 : initial_state_(initial_state), dependencies(std::move(dependencies)), synergies(std::move(synergies)) {}
State * initial_state() override
Retrieves the initial state of the problem.
Definition study_path.h:46

Member Function Documentation

◆ actions()

std::vector< std::shared_ptr< Action > > StudyProblem::actions ( std::shared_ptr< State state)
inlineoverridevirtual

Retrieves the set of actions applicable to a given state.

This method must be implemented by the user to define the available actions for a specific state.

Parameters
stateThe current state.
Returns
A vector of actions applicable to the given state.

Implements Problem.

Definition at line 58 of file study_path.h.

58 {
59 auto* study_state = std::dynamic_pointer_cast<StudyState>(state).get();
60 std::vector<std::shared_ptr<Action>> available_actions;
61
62 for (const auto& [topic, mastery] : study_state->mastery_levels) {
63 if (mastery < 100.0 && study_state->remaining_time > 0) {
64 double cost = 1.0; // 1 hour per study session
65 auto new_mastery = study_state->mastery_levels;
66 new_mastery[topic] += std::min(10.0, 100.0 - mastery); // Increment by 10%, cap at 100%
67 double synergy_bonus = synergies.count(topic) ? synergies.at(topic) : 0.0;
68 new_mastery[topic] += synergy_bonus;
69
70 double time_left = study_state->remaining_time - cost;
71 auto new_state = new StudyState(new_mastery, time_left);
72 available_actions.emplace_back( std::make_shared<Action>(topic, cost, state, std::shared_ptr<State>(new_state)) );
73 }
74 }
75
76 return available_actions;
77 }

◆ goal_test()

bool StudyProblem::goal_test ( State state)
inlineoverridevirtual

Tests if a given state satisfies the goal condition.

This method must be implemented by the user to define the goal state criteria.

Parameters
stateThe state to test.
Returns
True if the state satisfies the goal condition, false otherwise.

Implements Problem.

Definition at line 50 of file study_path.h.

50 {
51 auto* study_state = dynamic_cast<StudyState*>(state);
52 for (const auto& [_, mastery] : study_state->mastery_levels) {
53 if (mastery < 100.0) return false;
54 }
55 return true;
56 }

◆ heuristic()

double StudyProblem::heuristic ( State state)
inlineoverridevirtual

Computes a heuristic estimate for a given state.

This method must be implemented by the user to define a heuristic function for the problem.

Parameters
stateThe state for which to compute the heuristic.
Returns
A heuristic estimate of the cost to reach the goal from the given state.

Implements Problem.

Definition at line 79 of file study_path.h.

79 {
80 auto* study_state = dynamic_cast<StudyState*>(state);
81 double total_gap = 0;
82 for (const auto& [_, mastery] : study_state->mastery_levels) {
83 total_gap += (100.0 - mastery);
84 }
85 return total_gap / study_state->remaining_time;
86 }
double remaining_time
Definition study_path.h:22

References StudyState::remaining_time.

◆ initial_state()

State * StudyProblem::initial_state ( )
inlineoverridevirtual

Retrieves the initial state of the problem.

Returns
A pointer to the initial state.

Reimplemented from Problem.

Definition at line 46 of file study_path.h.

46 {
47 return initial_state_;
48 }

The documentation for this class was generated from the following file: