# How to optimize multiple linear regressions based on cost?

I have an optimization problem where I'd like to maximize revenue and I have separate variables for cost and revenue.

• Building a single unit of a product takes 100 hours of labor
• I have a list of staff, the number of hours they have available, and the cost per hour for each
• The projected revenue of the product changes based on the total cost to build the unit
• If cost is less than 2500, revenue = 40 * cost
• If cost is between 2500 to 5000, revenue = 25 * cost
• If cost is > 5000, revenue = 8 * cost
• I want my objective function to maximize the appropriate revenue formula based on what the cost might be

I tried to use the BigM notation to determine which range the cost falls into, and then my objective function looked something like
Maximize(
is_cost_group_1 * (40 * cost) +
is_cost_group_2 * (25 * cost) +
is_cost_group_3 * (8 * cost))
but this gave me an error'ed saying the solver does not support quadratic functions.

Is this possible as a linear programming problem?

• As stated, your cost function is discontinuous. If the cost is 2500, your revenue is 62,500. If the cost is 2499 (just slightly lower), your revenue is 99,960 (much higher). Is this intentional (and realistic), or do you want the marginal (incremental) revenue rate to be 40/25/8?
– prubin
Apr 4, 2022 at 15:44
• While this example is just a theoretical one, the discontinuous cost function is intentional and realistic because if we can keep the cost under 2500, we can sell more units to a wider audience whereas the higher cost will target fewer customers. Apr 4, 2022 at 18:37
• Demand being a decreasing function of price is fine, but cost is not price. If your cost is 2501 (revenue 62,525) and you pretended it was 2499 (revenue 99,960), would the extra 37,435 in revenue not cover the extra cost (and then some)?
– prubin
Apr 4, 2022 at 19:26

Let $$x$$ be the cost variable and $$y$$ the revenue variable (which you will maximize). Let $$M$$ be an upper limit on $$x$$ (the maximum cost you might encounter). Introduce three binary variables $$z_1,z_2,z_3$$ together with the following constraints:\begin{align*} z_{1}+z_{2}+z_{3} & =1\\ x & \le2500z_{1}+5000z_{2}+Mz_{3}\\ y & \le40x\\ y & \le25x+15M(1-z_{2})\\ y & \le8x+32M(1-z_{3}). \end{align*} If $$z_1=1$$, your cost is up to 2500 (but no higher) and your revenue is up to 40 times the cost (and therefore will be 40 times the cost). If $$z_2=1$$, your cost is up to 5000 and your revenue no more than (therefore equal to) 25 times cost. If $$z_3=1$$, cost is up to $$M$$ and revenue no more than 8 times cost.
Note that break points qualify for the higher revenue value. For instance, a cost of exactly 2500 can result in revenue $$40\times 2500$$. To enforce strict inequality (revenue rate 40 only if cost strictly less than 2500) you need to change 2500 and 5000 in the second constraint to $$2500-\epsilon$$ and $$5000-\epsilon$$ for some small $$\epsilon>0$$ and then live with the discrepancy that cost $$2500-\epsilon/2$$ on earns revenue multiple 25 and not 40.
• I recommend starting a new question with the second problem, after we resolve what is going on with this problem. In my answer, I am assuming that cost $x$ is a variable. My answer does not multiply $x$ and $z_i$ together.