Sailco Corporation Inventory Problmes

FROM - Operations Research: Applications and Algorithms 4th Edition, p100, Wayne L. Winston

Sailco Corporation must determine how many sailboats should be produced ruing each of the next four quarter (one quarter = three months). The demand during each of the next four quarters is as follows; first quarter, 40 sailboats: second quarter, 60 sailboats; third quarter, 75 sailboats; fourth quarter, 25 sailboats. Sailco must meet demands on time. At the beginning of the first quarter, Sailco has an inventory of 10 sailboats. At the beginning of each quarter, Sailco must decide how many sailboats should be produced during that quarter. For simplicity, we assume that sailboats manufactured during a quarter can be used to meet demand for that quarter. During each quarter, Sailco can produce up to 40 sailboats with regular-time labor at a total cost of \$400 per sailboat. By having employees work overtime during a quarter, Sailco can produce additional sailboats with overtime labor at total cost of \$450 per sailboat. At the end of each quarter (after production has occurred and the current quarter's demand has been satisfied), a carrying or holding cost of \$20 per sailboat is incurred. Use linear programming to determine a production schedule to minimize the sum of production and inventory costs during the next four quarters.


In [2]:
from gurobipy import *

In [3]:
time_period = ["q1", "q2", "q3", "q4"]
demand = [40,60,75,25]
m = Model("sailco_inventory")

variables = []
for i in range(len(time_period)):
    variables.append([])
    variables[0].append(
        m.addVar(vtype=GRB.CONTINUOUS, obj = 400, name="(x-%d)" % (i)))

for i in range(len(time_period)):
    variables.append([])
    variables[1].append(
        m.addVar(vtype=GRB.CONTINUOUS, obj = 450, name="(y-%d)" % (i)))

variables.append([])
variables[2].append(10)
for i in range(len(time_period)):
    variables.append([])
    variables[2].append(
        m.addVar(vtype=GRB.CONTINUOUS,obj = 20, name="(overhead-%d)" % (i)))
    
m.modelSense = GRB.MINIMIZE
m.update()


for time in range(len(time_period)):
    m.addConstr(variables[0][time] <= 40, "supply regulation %s" % variables[0][time])

for time in range(len(time_period)):
    m.addConstr(variables[2][time] - variables[2][time+1] + variables[0][time] + variables[1][time] - demand[time] == 0, 
                "inventory regulation %s" % variables[0][time])

m.optimize()

for v in m.getVars():
    print (v.varName, v.x)

    
print (m.getObjective().getValue())


Optimize a model with 8 rows, 12 columns and 19 nonzeros
Coefficient statistics:
  Matrix range     [1e+00, 1e+00]
  Objective range  [2e+01, 5e+02]
  Bounds range     [0e+00, 0e+00]
  RHS range        [3e+01, 8e+01]
Presolve removed 4 rows and 0 columns
Presolve time: 0.01s
Presolved: 4 rows, 12 columns, 15 nonzeros

Iteration    Objective       Primal Inf.    Dual Inf.      Time
       0    0.0000000e+00   1.900000e+02   0.000000e+00      0s
       6    7.8450000e+04   0.000000e+00   0.000000e+00      0s

Solved in 6 iterations and 0.02 seconds
Optimal objective  7.845000000e+04
(x-0) 40.0
(x-1) 40.0
(x-2) 40.0
(x-3) 25.0
(y-0) 0.0
(y-1) 10.0
(y-2) 35.0
(y-3) 0.0
(overhead-0) 10.0
(overhead-1) 0.0
(overhead-2) 0.0
(overhead-3) 0.0
78450.0