Dynamic Programming for Nonlinear Costs
The modified problem has a nonlinear cost pattern because different parts of an action are treated differently.
A Familiar Problem with New Rules
The modified exercise is still Jack's car rental problem. It is not a completely different optimization problem. The change is that the cost attached to an overnight arrangement now follows more complicated rules: one movement may be free, other movements may have direction-dependent charges, and parking may add a fixed charge after movement. These changes are useful because they show how dynamic programming handles costs that are not simply linear.
Why Policy Iteration Runs Again
A policy is a rule for choosing an action in the rental problem. When the movement and parking rules change, the cost attached to an action changes as well. The best action under the original rules therefore cannot simply be assumed to remain best under the modified rules. Policy iteration is used to re-solve the problem: evaluate the current rental policy under the new rules, improve the policy using those evaluations, and continue until the policy stabilizes.
The loop matters because the exercise changes the problem being solved. The original policy is valuable as a baseline, but the modified costs require a fresh solution. A policy that stabilizes under the new movement and parking rules is the policy relevant to the modified problem.
Movement Cost by Direction
The movement rule is directional. A car moved from the first location to the second can use the employee's free shuttle, but the allowance covers only one car. The first car moved in that direction receives the special free treatment. Every additional car moved from the first location to the second costs $2. Movement in the opposite direction costs $2 for every car moved.
Separating free and paid movement
Suppose three cars are moved from the first location to the second.
- 1First car
The first car can use the employee's free shuttle.
- 2Remaining cars
The second and third cars are additional cars moved in the same direction, so each costs $2.
- 3Movement total
The movement portion of the cost is therefore $4: the first car contributes no shuttle charge, and the two additional cars contribute $2 each.
The free allowance applies to one car only; it does not make all movement from the first location to the second free.
The Overnight Parking Threshold
The parking rule is assessed after movement is complete. The relevant quantity is the number of cars left overnight at each location. Whenever a location exceeds 10 overnight cars, a second-parking-lot charge of $4 is added. The charge is fixed: it does not increase according to how far the overnight count is above 10.
Applying the parking rule after movement
Suppose a movement decision leaves one location with 10 overnight cars and another location with 11 overnight cars.
- 1Check the first location
A count of 10 does not exceed the threshold, so it does not activate the second-parking-lot charge.
- 2Check the second location
A count of 11 exceeds the threshold, so that location receives the fixed $4 charge.
- 3Combine costs
The parking charge is added after the movement cost has been determined. It is not multiplied by the one car above the threshold.
The parking portion is $4 because one location exceeds 10 overnight cars.
Combining Costs in Dynamic Programming
The modified problem has a nonlinear cost pattern because different parts of an action are treated differently. The first car sent in one direction can be free, later cars in that direction are charged, movement in the opposite direction is charged for every car, and the parking charge appears as a fixed amount only after an overnight threshold is crossed. These rules do not need to be forced into one simple linear expression.
Dynamic programming accommodates this by evaluating the actual cost of each action and the possible future states that follow it. The method breaks a complex problem into simpler subproblems. It does not require every cost to have the same linear form, so it can represent the free-movement exception, direction dependence, threshold charge, and other arbitrary dynamics within the problem.
Implementation Checks
A staged implementation check is safer than changing every rule at once. First confirm that the program solves the original rental problem correctly. Then introduce the free shuttle rule and the limited-parking rule separately. At each stage, inspect the states, available actions, transition probabilities, rewards or costs, and policy changes. Finally, check that policy iteration stabilizes on the modified problem.
Common mistake Applying the free shuttle allowance to every car moved from the first location to the second.
What it looks likeTreating a three-car movement in that direction as entirely free.
Why it failsThe free treatment applies to only one car.
Do this insteadApply the free allowance to the first car and charge $2 for each additional car in that direction.
Common mistake Using the same movement rule in both directions.
What it looks likeAllowing one free car when moving from the second location to the first.
Why it failsThe free shuttle exception is specified for movement from the first location to the second; the opposite direction costs $2 for every car moved.
Do this insteadHandle the two directions separately.
Common mistake Charging parking before determining the overnight counts.
What it looks likeAdding the parking charge from the number of cars before movement.
Why it failsThe second-parking-lot charge is assessed after movement.
Do this insteadComplete the movement calculation, determine the cars left overnight at each location, and then apply the threshold rule.
Common mistake Making the parking charge grow with every car above 10.
What it looks likeCharging $8 when a location has 12 overnight cars.
Why it failsThe charge is a fixed $4 whenever the overnight count exceeds 10.
Do this insteadUse one fixed $4 charge for each location that exceeds the threshold.
Common mistake Trusting the modified implementation without checking the original problem.
What it looks likeAdding the new rules before confirming that the reference case works.
Why it failsAn existing error can be confused with an error introduced by the modification.
Do this insteadValidate the original problem first, then add the new rules incrementally.
Apply the Rules
Describe how an implementation should calculate the cost of a movement decision in the modified rental problem. Your response should distinguish the two movement directions, apply the one-car free shuttle allowance, determine the resulting overnight counts, and decide whether a fixed parking charge applies.
Hints
- Separate movement cost from the cost assessed after movement.
- The free treatment covers only one car in one direction.
- The parking threshold is checked using the cars left overnight at each location.
- The parking charge is fixed rather than proportional to the number of cars above 10.
What do you think happens?
A location finishes with more than 10 overnight cars. Is the second-parking-lot charge proportional to the number of cars above 10, or is it a fixed amount?
Reveal answer
It is a fixed amount
The rule adds a fixed $4 whenever the overnight count exceeds 10. The amount does not grow with the exact number above the threshold.
Key Takeaways
- 1The exercise modifies Jack's car rental problem rather than replacing it, so the original problem should serve as a reference case.
- 2Policy iteration must re-solve the rental problem because the modified movement and parking rules change action costs and the resulting policy.
- 3The first car moved from the first location to the second can use the free shuttle; additional cars in that direction cost $2 each, while movement in the opposite direction costs $2 per car.
- 4After movement, a fixed $4 parking charge applies at any location with more than 10 overnight cars.
- 5Dynamic programming can represent these nonlinear costs and arbitrary dynamics by evaluating actual action costs and possible future states.
- 6A trustworthy implementation checks the original problem first and then verifies states, actions, transitions, costs, and policy stabilization as the new rules are introduced.
At a glance
- The modified exercise remains Jack's car rental problem, but its movement and parking rules create nonlinear costs.
- The free shuttle is directional and limited to one car; other movements are charged according to their direction.
- The second-parking-lot charge is assessed after movement and is a fixed $4 when an overnight count exceeds 10.
- Dynamic programming can accommodate these nonlinear costs and arbitrary dynamics without requiring a simple linear cost pattern.
- Validate the original problem first, then add the modified rules in stages and check policy stabilization.