Question: Q1: Managing Repair Operations Fuel processing units arrive at your facility for repair at a steady rate of 3 units at the beginning of each
Q1: Managing Repair Operations
Fuel processing units arrive at your facility for repair at a steady rate of 3 units at the beginning of each week. At the start of each week, you decide how many units you will try to repair, up to a maximum of 8. The repair process has the following cost structure:
| Number of units attempted to repair | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| Cost | $ 0 | $ 100 | $ 110 | $ 120 | $ 130 | $ 190 | $ 200 | $ 210 | $ 220 |
(These are total costs, not costs per unit.) Every time you attempt to repair a unit, there is an 85% chance, independent of all other units, that the repair operation succeeds. Units for which the repair operation fails, plus any which you did not attempt to repair, are carried over to the next week. The costs in the above table apply not matter how many of the attempted repairs are successful. Safety regulations allow you to carry over at most 15 units to the next week; if the number of units to be carried over exceeds this amount, any excess must be sent to an external repair vendor at a cost of $150 each. Each unit carried over to the next week incurs a direct $9 waiting cost, and your firm has an internal cost of funds of 0.1% per week. The number of units you attempt to repair in any given week cannot exceed the number that are available to repair, which is the number carried over from the previous week plus the 3 that arrive at the start of that week. Just before the start of week 1, you have 2 units awaiting repair. After 12 weeks, the facility must be temporarily shut down for its annual safety cleaning, at which time any remaining units must be shipped out to the external repair vendor at the same $150 per unit cost as mentioned above.
To minimize the expected present value of the cost of the operation, find the optimal number of units to attempt to repair each week, as a function of the number of units carried over from the previous week.
Here is my code I don't know what I am doing wrong.
import numpy
from binomialPoisson import *
hugeNumber = float("inf")
queueCapacity = 15
chanceCanFix = 0.85
waitCost = 9.0
inflowRate = 3
costToFix = numpy.array([ 0.0, 100.0, 110.0, 120.0, 130.0,
190.0, 200.0, 210.0, 220.0])
maxCanFix = 8
overflowCost = 150.0
initialWaiting = 2
stages = 12
discountRate = 0.001
beta = 1.0/(1.0 + discountRate)
f = numpy.zeros([stages + 3, queueCapacity + 1])
x = numpy.zeros([stages + 1, queueCapacity + 1], dtype=int)
for i in range(queueCapacity + 1):
f[stages + 1, i] = - overflowCost * i
for t in range(stages, 0, -1):
for i in range(queueCapacity + 1):
value = hugeNumber
bestMove = 0
for p in range(maxCanFix + 1):
moveValue = costToFix*p
fixProb = binomial(p,chanceCanFix)
for d in range(p + 1):
# See if you can continue from here...
moveValue=p * waitCost
for e in range(i+1):
working= i+e
fixing=max(0,costToFix[p] -working)
waitcharge=overflowCost*fixing
j=working + p
moveValue +=fixProb[e]*(waitcharge + beta*f[t+1,j])
if moveValue < value:
value = moveValue
bestMove = p
f[t, i] = value
x[t, i] = bestMove
print("Optimal solution value is " + str(f[1, initialWaiting]))
print("In stage 1, if the queue is at " + str(initialWaiting) + ", the optimal decision is to fix " + str(x[1, initialWaiting]) + " units.")
for t in range(1, stages + 1):
print("In stage " + str(t) + ":")
for i in range(queueCapacity + 1):
print(" If the queue is at " + str(i) + ", the optimal decision is to fix " + str(x[t, i]) + " units.")
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
