Octave
Octave is software intended for performing numerical computations, such as solving linear and nonlinear problems, using a language that is mostly compatible with Matlab.
Reference documents
- GNU Octave reference manual
- Frequently asked questions about GNU Octave
- GNU Octave reference card
- octave-help mailing list archives: Dec 2011 (Nov, Oct, Sep, Aug, Jul, Jun, May, Apr, Mar, Feb, Jan)
Linear programming
Linear programming is a technique to identify maximum and minimum solutions for problems, often referred to as optimization. It is a common technique because a surprising number of real world problems can be described or estimated using linear equations. For example, in manufacturing:
- Programming is a synonym for planning, or more specifically, planning of manufacturing activities, resources and products
- The linear objective function describes the potential amount of profit, loss, revenue or cost
- Variables are the resources (input) and/or products (output) related to the manufacturing activities
- Linear equality and inequality constraints describe requirements or restrictions caused by manufacturing activities
- Maximization is concerned with profit, revenue or output quantities
- Minimization is concerned with loss, costs or input quantities
A standard form of a linear programming problem is to find values of x1, x2, ... , xn so as to
Subject to
(note 1)
maximize z = c1x1 + c2x2 + ... + cnxn
Subject to
(note 2)
a11x1 + a12x2 + ... + a1nxn ≤ b1
a21x1 + a22x2 + ... + a2nxn ≤ b2
...
am1x1 + am2x2 + ... + amnxn ≤ bm
anda21x1 + a22x2 + ... + a2nxn ≤ b2
...
am1x1 + am2x2 + ... + amnxn ≤ bm
(note 3)
x1 ≥ 0, x2 ≥ 0, ... , xn ≥ 0
Notes:
(1) Objective function could also be expressed as minimizing z
(2) Functional constraints could also be expressed with ≥ or =
(3) This requirement is also known as the nonnegativity constraint
(1) Objective function could also be expressed as minimizing z
(2) Functional constraints could also be expressed with ≥ or =
(3) This requirement is also known as the nonnegativity constraint
Linear programming has very specific terms:
- A solution is any specification of values for x1, x2, ... , xn
- A feasible solution is one such that all constraints are satisfied
- The feasible region is the collection of all feasible solutions
- It is possible for a problem to have an empty feasible region, e.g. no feasible solution
- An optimal solution is a feasible solution that has the most favorable value of the objective function
- When maximizing the objective function, the most favorable value is the largest value
- When minimizing the objective function, the most favorable value is the smallest value
As an example, consider the following linear programming problem:
Maximize z = 20x1 + 40x2
Such that,
4x1 + 6x2 ≤ 120
2x1 + 6x2 ≤ 72
x2 ≤ 10
x1, x2 ≥ 0
2x1 + 6x2 ≤ 72
x2 ≤ 10
x1, x2 ≥ 0
The Octave script below uses the glpk() function to solve the example problem.
Evaluating polynomial functions for specific variables
Octave scripts use a vector of the coefficients in descending order to represent a polynomial function. Afterwards, the command polyval() can be used to evaluate the function for specific variables. For example, consider this function:
- y = 3x2 - 3x - 6
Plotting polynomial functions
Octave uses a vector of the coefficients in descending order to represent a polynomial function. For example, consider this function:
- y = 3x2 - 3x - 6
Polynomial functions can be plotted in an Octave script by using the polyval and plot commands.
Finding roots of polynomial functions
A common task in many business and computing subjects is the calculation of minima and maxima values. This task requires finding the roots of first and second order derivatives, which can be done conveniently using Maxima or Octave scripts. For example, consider this function:
- y = 3x2 - 3x - 6
Polynomial functions are expressed quite literally in Maxima scripts. They use the realroots() command to calculate real valued roots.
Alternatively, an Octave script could also find the real valued roots. The main difference is that Octave uses a vector of the coefficients in descending order to represent a polynomial function.
http://hughesbennett.co.uk/Octave