MATH3202/7232 Operations Research & Mathematical Planning 2021
Practical 8 – Dynamic Programming
Python Functions
Define functions in Python to
• Calculate the factorial of a number n
• Calculate the value function for the ‘Minimal Studying’ problem
• Determine the optimal solution for the ‘Minimal Studying’ problem
Knapsack Problem
We have a container of size 20 units, and want to pack it with the following valuable items:
Item j Size vj Value tj 1 7 25
2 4 12 338
How many of each item should we pack in order to maximize the total value?
Fibonacci Sequence
Define a function in Python to calculate the nth number in the Fibonacci sequence.