LinearProgram<T>

Models & Types · AiDotNet.Solvers.LinearProgramming

Describes a linear program: a linear objective minimized subject to linear constraints and bounds on the variables.

For Beginners

A linear program is the mathematical form of “get the most out of limited resources”. Every quantity you can choose is a variable; the thing you want to make as large or small as possible is the objective; and the limits you cannot exceed are the constraints. Scheduling staff, blending materials, routing deliveries and allocating a budget are all linear programs.

How It Works

The problem solved is

Any of the constraint blocks may be omitted. When no bounds are supplied the variables are taken to be non-negative (lower = 0, upper = +∞), which is the convention used by every standard linear-programming interface.

Maximization is expressed by negating the objective: maximizing pᵀx is minimizing (−p)ᵀx, and the reported objective value is then the negative of the maximum.

The defining feature is that everything is linear — doubling a variable doubles its contribution, and there are no products of variables. That restriction is what makes these problems solvable exactly and quickly, even with thousands of variables.

Constructors

Constructor Summary
LinearProgram(Vector<T> objective, Matrix<T> inequalityMatrix, Vector<T> inequalityBounds, Matrix<T> equalityMatrix, Vector<T> equalityBounds, Vector<T> lowerBounds, Vector<T> upperBounds) Creates a linear program.

Properties

Property Summary
Matrix<T> EqualityMatrix { get; } Gets the equality constraint matrix A_eq, or null when there are none.
Matrix<T> InequalityMatrix { get; } Gets the inequality constraint matrix A_ub, or null when there are none.
Vector<T> EqualityBounds { get; } Gets the equality right-hand side b_eq, or null when there are none.
Vector<T> InequalityBounds { get; } Gets the inequality right-hand side b_ub, or null when there are none.
Vector<T> LowerBounds { get; } Gets the lower bound on each variable, or null to mean zero for every variable.
Vector<T> Objective { get; } Gets the objective coefficients c.
Vector<T> UpperBounds { get; } Gets the upper bound on each variable, or null to mean positive infinity for every variable.
int VariableCount { get; } Gets the number of decision variables.