2. Dynamic Programming¶
2.1. Theory¶
2.2. Project: Dynamic Programming¶
If not done yet, follow the instructions given above to enroll to the Gradescope and Inginious courses, as well as retrieving the source code of the projects.
The first project is about Dynamic Programming (DP) and the Traveling Salesman Problem (TSP). It consists of 2 parts:
On Gradescope, find the assignment on DP where you will learn about the TSP and model it on paper with this technique. Submit your answers when you are ready.
- Then, go to your personal LINFO2266 Github repository, where you will specify your model and solve real TSP instances.
In the
dynamicprogrammingpackage, you will find a file calledDynamicProgramming.java. This file contains three parameterized classesModel,StateandTransitionwhich allow to specify the components of any DP model. Moreover, you will find a class calledDynamicProgrammingthat will compute the optimal solution of a given DP problem. The first exercise is to implement the functionsgetSolution,getValueForStateandrebuildSolutionin this class.You can verify your implementation by running the tests for the Knapsack problem, which is already implemented in
Knapsack.java.Now it is your turn to implement a DP problem. The second exercise concerns the files
TSP.javaandTSPState.javawhere you need to fill the class representing a state of the TSP model and then implement functions specifying the recurrence you imagined in the first part of the project. Take a look atKnapsack.javaandKnapsackState.javaif you need an example.Run the tests for the TSP to see if your implementation is correct and fast enough.
When you are done, do not forget to commit and push your changes before submitting your work on Inginious.
