# linear programming minimum problem

A construction company has 6 projects, for each they need $$d_i$$ workers. The company has no workers at the beginning of project 1.

Each new worker must take a safety course that costs 300, and 50 more for each worker. If there is no new worker there is no course.

Firing a worker does not cost any money, and a workers can't be rehired.

Given that the salary of a worker is 100 per project, formulate a linear programming problem that minimizes the workers costs.

What I tried:

Let $$x_i$$ be the number of new workers for project $$i$$.

Let $$y_i$$ be the number of old workers remaining from previous projects until project $$i$$ (all the workers hired - all the workers that were fired)

Let $$z_i$$ be an indicator such that $$z_i =0 \iff x_i>0$$

The function I'm trying to solve is:

$$\min(\sum_{i=1}^6 150x_i + 300(1-z_i) + 100y_i)$$

s.t: \begin{align} x_i,y_i,z_i &\ge 0 \\ z_i &\ge 1-x_i \\ y_i + x_i &\ge d_i \\ y_i &\ge y_{i-1} + x_i \end{align}

Something feels not right to me. The main reason is that I tried to use matlab to solve this and it failed.

What did I do wrong? How can I solve this question?

Seems correct except that the last constraint should instead be $$y_i \le y_{i-1} + x_{i-1}$$.