Get startedGet started for free

Solving the capital budgeting problem

Recall the capital budgeting problem.

Your manager designs the firm's strategy and considers projects \(A\), \(B\), \(C\), and \(A\) is the prerequisite for \(B\). Profits are respectively \(V = [250, 200, 300]\), the required investment is I = [2000, 1900, 2500] and only $4600 is available. \(o\) is a binary variable of whether a project is selected.

Your manager gave you the problem:

\(\max\ \ o_AV_A + o_{AB}V_B + o_CV_C\) \(s.t.\ o_AI_A + o_{AB}I_B + o_CI_C\leq 4600\)

Your task is to linearize and solve the profit problem.

We have already imported pulp and defined a model with the parameters V, I, names for the project names (A, B, C, and AB indexed in that order), and o representing the binary decision using the same indexing.

This exercise is part of the course

Introduction to Optimization in Python

View Course

Exercise instructions

  • Define the linearized objective function by filling in the function for project B and C, considering the prerequisites for B.
  • Define the constraints using the updated AB variable.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Define the objective
model += o[0]*V[0] + ____*V[1] + ____*V[2]

# Define the constraints
model += o[0]*I[0] + ____*I[1] + o[2]*I[2] <= 4600, 'budget constraint'
model += o[____] <= o[0]
model += o[____] <= o[1]
model += o[____] >= o[0] + o[1] - 1 

status = model.solve()
print(f"{'Optimal found' if status == 1 else 'Ignore solution'}")

for i, name in enumerate(names):
    print(f"{name}: {'accepted' if o[i].varValue == 1 else 'rejected'}")
print(f'Total profit = ${value(model.objective)}')
Edit and Run Code