See ‘maximize_lp’ In Action

Linear Programming serves as a method for addressing real-world problems where the goal is to maximize (e.g., profit or security) or minimize (e.g., costs or risks) a certain outcome. Optimization is achieved by selecting appropriate values for variables, which are subject to various constraints. The mathematical model for such problems consists solely of linear expressions, excluding the multiplication of variables or raising them to a power. Many real-world optimization problems exhibit linear characteristics or can be linearized with minimal error.

For instance, consider the following example:

A company makes two types of cloth, X and Y, using three different colors of wool (see Fig 1). Cloth X yields a profit of $12 per unit, while cloth Y yields $8 per unit. The objective is to determine the optimal quantities of X and Y to maximize profit.

Fig. 1

Let x and y denotes the quantities of cloth X and Y produced, respectively. The profit is expressed as

P = 12x+8y.

Given that there is only 1400 kg of red wool available, and each cloth require 4 kg of red wool, the constraint is

4x + 4y \le 1400.

Similarly, considering the available green and yellow wool, the constraints are

6x + 3y \le 1800, \quad 2x+6y \le 1800.

Additionally, neither x nor y should be negative,

x\ge 0, y \ge 0.

Therefore, the optimization problem can be formulated as:

Maximize the linear objective function

P=12x+8y

subject to the linear constraints:

\begin{cases} 4x+4y<=1400, \\ 6x+3y<=1800, \\ 2x+6y<=1800, \\ x, y \ge 0.\end{cases}

The problem can be solved using Maxima’s ‘maximize_lp’ :

Fig. 2

The solution in Fig. 3 shows that the company should produce 750 units of cloth X and 100 units of cloth Y to achieve the maximum possible profit of $3800. This will utilize all the available red and green wool, leaving 700 kg of yellow unused.

Fig. 3

See also “Building the Optimal Portfolio