1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Optimization in Python

Connected

Exercise

Allocating resources

Nice work, time to solve the next problem you were introduced to.

A manager allocates 120 tasks to a senior (S), a junior (J) and an intern (I) software engineer and wants to minimize costs.

The intern requires training that costs $500 prior to working on the tasks. The cost to resolve each task is c = [30, 40, 5] respectively.

\(x\) holds the number of assigned tasks and \(o\) the binary for whether the intern receives training. The total cost is

\(TC = 30x_S+40x_J+(5x_I+500)o\)

Use the BigM method to linearize this problem using the new variable \(z\):

\(z = (5x_I+500)o\)

\(-oM\leq z \leq oM\)

\(-(1-o)M \leq z- (5x_I+500)o \leq (1-o)M\)

pulp, along with a model, parameters c, M, and names, and variables x, z, o have already been imported for you.

Instructions

100 XP
  • Define objective by replacing part of the formula with z.
  • Define constraints filling the index of the intern..