\input texinfo
@c makeinfo simplex.texi         to make .info
@c texi2html simplex.texi        to make .html
@c texi2pdf simplex.texi         to make .pdf

@setfilename simplex.info
@settitle simplex

@ifinfo 
@macro var {obj}
<\obj\>
@end macro
@end ifinfo

@node Top, Introduction to simplex, (dir), (dir)
@top
@menu
* Introduction to simplex::
* Definitions for simplex::
* Function and variable index::
@end menu

@node Introduction to simplex, Definitions for simplex, Top, Top
@section Introduction to simplex

@code{simplex} is a package for linear optimization using the simplex algorithm.

Example:

@example
(%i1) load("simplex")$
(%i2) minimize_sx(x+y, [3*x+2*y>2, x+4*y>3]);
                  9        7       1
(%o2)            [--, [y = --, x = -]]
                  10       10      5
@end example

@node Definitions for simplex, Function and variable index, Introduction to simplex, Top
@section Definitions for simplex

@defvr {Option variable} epsilon_sx

Epsilon used for numerical computations in @code{linear_program}. The default value is
10^-8.

See also: linear_program.

@end defvr

@deffn {Function} linear_program (@var{A}, @var{b}, @var{c})

@code{linear_program} is an implementation of the simplex algorithm.
@code{linear_program(A, b, c)} computes a vector @var{x} for which @code{c.x} is minimum
possible among vectors for which @code{A.x = b} and @code{x >= 0}. Argument
@var{A} is a matrix and arguments @var{b} and @var{c} are lists.

@code{linear_program} returns a list which contains the minimizing vector @var{x} and the
minimum value @code{c.x}. If the problem is not bounded, it returns "Problem not bounded!" and
if the problem is not feasible, it returns "Problem not feasible!".

To use this function first load the @code{simplex} package with @code{load(simplex);}.

Example:

@example
(%i2) A: matrix([1,1,-1,0], [2,-3,0,-1], [4,-5,0,0])$
(%i3) b: [1,1,6]$
(%i4) c: [1,-2,0,0]$
(%i5) linear_program(A, b, c);
                   13     19        3
(%o5)            [[--, 4, --, 0], - -]
                   2      2         2
@end example

See also: minimize_sx, scale_sx, epsilon_sx.

@end deffn

@deffn {Function} maximize_sx (@var{obj}, @var{cond}, [@var{pos}])

Maximizes linear objective function @var{obj} subject to some linear constraints
@var{cond}. See @code{minimize_sx} for detailed description of arguments and return
value.


See also: minimize_sx.

@end deffn

@deffn {Function} minimize_sx (@var{obj}, @var{cond}, [@var{pos}])

Minimizes a linear objective function @var{obj} subject to some linear
constraints @var{cond}. @var{cond} a list of linear equations or
inequalities. In strict inequalities @code{>} is replaced by @code{>=}
and @code{<} by @code{<=}. The optional argument @var{pos} is a list of
decision variables which are assumed to be positive.

If the minimum exists, @code{minimize_sx} returns a list which contains
the minimum value of the objective function and a list of decision variable
values for which the minimum is attained. If the problem is not bounded,
@code{minimize_sx} returns "Problem not bounded!" and if the problem
is not feasible, it returns "Ploblem not feasible!".

The decision variables are not assumed to be nonegative by default. If all
decision variables are nonegative, set @code{nonegative_sx} to @code{true}.
If only some of decision variables are positive, list them in the optional
argument @var{pos} (note that this is more efficient than adding
constraints).

@code{minimize_sx} uses the simplex algorithm which is implemented in maxima
@code{linear_program} function.

To use this function first load the @code{simplex} package with @code{load(simplex);}.

Examples:

@example
(%i1) minimize_sx(x+y, [3*x+y=0, x+2*y>2]);
                      4       6        2
(%o1)                [-, [y = -, x = - -]]
                      5       5        5
(%i2) minimize_sx(x+y, [3*x+y>0, x+2*y>2]), nonegative_sx=true;
(%o2)                [1, [y = 1, x = 0]]
(%i3) minimize_sx(x+y, [3*x+y=0, x+2*y>2]), nonegative_sx=true;
(%o3)                Problem not feasible!
(%i4) minimize_sx(x+y, [3*x+y>0]);
(%o4)                Problem not bounded!
@end example


See also: maximize_sx, nonegative_sx, epsilon_sx.

@end deffn

@defvr {Option variable} nonegative_sx

If @code{nonegative_sx} is true all decision variables to @code{minimize_sx}
and @code{maximize_sx} are assumed to be positive. The default value is
@code{false}.

See also: minimize_sx.

@end defvr

@node Function and variable index,  , Definitions for simplex, Top
@appendix Function and variable index
@printindex fn
@printindex vr

@bye
