Classes
- Dog: Represents a dog with attributes such as name, attention, and walking time. The class also handles dislikes.
- Walker: Represents the walker with attributes for capacity and time, as well as lists for dogs at each site.
- DogWalkingState: Maintains the state of the problem, including the dogs at each site, the walker's position, and methods to generate successor states and calculate heuristics.
- DogWalkingProblem: Extends the search problem to include the goal state and specific implementations of the heuristic and cost functions, as well as methods for searching and constructing paths.
Search Algorithm
The A* search algorithm is used to find the optimal solution to the Dog Walking Problem. It combines the cost of reaching a state with a heuristic estimate of the cost to reach the goal from that state. This approach helps in efficiently navigating the state space to find the optimal path.
Cost and Heuristic
Cost Function: The cost function calculates the cost of actions based on the walking time and attention requirements. It penalizes actions that exceed the walker’s capacity.
Heuristic Function: The heuristic function estimates the remaining cost to reach the goal. It considers the remaining walking time, attention capacity, and the number of dogs at each site.