TimeO is a Java application that solves the time-based orienteering problem by finding an optimal path to maximize the score when visiting control points within their designated time windows while respecting time limits and penalties.
Orienteering is a sport where participants navigate from point to point in unfamiliar terrain using a map and compass. This program implements a solution for a time-constrained variant where:
- Each control point has a score value
- Control points are only valid within specific time windows (open/close times)
- There is a global time limit with penalties for exceeding it
- The goal is to maximize the total score by visiting optimal control points
The algorithm uses backtracking with branch-and-bound optimization to find the best possible route through the control points.
- Java 8 or higher
- No additional libraries required
TimeO.java- Main implementation file with the algorithms and driver code- Graph components (dependencies/pre-built):
Graph.java- Graph interfaceEdge.java- Edge interfaceVertex.java- Vertex interfaceAbstractGraph.java- Skeletal implementation of GraphAdjacencyListGraph.java- Concrete implementation using adjacency listsAdjacencyMatrixGraph.java- Alternative implementation using adjacency matrices
The program works with two input files:
-
Map file (
westpoint14-timeo.map): Contains the graph structure with distances- First line:
controls <num_controls> <control_codes...> - Remaining lines:
<source> <destination> <distance_forward> <distance_backward>
- First line:
-
Course file (
westpoint14-timeo.course): Contains control point information- First line:
timelimit <time_limit> <penalty_per_minute> - Second line:
controls <num_controls> - Remaining lines:
<control_code> <points> <open_time> <close_time>
- First line:
java TimeO <map_file> <course_file> <pace>map_file: Path to the map filecourse_file: Path to the course filepace: The pace value used to adjust distances (higher values mean slower travel)
java TimeO westpoint14-timeo.map westpoint14-timeo.course 1.2The program uses:
- Backtracking: Recursively explores all possible paths
- Branch-and-bound: Prunes paths that cannot lead to a better solution
- Graph Theory: Models the terrain as a weighted graph
The algorithm performs the following steps:
- Parse map and course files
- Build a graph representation of controls and paths
- Use backtracking to explore all possible paths
- Apply pruning to avoid unpromising paths
- Return the optimal solution (maximum score)
The program outputs:
- Total time taken for the route
- Total score (raw score minus penalties)
- Raw score (sum of control point values)
- Total penalty incurred
- List of controls visited in sequence