File: simplex.texi

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (171 lines) | stat: -rw-r--r-- 5,122 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@menu
* Introduction to simplex::
* Functions and Variables for simplex::
@end menu

@node Introduction to simplex, Functions and Variables for simplex, simplex, simplex
@section Introduction to simplex

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

Example:

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

@opencatbox
@category{Numerical methods} @category{Share packages} @category{Package simplex}
@closecatbox

@node Functions and Variables for simplex,  , Introduction to simplex, simplex
@section Functions and Variables for simplex

@defvr {Option variable} epsilon_lp
Default value: @code{10^-8}

Epsilon used for numerical computations in @code{linear_program}.

See also: @code{linear_program}.

@opencatbox
@category{Package simplex}
@closecatbox

@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:

@c ===beg===
@c A: matrix([1,1,-1,0], [2,-3,0,-1], [4,-5,0,0])$
@c b: [1,1,6]$
@c c: [1,-2,0,0]$
@c linear_program(A, b, c);
@c ===end===
@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: @code{minimize_lp}, @code{scale_lp}, and @code{epsilon_lp}.

@opencatbox
@category{Package simplex} @category{Numerical methods}
@closecatbox

@end deffn

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

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


See also: @code{minimize_lp}.

@opencatbox
@category{Package simplex} @category{Numerical methods}
@closecatbox

@end deffn

@deffn {Function} minimize_lp (@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_lp} 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_lp} 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_lp} 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_lp} 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:

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


See also: @code{maximize_lp}, @code{nonegative_lp}, @code{epsilon_lp}.

@opencatbox
@category{Package simplex} @category{Numerical methods}
@closecatbox

@end deffn

@defvr {Option variable} nonegative_lp
Default value: @code{false}

If @code{nonegative_lp} is true all decision variables to
@code{minimize_lp} and @code{maximize_lp} are assumed to be positive.

See also: @code{minimize_lp}.

@opencatbox
@category{Package simplex}
@closecatbox

@end defvr