Planning the Construction of homes

On a housing estate on the Alicante coastline, two types of homes are being built: apartments and penthouses, whose prices are \(p_1\) and \(p_2\) M€ respectively. The curve of demand for apartments is \(d_1 = 40 – 2p_1\) and \(d_2 = 150 – 3p_2\) for penthouses. The builder calculated that, owing to the orders that he has already sent to his raw materials suppliers, it is worth building 15 times more apartments than penthouses. He has also calculated that building an apartment costs him 5M€, while a penthouse costs him 3M€. Knowing that the builder has a budget of 350 M€, work out the following:

a) Write an NLP to calculate the optimal prices for apartments and penthouses.

\(\max z = (p1-5)(40-2p_1) + (p_2-3)(150-3p_2) = -2p_1^2-3p_2^2+50p_1+159p_2-650\)

\(\text{s.t}\)

\(5(40-2p_1)+3(150-3p_2) \leq 350 \rightarrow -10p_1-9p2+300 \leq 0\)

\(15(150-3p_2) \leq (40-2p_1) \rightarrow 2p_1-45p_2+2210 \leq 0\)

\(p_1, p_2 \geq 0\)

b) Write the Kuhn Tucker conditions of the NLP problem:

The Lagrangian is:

\(L = -2p_1^2-3p_2^2+50p_1+159p_2-650 + \lambda_1\left(-10p_1-9p2+300\right) + \lambda_2\left(2p_1-45p_2+2210\right)\)

Gradient condition:

\(\nabla(L)=0\)

\(\dfrac{dL}{dq_1} = -4p_1+50-10\lambda_1+2\lambda_2 = 0\)

\(\dfrac{dL}{dq_2} = -6p_2+159-9\lambda_1-45\lambda_2 = 0\)

Feasibility Condition:

\(-10p_1-9p_2+300 \leq 0\)

\(2p_1-45p_2+2210 \leq 0\)

Orthogonality Condition:

\(\lambda_1·(-10p_1-9p2+300) = 0\)

\(\lambda_2·(2p_1-45p_2+2210) = 0\)

Non-negativity condition:

\(p_1, p_2 \geq 0\)

\(\lambda_1, \lambda_2 \leq 0\)

[1]:
import numpy as np
from scipy.optimize import LinearConstraint, minimize

def objective_func(p):
  return 2*p[0]**2 + 3*p[1]**2 - 50*p[0] - 159*p[1]+650

rhs_coefs = np.array([[10, 9], [2, -45]])

constraints = LinearConstraint(rhs_coefs,lb=[300, 2210], ub=[np.inf, np.inf])

p0 = [5, 40]

res = minimize(objective_func, p0, constraints=constraints, bounds=[(0, np.inf), (0, np.inf)],
               options={"maxiter":1000, "disp": True})

print(res.x)
Optimization terminated successfully    (Exit mode 0)
            Current function value: 2387450.0025050757
            Iterations: 3
            Function evaluations: 11
            Gradient evaluations: 3
[1.10500000e+03 2.08014536e-08]