5.1.1. Modeling for linear programming¶
Linear programming (LP) problems can be described by using the following mathematical model:
- In the preceding model:
\(x \in \mathbb{R}^{n}\) is a decision variable.
\(l^c \in \mathbb{R}^{n}\) and \(u^c \in \mathbb{R}^{n}\) are the lower bound and upper bound of \(x\).
\(c^f \in \mathbb{R}\) is a constant in the target function.
\(c \in \mathbb{R}^{n}\) is a coefficient in the target function.
\(A \in \mathbb{R}^{m \times n}\) is a constraint matrix.
\(l^r \in \mathbb{R}^{m}\) and \(u^r \in \mathbb{R}^{m}\) are the lower bound and upper bound of a constraint.
The procedure of using MindOpt is as follows:
Create an optimization model.
Input an optimization problem and set algorithm parameters.
Solve the problem and obtain the solution.
Note
MindOpt stores only non-zero elements in the constraint matrix \(A\). Therefore, you only need to input the row/column index and non-zero value of each non-zero element in the constraint matrix.
5.1.1.1. Examples of linear programming problems¶
Linear programming problem:
The following part describes how to use MindOpt to build a model and solve the optimization problem. Examples are provided for different programming languages. You can input non-zero elements into the matrix in two ways:
By row (constraint)
By column (variable)
Note
When you input elements by row, you only need to input the column index and non-zero value of each non-zero element in a row.
When you input elements by column, you only need to input the column index and non-zero value of each non-zero element in a column.