/usr/share/doc/lp-solve-doc/MathProg.htm is in lp-solve-doc 5.5.0.13-7build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<HEAD>
<TITLE>GNU MathProg</TITLE>
<style TYPE="text/css"> BODY { font-family:verdana,arial,helvetica; margin:0; }
</style>
</HEAD>
<BODY>
<TABLE STYLE="TABLE-LAYOUT:fixed" class="clsContainer" CELLPADDING="15" CELLSPACING="0"
WIDTH="100%" BORDER="0">
<TR>
<TD VALIGN="top">
<h1 align="left"><u>GNU MathProg</u></h1>
<p>GNU MathProg is a modeling language intended for describing linear mathematical programming models.
<br>
Model descriptions written in the GNU MathProg language consist of a set of statements and data blocks
constructed by the user.
</p>
<p>See <a href="http://gnuwin32.sourceforge.net/downlinks/glpk-doc-zip.php">http://gnuwin32.sourceforge.net/downlinks/glpk-doc-zip.php</a> for a complete description of this modeling language.</p>
<p>GNU MathProg is part of the GLPK solver.
See <a href="http://www.gnu.org/software/glpk/glpk.html">http://www.gnu.org/software/glpk/glpk.html</a>
and <a href="http://gnuwin32.sourceforge.net/packages/glpk.htm">http://gnuwin32.sourceforge.net/packages/glpk.htm</a>
for the homepage of it.<br>
Note that MathProg is a subset of the AMPL modeling language. See <a href="AMPL.htm">Using lpsolve from AMPL</a>.<br>
The XLI used by lp_solve to read these models is derived from this code.<br>
<br>
lp_solve can read/write and solve these MathProg models directly via the xli_MathProg XLI driver (see <a href="XLI.htm">External Language Interfaces</a>).
It reads such a model in above format and can solve it then.<br>
<br>
For example:</p>
<pre>
lp_solve -rxli xli_MathProg <a href="#Diet1.mod">Diet1.mod</a>
</pre>
<p>This gives as result:</p>
<pre>
Value of objective function: 88.2
Actual values of the variables:
Buy[BEEF] 0
Buy[CHK] 0
Buy[FISH] 0
Buy[HAM] 0
Buy[MCH] 46.6667
Buy[MTL] 0
Buy[SPG] 0
Buy[TUR] 0
</pre>
<p>MathProg has also the possibility to have the model and data in two separate files.
lp_solve can handle this also. For example:</p>
<pre>
lp_solve -rxli xli_MathProg <a href="#diet.mod">diet.mod</a> -rxlidata <a href="#diet.dat">diet.dat</a>
</pre>
<p>This gives as result:</p>
<pre>
Value of objective function: 88.2
Actual values of the variables:
Buy[BEEF] 0
Buy[CHK] 0
Buy[FISH] 0
Buy[HAM] 0
Buy[MCH] 46.6667
Buy[MTL] 0
Buy[SPG] 0
Buy[TUR] 0
</pre>
<h4>Generating MathProg models</h4>
<p>The XLI can also create a MathProg model, however it doesn't use the strength of the language.
Constraints are written out line per line. But it can be a starter.
For example:</p>
<pre>
lp_solve <a href="#model.lp">model.lp</a> -wxli xli_MathProg model.mod
</pre>
<p>This gives as model.mod:</p>
<pre>
/* Variable definitions */
var x >= 0;
var y >= 0;
/* Objective function */
maximize obj: +143*x +60*y;
/* Constraints */
R1: +120*x +210*y <= 15000;
R2: +110*x +30*y <= 4000;
R3: +x +y <= 75;
</pre>
<h4>API</h4>
<p>Use the lpsolve API call <a href="read_XLI.htm">read_XLI</a> to read a model
and <a href="write_XLI.htm">write_XLI</a> to write a model.
See also <a href="XLI.htm">External Language Interfaces</a>.
</p>
<h4>IDE</h4>
<p>Also from within the IDE, this XLI can be used. However, some entries
must be added in LpSolveIDE.ini (in the folder where the IDE is installed).
</p>
<p>In the [XLI] section the following must be added:</p>
<pre>
lib1=xli_MathProg
</pre>
<p>And a new section for the MathProg XLI must also be added:</p>
<pre>
[xli_MathProg]
extension=.mod
language=MATHPROG
</pre>
<p>Then make sure that the xli_MathProg.dll is available for the IDE.
This must be done by placing this dll in the IDE folder or in the
Windows system32 folder.</p>
<h4>Example models/data</h4>
<a name="Diet1.mod"></a>
<h5>Diet1.mod</h5>
<pre>
set NUTR;
set FOOD;
param cost {FOOD} > 0;
param f_min {FOOD} >= 0;
param f_max {j in FOOD} >= f_min[j];
param n_min {NUTR} >= 0;
param n_max {i in NUTR} >= n_min[i];
param amt {NUTR,FOOD} >= 0;
var Buy {j in FOOD} >= f_min[j], <= f_max[j];
minimize total_cost: sum {j in FOOD} cost[j] * Buy[j];
subject to diet {i in NUTR}:
n_min[i] <= sum {j in FOOD} amt[i,j] * Buy[j] <= n_max[i];
data;
set NUTR := A B1 B2 C ;
set FOOD := BEEF CHK FISH HAM MCH MTL SPG TUR ;
param: cost f_min f_max :=
BEEF 3.19 0 100
CHK 2.59 0 100
FISH 2.29 0 100
HAM 2.89 0 100
MCH 1.89 0 100
MTL 1.99 0 100
SPG 1.99 0 100
TUR 2.49 0 100 ;
param: n_min n_max :=
A 700 10000
C 700 10000
B1 700 10000
B2 700 10000 ;
param amt (tr):
A C B1 B2 :=
BEEF 60 20 10 15
CHK 8 0 20 20
FISH 8 10 15 10
HAM 40 40 35 10
MCH 15 35 15 15
MTL 70 30 15 15
SPG 25 50 25 15
TUR 60 20 15 10 ;
end;
</pre>
<a name="diet.mod"></a>
<h5>diet.mod</h5>
<pre>
set NUTR;
set FOOD;
param cost {FOOD} > 0;
param f_min {FOOD} >= 0;
param f_max {j in FOOD} >= f_min[j];
param n_min {NUTR} >= 0;
param n_max {i in NUTR} >= n_min[i];
param amt {NUTR,FOOD} >= 0;
var Buy {j in FOOD} >= f_min[j], <= f_max[j];
minimize total_cost: sum {j in FOOD} cost[j] * Buy[j];
subject to diet {i in NUTR}:
n_min[i] <= sum {j in FOOD} amt[i,j] * Buy[j] <= n_max[i];
</pre>
<a name="diet.dat"></a>
<h5>diet.dat</h5>
<pre>
set NUTR := A B1 B2 C ;
set FOOD := BEEF CHK FISH HAM MCH MTL SPG TUR ;
param: cost f_min f_max :=
BEEF 3.19 0 100
CHK 2.59 0 100
FISH 2.29 0 100
HAM 2.89 0 100
MCH 1.89 0 100
MTL 1.99 0 100
SPG 1.99 0 100
TUR 2.49 0 100 ;
param: n_min n_max :=
A 700 10000
C 700 10000
B1 700 10000
B2 700 10000 ;
param amt (tr):
A C B1 B2 :=
BEEF 60 20 10 15
CHK 8 0 20 20
FISH 8 10 15 10
HAM 40 40 35 10
MCH 15 35 15 15
MTL 70 30 15 15
SPG 25 50 25 15
TUR 60 20 15 10 ;
</pre>
<a name="model.lp"></a>
<h5>model.lp</h5>
<pre>
/* model.lp */
max: 143 x + 60 y;
120 x + 210 y <= 15000;
110 x + 30 y <= 4000;
x + y <= 75;
</pre>
</TD>
</TR>
</TABLE>
</BODY>
</html>
|