Linear Programming Calculator

Given a linear programming problem in the form \[ \begin{array}{ll} \left\{\begin{array}{l} \mbox{maximize} \\ \mbox{minimize} \end{array}\right\} & f(\mathbf{x})=\mathbf{c}^T\mathbf{x} \\ \mbox{subject to} & \mathbf{A}\mathbf{x} \left\{\begin{array}{c} \leqslant \\ = \\ \geqslant \end{array}\right\} \mathbf{b} \\ \mbox{and} & \mathbf{x} \geqslant 0 \end{array} \] where $\mathbf{x}=\{x_1,x_2,\ldots,x_n\}$ is the vector of $n$ variables, $\mathbf{c}$ and $\mathbf{b}$ are vectors of $n$ real coefficients and $m$ (right-hand-side) numbers, respectively, $\mathbf{A}$ is a matrix of $m\times n$ real numbers, this calculator find $\mathbf{x}$ that maximize or minimize the objective function $f(\mathbf{x})$.

Input Data

This calculator requires from users two inputs. The first consists of two lines: "max" or "min" in the first line and the coefficient $\mathbf{c}$ in the second line. For example, you want to maximize $f(\mathbf{x})=x_1+2x_2+3x_3$, the first input is as below:

max
1   2    3

The second input is for the linear constraints. It is entered as an $m\times (n+2)$ matrix, where $m$ is the number of constraints, $n$ the number of variables. The first $n$ columns represent matrix $\mathbf{A}$. The next column represents equality sign or inequality sign in the form of numbers as follows: $-1$ for $\leqslant$, $0$ for $=$, and $1$ for $\geqslant$. The last column represents the right-hand-side vector $\mathbf{b}$. For example, the constraints below \[ \begin{array}{rcl} x_1 + x_2 - x_3 & = & 1 \\ -2x_1 + x_2 + 2x_3 & \geqslant & -5 \\ x_1 - x_2 & \leqslant & 4 \\ x_2 + x_3 & \leqslant & 5 \end{array} \] is entered in the second input as
  1    1   -1   0   1
 -2    1    2   1  -5
  1   -1    0  -1   4
  0    1    1  -1   5

Note that $0$'s are entered into the third/fourth rows as they do not depend on $x_3$ and $x_1$, respectively.

Linear Programming Calculator

Advertise