solution_140d.py

#!/usr/bin/python3
# ====================================================================
# Ski manufacture problem
# ---- x = number of parabolic skis per data
# ----     $40 profit
# ----     6 hours fabricating
# ----     1 hours finishing   
# ---- y = number of conventional skis per day
# ----     $30 profit
# ----     4 hours fabricating
# ----     1 hours finishing
# ----
# ---- 108 fabricating department labor hours available per day
# ----  24 finishing   department labor hours available per day
# maximize profit
# --------------------------------------------------------------------
# To see information on Pulp classes go to
#     https://www.coin-or.org/PuLP/pulp.html
# ====================================================================

import pulp as pl

x = pl.LpVariable('x',0,None,cat='integer')

y = pl.LpVariable('y',0,None,cat='integer')

prob = pl.LpProblem('SkiManufacturingProblem',pl.LpMaximize)

# ---- add objective function (maximum profit)

prob += 40*x + 30*y

# ---- add constraints

prob += 6*x + 4*y <= 108

prob += x + y <=24

# ---- solve problem (using default solver)

status = prob.solve()

print(f'status = {pl.LpStatus[status]}')

# ---- describe solution

x = pl.value(x)
y = pl.value(y)

print(f'{x} parabolic skis per day')
print(f'{y} conventional skis per day')
print(f'profit = ${40*x + 40*y} per day')