LINEAR OPTIMIZATION WITH PYTHON
LINEAR OPTIMIZATION WITH PYTHON
Jos?e M. Garrido Department of Computer Science
January 2016
College of Computing and Software Engineering Kennesaw State University
c 2015 J. M. Garrido
Linear Optimization with Python
2
1 General Form of a Linear Optimization Model
The following is a general form of a linear optimization model that is basically organized in three parts.
1. The objective function, f , to be maximized or minimized, mathematically expressed as:
f (x1, x2, . . . , xn) = c1x1 + c2x2 + . . . + cnxn
(1)
2. The set of m constraints, which is of the form:
ai,1x1 + ai,2x2 + . . . + ai,nxn bi i = 1, . . . m
(2)
The other form is:
ai,1x1 + ai,2x2 + . . . + ai,nxn bi i = 1, . . . m
(3)
3. The sign restriction for variables: xj 0, or xj 0, or xj unrestricted in sign, j = 1, . . . n.
Many problems are formulated with a mix of m constraints with , =, and forms. Note that the objective function, which is expressed mathematically in (1), and the constraints, which are expressed mathematically in (2) and (3), are linear mathematical (algebraic) expressions.
An important assumption included in the general formulation of a linear optimization problem is that the variables, xi, i = 1, . . . n, take numeric values that are real or fractional. In the case that one or more variables only take integer values, then other techniques and algorithms are used. These methods belong to the class of Integer Linear Optimization or Mixed Integer Optimization.
2 The Simplex Algorithm
The Simplex algorithm, due to George B. Dantzig, is used to solve linear optimization problems. It is a tabular solution algorithm and is a powerful computational procedure that provides fast solutions to relatively large-scale applications. There are many software implementations of this algorithm, or variations of it. The basic algorithm is applied to a linear programming problem that is in standard form, in which all constraints are equations and all variables non-negative.
c 2015 J. M. Garrido
Linear Optimization with Python
3
2.1 Foundations of the Simplex Algorithm
For a given linear optimization problem, a point is the set of values corresponding to one for each decision variable. The feasible region for the problem, is the set of all points that satisfy the constraints and all sign restrictions. If there are points that are not in the feasible region, they are said to be in an infeasible region.
The optimal solution to a linear maximization problem is a point in the feasible region with the largest value of the objective function. In a similar manner, the optimal solution to a linear minimization problem is a point in the feasible region with the smallest value of the objective function.
There are four cases to consider in a linear optimization problem.
1. A unique optimal solution
2. An infinite number of optimal solutions
3. No feasible solutions
4. An unbounded solution
In a linear maximization problem, a constraint is binding at an optimal solution if it holds with equality when the values of the variables are substituted in the constraint.
2.2 Problem Formulation in Standard Form
Because the Simplex algorithm requires the problem to be formulated in standard form, the general form of the problem must be converted to standard form.
? For each constraint of form, a slack variable is defined. For constraint i, slack variable si is included. Initially constraint i has the general form:
ai,1x1 + ai,2x2 + . . . + ai,nxn bi
(4)
To convert constraint i of the general form of the expression in (4) to an equality, slack variable si is added to the constraint, and si 0. The constraint will now have the form:
ai,1x1 + ai,2x2 + . . . + ai,nxn + si = bi
(5)
c 2015 J. M. Garrido
Linear Optimization with Python
4
? For each constraint of form, an excess variable is defined. For constraint i, excess variable ei is included. Initially constraint i has the general form:
ai,1x1 + ai,2x2 + . . . + ai,nxn bi
(6)
To convert constraint i of the general form of the expression in (6) to an equality, excess variable ei is subtracted from the constraint, and ei 0. The constraint will now have the form:
ai,1x1 + ai,2x2 + . . . + ai,nxn - ei = bi
(7)
Consider the following formulation of a numerical example:
Maximize: 5x1 + 3x2 Subject to:
2x1 + x2 40 x1 + 2x2 50
x1 0 x2 0
After rewriting the objective function and adding two slack variables s1 and s2 to the problem, the transformed problem formulation in standard form is:
Maximize: z - 5x1 - 3x2 = 0. Subject to the following constraints:
2x1 + x2 + s1
= 40
x1 + 2x2
+ s2 = 50
x1 0 x2 0 s1 0 s2 0
2.3 Generalized Standard Form
A generalized standard form of a linear optimization problem is: Maximize (or minimize) f = c1x1 + c2x2 + . . . + cnxn Subject to the following constraints:
c 2015 J. M. Garrido
Linear Optimization with Python
5
a1,1x1 + a1,2x2 + . . . + a1,nxn = b1
a2,1x1 + a2,2x2 + . . . + a2,nxn = b2
...
...
...
...
(8)
am,1x1 + am,2x2 + . . . + am,nxn = bm
xi 0, i = 1, 2, . . . , n.
The constraints can be written in matrix form as follows:
aa12,,11 am... ,1
aa12,,22 a2...,m
??? ??? ... ???
aa12,,nn am... ,n
xx12 ... xn
=
b1 b2 ... bm
(9)
Equation (9) can also be written as AX = B, in which A is an m ? n matrix, X is a column vector of size n, and B is a column vector of size m.
2.4 Additional Definitions
To derive a basic solution to Equation (9), a set m of variables known as the basic variables is used to compute a solution. These variables are the ones left after setting the nonbasic variables, which is the set of n - m variables chosen and set to zero.
There can be several different basic solutions in a linear optimization problem. There could be one or more sets of m basic variables for which a basic solution cannot be derived.
A basic feasible solution to the standard formulation of a linear optimization problem is a basic solution in which the variables are non-negative.
The solution to a linear optimization problem is the best basic feasible solution to AX = B (or Equation (9)).
3 Description of The Simplex Algorithm
In addition to transforming the constraints to standard form, the expression of the objective function must be changed to an equation with zero on its right-hand side. The general expression:
is changed to
f = c1x1 + c2x2 + . . . + cnxn
c 2015 J. M. Garrido
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- project 3 hannah choi data 8
- numerical computing in python cornell university
- numpy primer
- module 1 introduction 2 module grids
- linear optimization with python
- informatics practices new 065 class xii kv no 1
- research ideas northwestern university
- avinash maurya full stack web developer
- error handling pandas and data analysis
- markov models numpy
Related searches
- linear equation with 3 variables calculator
- linear equations with inequalities
- linear inequalities with two variables
- solving linear equation with two unknowns
- solving linear equations with 2 variables
- linear equation with no solution
- linear inequalities with two variables examples
- solving linear equations with fractions
- linear algebra with applications pdf
- linear equations with fractions examples
- linear equations with fractions practice
- linear equations with 3 variables