alpar@1
|
1 |
%* glpk03.tex *%
|
alpar@1
|
2 |
|
alpar@1
|
3 |
\chapter{Utility API routines}
|
alpar@1
|
4 |
|
alpar@1
|
5 |
\section{Problem data reading/writing routines}
|
alpar@1
|
6 |
|
alpar@1
|
7 |
\subsection{glp\_read\_mps---read problem data in MPS format}
|
alpar@1
|
8 |
|
alpar@1
|
9 |
\subsubsection*{Synopsis}
|
alpar@1
|
10 |
|
alpar@1
|
11 |
\begin{verbatim}
|
alpar@1
|
12 |
int glp_read_mps(glp_prob *lp, int fmt, const void *parm,
|
alpar@1
|
13 |
const char *fname);
|
alpar@1
|
14 |
\end{verbatim}
|
alpar@1
|
15 |
|
alpar@1
|
16 |
\subsubsection*{Description}
|
alpar@1
|
17 |
|
alpar@1
|
18 |
The routine \verb|glp_read_mps| reads problem data in MPS format from a
|
alpar@1
|
19 |
text file. (The MPS format is described in Appendix \ref{champs}, page
|
alpar@1
|
20 |
\pageref{champs}.)
|
alpar@1
|
21 |
|
alpar@1
|
22 |
The parameter \verb|fmt| specifies the MPS format version as follows:
|
alpar@1
|
23 |
|
alpar@1
|
24 |
\begin{tabular}{@{}ll}
|
alpar@1
|
25 |
\verb|GLP_MPS_DECK| & fixed (ancient) MPS format; \\
|
alpar@1
|
26 |
\verb|GLP_MPS_FILE| & free (modern) MPS format. \\
|
alpar@1
|
27 |
\end{tabular}
|
alpar@1
|
28 |
|
alpar@1
|
29 |
The parameter \verb|parm| is reserved for use in the future and must be
|
alpar@1
|
30 |
specified as \verb|NULL|.
|
alpar@1
|
31 |
|
alpar@1
|
32 |
The character string \verb|fname| specifies a name of the text file to
|
alpar@1
|
33 |
be read in. (If the file name ends with suffix `\verb|.gz|', the file is
|
alpar@1
|
34 |
assumed to be compressed, in which case the routine \verb|glp_read_mps|
|
alpar@1
|
35 |
decompresses it ``on the fly''.)
|
alpar@1
|
36 |
|
alpar@1
|
37 |
Note that before reading data the current content of the problem object
|
alpar@1
|
38 |
is completely erased with the routine \verb|glp_erase_prob|.
|
alpar@1
|
39 |
|
alpar@1
|
40 |
\subsubsection*{Returns}
|
alpar@1
|
41 |
|
alpar@1
|
42 |
If the operation was successful, the routine \verb|glp_read_mps|
|
alpar@1
|
43 |
returns zero. Otherwise, it prints an error message and returns
|
alpar@1
|
44 |
non-zero.
|
alpar@1
|
45 |
|
alpar@1
|
46 |
\subsection{glp\_write\_mps---write problem data in MPS format}
|
alpar@1
|
47 |
|
alpar@1
|
48 |
\subsubsection*{Synopsis}
|
alpar@1
|
49 |
|
alpar@1
|
50 |
\begin{verbatim}
|
alpar@1
|
51 |
int glp_write_mps(glp_prob *lp, int fmt, const void *parm,
|
alpar@1
|
52 |
const char *fname);
|
alpar@1
|
53 |
\end{verbatim}
|
alpar@1
|
54 |
|
alpar@1
|
55 |
\subsubsection*{Description}
|
alpar@1
|
56 |
|
alpar@1
|
57 |
The routine \verb|glp_write_mps| writes problem data in MPS format to a
|
alpar@1
|
58 |
text file. (The MPS format is described in Appendix \ref{champs}, page
|
alpar@1
|
59 |
\pageref{champs}.)
|
alpar@1
|
60 |
|
alpar@1
|
61 |
The parameter \verb|fmt| specifies the MPS format version as follows:
|
alpar@1
|
62 |
|
alpar@1
|
63 |
\begin{tabular}{@{}ll}
|
alpar@1
|
64 |
\verb|GLP_MPS_DECK| & fixed (ancient) MPS format; \\
|
alpar@1
|
65 |
\verb|GLP_MPS_FILE| & free (modern) MPS format. \\
|
alpar@1
|
66 |
\end{tabular}
|
alpar@1
|
67 |
|
alpar@1
|
68 |
The parameter \verb|parm| is reserved for use in the future and must be
|
alpar@1
|
69 |
specified as \verb|NULL|.
|
alpar@1
|
70 |
|
alpar@1
|
71 |
The character string \verb|fname| specifies a name of the text file to
|
alpar@1
|
72 |
be written out. (If the file name ends with suffix `\verb|.gz|', the
|
alpar@1
|
73 |
file is assumed to be compressed, in which case the routine
|
alpar@1
|
74 |
\verb|glp_write_mps| performs automatic compression on writing it.)
|
alpar@1
|
75 |
|
alpar@1
|
76 |
\subsubsection*{Returns}
|
alpar@1
|
77 |
|
alpar@1
|
78 |
If the operation was successful, the routine \verb|glp_write_mps|
|
alpar@1
|
79 |
returns zero. Otherwise, it prints an error message and returns
|
alpar@1
|
80 |
non-zero.
|
alpar@1
|
81 |
|
alpar@1
|
82 |
\subsection{glp\_read\_lp---read problem data in CPLEX LP format}
|
alpar@1
|
83 |
|
alpar@1
|
84 |
\subsubsection*{Synopsis}
|
alpar@1
|
85 |
|
alpar@1
|
86 |
\begin{verbatim}
|
alpar@1
|
87 |
int glp_read_lp(glp_prob *lp, const void *parm,
|
alpar@1
|
88 |
const char *fname);
|
alpar@1
|
89 |
\end{verbatim}
|
alpar@1
|
90 |
|
alpar@1
|
91 |
\subsubsection*{Description}
|
alpar@1
|
92 |
|
alpar@1
|
93 |
The routine \verb|glp_read_lp| reads problem data in CPLEX LP format
|
alpar@1
|
94 |
from a text file. (The CPLEX LP format is described in Appendix
|
alpar@1
|
95 |
\ref{chacplex}, page \pageref{chacplex}.)
|
alpar@1
|
96 |
|
alpar@1
|
97 |
The parameter \verb|parm| is reserved for use in the future and must be
|
alpar@1
|
98 |
specified as \verb|NULL|.
|
alpar@1
|
99 |
|
alpar@1
|
100 |
The character string \verb|fname| specifies a name of the text file to
|
alpar@1
|
101 |
be read in. (If the file name ends with suffix `\verb|.gz|', the file is
|
alpar@1
|
102 |
assumed to be compressed, in which case the routine \verb|glp_read_lp|
|
alpar@1
|
103 |
decompresses it ``on the fly''.)
|
alpar@1
|
104 |
|
alpar@1
|
105 |
Note that before reading data the current content of the problem object
|
alpar@1
|
106 |
is completely erased with the routine \verb|glp_erase_prob|.
|
alpar@1
|
107 |
|
alpar@1
|
108 |
\subsubsection*{Returns}
|
alpar@1
|
109 |
|
alpar@1
|
110 |
If the operation was successful, the routine \verb|glp_read_lp| returns
|
alpar@1
|
111 |
zero. Otherwise, it prints an error message and returns non-zero.
|
alpar@1
|
112 |
|
alpar@1
|
113 |
\subsection{glp\_write\_lp---write problem data in CPLEX LP format}
|
alpar@1
|
114 |
|
alpar@1
|
115 |
\subsubsection*{Synopsis}
|
alpar@1
|
116 |
|
alpar@1
|
117 |
\begin{verbatim}
|
alpar@1
|
118 |
int glp_write_lp(glp_prob *lp, const void *parm,
|
alpar@1
|
119 |
const char *fname);
|
alpar@1
|
120 |
\end{verbatim}
|
alpar@1
|
121 |
|
alpar@1
|
122 |
\subsubsection*{Description}
|
alpar@1
|
123 |
|
alpar@1
|
124 |
The routine \verb|glp_write_lp| writes problem data in CPLEX LP format
|
alpar@1
|
125 |
to a text file. (The CPLEX LP format is described in Appendix
|
alpar@1
|
126 |
\ref{chacplex}, page \pageref{chacplex}.)
|
alpar@1
|
127 |
|
alpar@1
|
128 |
The parameter \verb|parm| is reserved for use in the future and must be
|
alpar@1
|
129 |
specified as \verb|NULL|.
|
alpar@1
|
130 |
|
alpar@1
|
131 |
The character string \verb|fname| specifies a name of the text file to
|
alpar@1
|
132 |
be written out. (If the file name ends with suffix `\verb|.gz|', the
|
alpar@1
|
133 |
file is assumed to be compressed, in which case the routine
|
alpar@1
|
134 |
\verb|glp_write_lp| performs automatic compression on writing it.)
|
alpar@1
|
135 |
|
alpar@1
|
136 |
\subsubsection*{Returns}
|
alpar@1
|
137 |
|
alpar@1
|
138 |
If the operation was successful, the routine \verb|glp_write_lp|
|
alpar@1
|
139 |
returns zero. Otherwise, it prints an error message and returns
|
alpar@1
|
140 |
non-zero.
|
alpar@1
|
141 |
|
alpar@1
|
142 |
\subsection{glp\_read\_prob---read problem data in GLPK format}
|
alpar@1
|
143 |
|
alpar@1
|
144 |
\subsubsection*{Synopsis}
|
alpar@1
|
145 |
|
alpar@1
|
146 |
\begin{verbatim}
|
alpar@1
|
147 |
int glp_read_prob(glp_prob *P, int flags, const char *fname);
|
alpar@1
|
148 |
\end{verbatim}
|
alpar@1
|
149 |
|
alpar@1
|
150 |
\subsubsection*{Description}
|
alpar@1
|
151 |
|
alpar@1
|
152 |
The routine \verb|glp_read_prob| reads problem data in the GLPK LP/MIP
|
alpar@1
|
153 |
format from a text file. (For description of the GLPK LP/MIP format see
|
alpar@1
|
154 |
below.)
|
alpar@1
|
155 |
|
alpar@1
|
156 |
The parameter \verb|flags| is reserved for use in the future and should
|
alpar@1
|
157 |
be specified as zero.
|
alpar@1
|
158 |
|
alpar@1
|
159 |
The character string \verb|fname| specifies a name of the text file to
|
alpar@1
|
160 |
be read in. (If the file name ends with suffix `\verb|.gz|', the file
|
alpar@1
|
161 |
is assumed to be compressed, in which case the routine
|
alpar@1
|
162 |
\verb|glp_read_prob| decompresses it ``on the fly''.)
|
alpar@1
|
163 |
|
alpar@1
|
164 |
Note that before reading data the current content of the problem object
|
alpar@1
|
165 |
is completely erased with the routine \verb|glp_erase_prob|.
|
alpar@1
|
166 |
|
alpar@1
|
167 |
\subsubsection*{Returns}
|
alpar@1
|
168 |
|
alpar@1
|
169 |
If the operation was successful, the routine \verb|glp_read_prob|
|
alpar@1
|
170 |
returns zero. Otherwise, it prints an error message and returns
|
alpar@1
|
171 |
non-zero.
|
alpar@1
|
172 |
|
alpar@1
|
173 |
\subsubsection*{GLPK LP/MIP format}
|
alpar@1
|
174 |
|
alpar@1
|
175 |
The GLPK LP/MIP format is a DIMACS-like format.\footnote{The DIMACS
|
alpar@1
|
176 |
formats were developed by the Center for Discrete Mathematics and
|
alpar@1
|
177 |
Theoretical Computer Science (DIMACS) to facilitate exchange of problem
|
alpar@1
|
178 |
data. For details see: {\tt <http://dimacs.rutgers.edu/Challenges/>}. }
|
alpar@1
|
179 |
The file in this format is a plain ASCII text file containing lines of
|
alpar@1
|
180 |
several types described below. A line is terminated with the end-of-line
|
alpar@1
|
181 |
character. Fields in each line are separated by at least one blank
|
alpar@1
|
182 |
space. Each line begins with a one-character designator to identify the
|
alpar@1
|
183 |
line type.
|
alpar@1
|
184 |
|
alpar@1
|
185 |
The first line of the data file must be the problem line (except
|
alpar@1
|
186 |
optional comment lines, which may precede the problem line). The last
|
alpar@1
|
187 |
line of the data file must be the end line. Other lines may follow in
|
alpar@1
|
188 |
arbitrary order, however, duplicate lines are not allowed.
|
alpar@1
|
189 |
|
alpar@1
|
190 |
\paragraph{Comment lines.} Comment lines give human-readable
|
alpar@1
|
191 |
information about the data file and are ignored by GLPK routines.
|
alpar@1
|
192 |
Comment lines can appear anywhere in the data file. Each comment line
|
alpar@1
|
193 |
begins with the lower-case character \verb|c|.
|
alpar@1
|
194 |
|
alpar@1
|
195 |
\begin{verbatim}
|
alpar@1
|
196 |
c This is an example of comment line
|
alpar@1
|
197 |
\end{verbatim}
|
alpar@1
|
198 |
|
alpar@1
|
199 |
\paragraph{Problem line.} There must be exactly one problem line in the
|
alpar@1
|
200 |
data file. This line must appear before any other lines except comment
|
alpar@1
|
201 |
lines and has the following format:
|
alpar@1
|
202 |
|
alpar@1
|
203 |
\begin{verbatim}
|
alpar@1
|
204 |
p CLASS DIR ROWS COLS NONZ
|
alpar@1
|
205 |
\end{verbatim}
|
alpar@1
|
206 |
|
alpar@1
|
207 |
The lower-case letter \verb|p| specifies that this is the problem line.
|
alpar@1
|
208 |
|
alpar@1
|
209 |
The \verb|CLASS| field defines the problem class and can contain either
|
alpar@1
|
210 |
the keyword \verb|lp| (that means linear programming problem) or
|
alpar@1
|
211 |
\verb|mip| (that means mixed integer programming problem).
|
alpar@1
|
212 |
|
alpar@1
|
213 |
The \verb|DIR| field defines the optimization direction (that is, the
|
alpar@1
|
214 |
objective function sense) and can contain either the keyword \verb|min|
|
alpar@1
|
215 |
(that means minimization) or \verb|max| (that means maximization).
|
alpar@1
|
216 |
|
alpar@1
|
217 |
The \verb|ROWS|, \verb|COLS|, and \verb|NONZ| fields contain
|
alpar@1
|
218 |
non-negative integer values specifying, respectively, the number of
|
alpar@1
|
219 |
rows (constraints), columns (variables), and non-zero constraint
|
alpar@1
|
220 |
coefficients in the problem instance. Note that \verb|NONZ| value does
|
alpar@1
|
221 |
not account objective coefficients.
|
alpar@1
|
222 |
|
alpar@1
|
223 |
\paragraph{Row descriptors.} There must be at most one row descriptor
|
alpar@1
|
224 |
line in the data file for each row (constraint). This line has one of
|
alpar@1
|
225 |
the following formats:
|
alpar@1
|
226 |
|
alpar@1
|
227 |
\begin{verbatim}
|
alpar@1
|
228 |
i ROW f
|
alpar@1
|
229 |
i ROW l RHS
|
alpar@1
|
230 |
i ROW u RHS
|
alpar@1
|
231 |
i ROW d RHS1 RHS2
|
alpar@1
|
232 |
i ROW s RHS
|
alpar@1
|
233 |
\end{verbatim}
|
alpar@1
|
234 |
|
alpar@1
|
235 |
The lower-case letter \verb|i| specifies that this is the row
|
alpar@1
|
236 |
descriptor line.
|
alpar@1
|
237 |
|
alpar@1
|
238 |
The \verb|ROW| field specifies the row ordinal number, an integer
|
alpar@1
|
239 |
between 1 and $m$, where $m$ is the number of rows in the problem
|
alpar@1
|
240 |
instance.
|
alpar@1
|
241 |
|
alpar@1
|
242 |
The next lower-case letter specifies the row type as follows:
|
alpar@1
|
243 |
|
alpar@1
|
244 |
\verb|f| --- free (unbounded) row: $-\infty<\sum a_jx_j<+\infty$;
|
alpar@1
|
245 |
|
alpar@1
|
246 |
\verb|l| --- inequality constraint of `$\geq$' type:
|
alpar@1
|
247 |
$\sum a_jx_j\geq b$;
|
alpar@1
|
248 |
|
alpar@1
|
249 |
\verb|u| --- inequality constraint of `$\leq$' type:
|
alpar@1
|
250 |
$\sum a_jx_j\leq b$;
|
alpar@1
|
251 |
|
alpar@1
|
252 |
\verb|d| --- double-sided inequality constraint:
|
alpar@1
|
253 |
$b_1\leq\sum a_jx_j\leq b_2$;
|
alpar@1
|
254 |
|
alpar@1
|
255 |
\verb|s| --- equality constraint: $\sum a_jx_j=b$.
|
alpar@1
|
256 |
|
alpar@1
|
257 |
The \verb|RHS| field contains a floaing-point value specifying the
|
alpar@1
|
258 |
row right-hand side. The \verb|RHS1| and \verb|RHS2| fields contain
|
alpar@1
|
259 |
floating-point values specifying, respectively, the lower and upper
|
alpar@1
|
260 |
right-hand sides for the double-sided row.
|
alpar@1
|
261 |
|
alpar@1
|
262 |
If for some row its descriptor line does not appear in the data file,
|
alpar@1
|
263 |
by default that row is assumed to be an equality constraint with zero
|
alpar@1
|
264 |
right-hand side.
|
alpar@1
|
265 |
|
alpar@1
|
266 |
\paragraph{Column descriptors.} There must be at most one column
|
alpar@1
|
267 |
descriptor line in the data file for each column (variable). This line
|
alpar@1
|
268 |
has one of the following formats depending on the problem class
|
alpar@1
|
269 |
specified in the problem line:
|
alpar@1
|
270 |
|
alpar@1
|
271 |
\bigskip
|
alpar@1
|
272 |
|
alpar@1
|
273 |
\begin{tabular}{@{}l@{\hspace*{40pt}}l}
|
alpar@1
|
274 |
LP class & MIP class \\
|
alpar@1
|
275 |
\hline
|
alpar@1
|
276 |
\verb|j COL f| & \verb|j COL KIND f| \\
|
alpar@1
|
277 |
\verb|j COL l BND| & \verb|j COL KIND l BND| \\
|
alpar@1
|
278 |
\verb|j COL u BND| & \verb|j COL KIND u BND| \\
|
alpar@1
|
279 |
\verb|j COL d BND1 BND2| & \verb|j COL KIND d BND1 BND2| \\
|
alpar@1
|
280 |
\verb|j COL s BND| & \verb|j COL KIND s BND| \\
|
alpar@1
|
281 |
\end{tabular}
|
alpar@1
|
282 |
|
alpar@1
|
283 |
\bigskip
|
alpar@1
|
284 |
|
alpar@1
|
285 |
The lower-case letter \verb|j| specifies that this is the column
|
alpar@1
|
286 |
descriptor line.
|
alpar@1
|
287 |
|
alpar@1
|
288 |
The \verb|COL| field specifies the column ordinal number, an integer
|
alpar@1
|
289 |
between 1 and $n$, where $n$ is the number of columns in the problem
|
alpar@1
|
290 |
instance.
|
alpar@1
|
291 |
|
alpar@1
|
292 |
The \verb|KIND| field is used only for MIP problems and specifies the
|
alpar@1
|
293 |
column kind as follows:
|
alpar@1
|
294 |
|
alpar@1
|
295 |
\verb|c| --- continuous column;
|
alpar@1
|
296 |
|
alpar@1
|
297 |
\verb|i| --- integer column;
|
alpar@1
|
298 |
|
alpar@1
|
299 |
\verb|b| --- binary column (in this case all remaining fields must be
|
alpar@1
|
300 |
omitted).
|
alpar@1
|
301 |
|
alpar@1
|
302 |
The next lower-case letter specifies the column type as follows:
|
alpar@1
|
303 |
|
alpar@1
|
304 |
\verb|f| --- free (unbounded) column: $-\infty<x<+\infty$;
|
alpar@1
|
305 |
|
alpar@1
|
306 |
\verb|l| --- column with lower bound: $x\geq l$;
|
alpar@1
|
307 |
|
alpar@1
|
308 |
\verb|u| --- column with upper bound: $x\leq u$;
|
alpar@1
|
309 |
|
alpar@1
|
310 |
\verb|d| --- double-bounded column: $l\leq x\leq u$;
|
alpar@1
|
311 |
|
alpar@1
|
312 |
\verb|s| --- fixed column: $x=s$.
|
alpar@1
|
313 |
|
alpar@1
|
314 |
The \verb|BND| field contains a floating-point value that specifies the
|
alpar@1
|
315 |
column bound. The \verb|BND1| and \verb|BND2| fields contain
|
alpar@1
|
316 |
floating-point values specifying, respectively, the lower and upper
|
alpar@1
|
317 |
bounds for the double-bounded column.
|
alpar@1
|
318 |
|
alpar@1
|
319 |
If for some column its descriptor line does not appear in the file, by
|
alpar@1
|
320 |
default that column is assumed to be non-negative (in case of LP class)
|
alpar@1
|
321 |
or binary (in case of MIP class).
|
alpar@1
|
322 |
|
alpar@1
|
323 |
\paragraph{Coefficient descriptors.} There must be exactly one
|
alpar@1
|
324 |
coefficient descriptor line in the data file for each non-zero
|
alpar@1
|
325 |
objective or constraint coefficient. This line has the following format:
|
alpar@1
|
326 |
|
alpar@1
|
327 |
\begin{verbatim}
|
alpar@1
|
328 |
a ROW COL VAL
|
alpar@1
|
329 |
\end{verbatim}
|
alpar@1
|
330 |
|
alpar@1
|
331 |
The lower-case letter \verb|a| specifies that this is the coefficient
|
alpar@1
|
332 |
descriptor line.
|
alpar@1
|
333 |
|
alpar@1
|
334 |
For objective coefficients the \verb|ROW| field must contain 0. For
|
alpar@1
|
335 |
constraint coefficients the \verb|ROW| field specifies the row ordinal
|
alpar@1
|
336 |
number, an integer between 1 and $m$, where $m$ is the number of rows
|
alpar@1
|
337 |
in the problem instance.
|
alpar@1
|
338 |
|
alpar@1
|
339 |
The \verb|COL| field specifies the column ordinal number, an integer
|
alpar@1
|
340 |
between 1 and $n$, where $n$ is the number of columns in the problem
|
alpar@1
|
341 |
instance.
|
alpar@1
|
342 |
|
alpar@1
|
343 |
If both the \verb|ROW| and \verb|COL| fields contain 0, the line
|
alpar@1
|
344 |
specifies the constant term (``shift'') of the objective function
|
alpar@1
|
345 |
rather than objective coefficient.
|
alpar@1
|
346 |
|
alpar@1
|
347 |
The \verb|VAL| field contains a floating-point coefficient value (it is
|
alpar@1
|
348 |
allowed to specify zero value in this field).
|
alpar@1
|
349 |
|
alpar@1
|
350 |
The number of constraint coefficient descriptor lines must be exactly
|
alpar@1
|
351 |
the same as specified in the field \verb|NONZ| of the problem line.
|
alpar@1
|
352 |
|
alpar@1
|
353 |
\paragraph{Symbolic name descriptors.} There must be at most one
|
alpar@1
|
354 |
symbolic name descriptor line for the problem instance, objective
|
alpar@1
|
355 |
function, each row (constraint), and each column (variable). This line
|
alpar@1
|
356 |
has one of the following formats:
|
alpar@1
|
357 |
|
alpar@1
|
358 |
\begin{verbatim}
|
alpar@1
|
359 |
n p NAME
|
alpar@1
|
360 |
n z NAME
|
alpar@1
|
361 |
n i ROW NAME
|
alpar@1
|
362 |
n j COL NAME
|
alpar@1
|
363 |
\end{verbatim}
|
alpar@1
|
364 |
|
alpar@1
|
365 |
The lower-case letter \verb|n| specifies that this is the symbolic name
|
alpar@1
|
366 |
descriptor line.
|
alpar@1
|
367 |
|
alpar@1
|
368 |
The next lower-case letter specifies which object should be assigned a
|
alpar@1
|
369 |
symbolic name:
|
alpar@1
|
370 |
|
alpar@1
|
371 |
\verb|p| --- problem instance;
|
alpar@1
|
372 |
|
alpar@1
|
373 |
\verb|z| --- objective function;
|
alpar@1
|
374 |
|
alpar@1
|
375 |
\verb|i| --- row (constraint);
|
alpar@1
|
376 |
|
alpar@1
|
377 |
\verb|j| --- column (variable).
|
alpar@1
|
378 |
|
alpar@1
|
379 |
The \verb|ROW| field specifies the row ordinal number, an integer
|
alpar@1
|
380 |
between 1 and $m$, where $m$ is the number of rows in the problem
|
alpar@1
|
381 |
instance.
|
alpar@1
|
382 |
|
alpar@1
|
383 |
The \verb|COL| field specifies the column ordinal number, an integer
|
alpar@1
|
384 |
between 1 and $n$, where $n$ is the number of columns in the problem
|
alpar@1
|
385 |
instance.
|
alpar@1
|
386 |
|
alpar@1
|
387 |
The \verb|NAME| field contains the symbolic name, a sequence from 1 to
|
alpar@1
|
388 |
255 arbitrary graphic ASCII characters, assigned to corresponding
|
alpar@1
|
389 |
object.
|
alpar@1
|
390 |
|
alpar@1
|
391 |
\paragraph{End line.} There must be exactly one end line in the data
|
alpar@1
|
392 |
file. This line must appear last in the file and has the following
|
alpar@1
|
393 |
format:
|
alpar@1
|
394 |
|
alpar@1
|
395 |
\begin{verbatim}
|
alpar@1
|
396 |
e
|
alpar@1
|
397 |
\end{verbatim}
|
alpar@1
|
398 |
|
alpar@1
|
399 |
The lower-case letter \verb|e| specifies that this is the end line.
|
alpar@1
|
400 |
Anything that follows the end line is ignored by GLPK routines.
|
alpar@1
|
401 |
|
alpar@1
|
402 |
\subsubsection*{Example of data file in GLPK LP/MIP format}
|
alpar@1
|
403 |
|
alpar@1
|
404 |
The following example of a data file in GLPK LP/MIP format specifies
|
alpar@1
|
405 |
the same LP problem as in Subsection ``Example of MPS file''.
|
alpar@1
|
406 |
|
alpar@1
|
407 |
\begin{center}
|
alpar@1
|
408 |
\footnotesize\tt
|
alpar@1
|
409 |
\begin{tabular}{l@{\hspace*{50pt}}}
|
alpar@1
|
410 |
p lp min 8 7 48 \\
|
alpar@1
|
411 |
n p PLAN \\
|
alpar@1
|
412 |
n z VALUE \\
|
alpar@1
|
413 |
i 1 f \\
|
alpar@1
|
414 |
n i 1 VALUE \\
|
alpar@1
|
415 |
i 2 s 2000 \\
|
alpar@1
|
416 |
n i 2 YIELD \\
|
alpar@1
|
417 |
i 3 u 60 \\
|
alpar@1
|
418 |
n i 3 FE \\
|
alpar@1
|
419 |
i 4 u 100 \\
|
alpar@1
|
420 |
n i 4 CU \\
|
alpar@1
|
421 |
i 5 u 40 \\
|
alpar@1
|
422 |
n i 5 MN \\
|
alpar@1
|
423 |
i 6 u 30 \\
|
alpar@1
|
424 |
n i 6 MG \\
|
alpar@1
|
425 |
i 7 l 1500 \\
|
alpar@1
|
426 |
n i 7 AL \\
|
alpar@1
|
427 |
i 8 d 250 300 \\
|
alpar@1
|
428 |
n i 8 SI \\
|
alpar@1
|
429 |
j 1 d 0 200 \\
|
alpar@1
|
430 |
n j 1 BIN1 \\
|
alpar@1
|
431 |
j 2 d 0 2500 \\
|
alpar@1
|
432 |
n j 2 BIN2 \\
|
alpar@1
|
433 |
j 3 d 400 800 \\
|
alpar@1
|
434 |
n j 3 BIN3 \\
|
alpar@1
|
435 |
j 4 d 100 700 \\
|
alpar@1
|
436 |
n j 4 BIN4 \\
|
alpar@1
|
437 |
j 5 d 0 1500 \\
|
alpar@1
|
438 |
n j 5 BIN5 \\
|
alpar@1
|
439 |
n j 6 ALUM \\
|
alpar@1
|
440 |
n j 7 SILICON \\
|
alpar@1
|
441 |
a 0 1 0.03 \\
|
alpar@1
|
442 |
a 0 2 0.08 \\
|
alpar@1
|
443 |
a 0 3 0.17 \\
|
alpar@1
|
444 |
a 0 4 0.12 \\
|
alpar@1
|
445 |
a 0 5 0.15 \\
|
alpar@1
|
446 |
a 0 6 0.21 \\
|
alpar@1
|
447 |
a 0 7 0.38 \\
|
alpar@1
|
448 |
a 1 1 0.03 \\
|
alpar@1
|
449 |
a 1 2 0.08 \\
|
alpar@1
|
450 |
a 1 3 0.17 \\
|
alpar@1
|
451 |
a 1 4 0.12 \\
|
alpar@1
|
452 |
a 1 5 0.15 \\
|
alpar@1
|
453 |
a 1 6 0.21 \\
|
alpar@1
|
454 |
\end{tabular}
|
alpar@1
|
455 |
\begin{tabular}{|@{\hspace*{80pt}}l}
|
alpar@1
|
456 |
a 1 7 0.38 \\
|
alpar@1
|
457 |
a 2 1 1 \\
|
alpar@1
|
458 |
a 2 2 1 \\
|
alpar@1
|
459 |
a 2 3 1 \\
|
alpar@1
|
460 |
a 2 4 1 \\
|
alpar@1
|
461 |
a 2 5 1 \\
|
alpar@1
|
462 |
a 2 6 1 \\
|
alpar@1
|
463 |
a 2 7 1 \\
|
alpar@1
|
464 |
a 3 1 0.15 \\
|
alpar@1
|
465 |
a 3 2 0.04 \\
|
alpar@1
|
466 |
a 3 3 0.02 \\
|
alpar@1
|
467 |
a 3 4 0.04 \\
|
alpar@1
|
468 |
a 3 5 0.02 \\
|
alpar@1
|
469 |
a 3 6 0.01 \\
|
alpar@1
|
470 |
a 3 7 0.03 \\
|
alpar@1
|
471 |
a 4 1 0.03 \\
|
alpar@1
|
472 |
a 4 2 0.05 \\
|
alpar@1
|
473 |
a 4 3 0.08 \\
|
alpar@1
|
474 |
a 4 4 0.02 \\
|
alpar@1
|
475 |
a 4 5 0.06 \\
|
alpar@1
|
476 |
a 4 6 0.01 \\
|
alpar@1
|
477 |
a 5 1 0.02 \\
|
alpar@1
|
478 |
a 5 2 0.04 \\
|
alpar@1
|
479 |
a 5 3 0.01 \\
|
alpar@1
|
480 |
a 5 4 0.02 \\
|
alpar@1
|
481 |
a 5 5 0.02 \\
|
alpar@1
|
482 |
a 6 1 0.02 \\
|
alpar@1
|
483 |
a 6 2 0.03 \\
|
alpar@1
|
484 |
a 6 5 0.01 \\
|
alpar@1
|
485 |
a 7 1 0.7 \\
|
alpar@1
|
486 |
a 7 2 0.75 \\
|
alpar@1
|
487 |
a 7 3 0.8 \\
|
alpar@1
|
488 |
a 7 4 0.75 \\
|
alpar@1
|
489 |
a 7 5 0.8 \\
|
alpar@1
|
490 |
a 7 6 0.97 \\
|
alpar@1
|
491 |
a 8 1 0.02 \\
|
alpar@1
|
492 |
a 8 2 0.06 \\
|
alpar@1
|
493 |
a 8 3 0.08 \\
|
alpar@1
|
494 |
a 8 4 0.12 \\
|
alpar@1
|
495 |
a 8 5 0.02 \\
|
alpar@1
|
496 |
a 8 6 0.01 \\
|
alpar@1
|
497 |
a 8 7 0.97 \\
|
alpar@1
|
498 |
e o f \\
|
alpar@1
|
499 |
\\
|
alpar@1
|
500 |
\end{tabular}
|
alpar@1
|
501 |
\end{center}
|
alpar@1
|
502 |
|
alpar@1
|
503 |
\newpage
|
alpar@1
|
504 |
|
alpar@1
|
505 |
\subsection{glp\_write\_prob---write problem data in GLPK format}
|
alpar@1
|
506 |
|
alpar@1
|
507 |
\subsubsection*{Synopsis}
|
alpar@1
|
508 |
|
alpar@1
|
509 |
\begin{verbatim}
|
alpar@1
|
510 |
int glp_write_prob(glp_prob *P, int flags, const char *fname);
|
alpar@1
|
511 |
\end{verbatim}
|
alpar@1
|
512 |
|
alpar@1
|
513 |
\subsubsection*{Description}
|
alpar@1
|
514 |
|
alpar@1
|
515 |
The routine \verb|glp_write_prob| writes problem data in the GLPK
|
alpar@1
|
516 |
LP/MIP format to a text file. (For description of the GLPK LP/MIP
|
alpar@1
|
517 |
format see Subsection ``Read problem data in GLPK format''.)
|
alpar@1
|
518 |
|
alpar@1
|
519 |
The parameter \verb|flags| is reserved for use in the future and should
|
alpar@1
|
520 |
be specified as zero.
|
alpar@1
|
521 |
|
alpar@1
|
522 |
The character string \verb|fname| specifies a name of the text file to
|
alpar@1
|
523 |
be written out. (If the file name ends with suffix `\verb|.gz|', the
|
alpar@1
|
524 |
file is assumed to be compressed, in which case the routine
|
alpar@1
|
525 |
\verb|glp_write_prob| performs automatic compression on writing it.)
|
alpar@1
|
526 |
|
alpar@1
|
527 |
\subsubsection*{Returns}
|
alpar@1
|
528 |
|
alpar@1
|
529 |
If the operation was successful, the routine \verb|glp_read_prob|
|
alpar@1
|
530 |
returns zero. Otherwise, it prints an error message and returns
|
alpar@1
|
531 |
non-zero.
|
alpar@1
|
532 |
|
alpar@1
|
533 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
alpar@1
|
534 |
|
alpar@1
|
535 |
\newpage
|
alpar@1
|
536 |
|
alpar@1
|
537 |
\section{Routines for processing MathProg models}
|
alpar@1
|
538 |
|
alpar@1
|
539 |
\subsection{Introduction}
|
alpar@1
|
540 |
|
alpar@1
|
541 |
GLPK supports the {\it GNU MathProg modeling language}.\footnote{The
|
alpar@1
|
542 |
GNU MathProg modeling language is a subset of the AMPL language. For
|
alpar@1
|
543 |
its detailed description see the document ``Modeling Language GNU
|
alpar@1
|
544 |
MathProg: Language Reference'' included in the GLPK distribution.}
|
alpar@1
|
545 |
As a rule, models written in MathProg are solved with the GLPK LP/MIP
|
alpar@1
|
546 |
stand-alone solver \verb|glpsol| (see Appendix D) and do not need any
|
alpar@1
|
547 |
programming with API routines. However, for various reasons the user
|
alpar@1
|
548 |
may need to process MathProg models directly in his/her application
|
alpar@1
|
549 |
program, in which case he/she may use API routines described in this
|
alpar@1
|
550 |
section. These routines provide an interface to the {\it MathProg
|
alpar@1
|
551 |
translator}, a component of GLPK, which translates MathProg models into
|
alpar@1
|
552 |
an internal code and then interprets (executes) this code.
|
alpar@1
|
553 |
|
alpar@1
|
554 |
The processing of a model written in GNU MathProg includes several
|
alpar@1
|
555 |
steps, which should be performed in the following order:
|
alpar@1
|
556 |
|
alpar@1
|
557 |
\begin{enumerate}
|
alpar@1
|
558 |
\item{\it Allocating the workspace.}
|
alpar@1
|
559 |
The translator allocates the workspace, an internal data structure used
|
alpar@1
|
560 |
on all subsequent steps.
|
alpar@1
|
561 |
\item{\it Reading model section.} The translator reads model section
|
alpar@1
|
562 |
and, optionally, data section from a specified text file and translates
|
alpar@1
|
563 |
them into the internal code. If necessary, on this step data section
|
alpar@1
|
564 |
may be ignored.
|
alpar@1
|
565 |
\item{\it Reading data section(s).} The translator reads one or more
|
alpar@1
|
566 |
data sections from specified text file(s) and translates them into the
|
alpar@1
|
567 |
internal code.
|
alpar@1
|
568 |
\item{\it Generating the model.} The translator executes the internal
|
alpar@1
|
569 |
code to evaluate the content of the model objects such as sets,
|
alpar@1
|
570 |
parameters, variables, constraints, and objectives. On this step the
|
alpar@1
|
571 |
execution is suspended at the solve statement.
|
alpar@1
|
572 |
\item {\it Building the problem object.} The translator obtains all
|
alpar@1
|
573 |
necessary information from the workspace and builds the standard
|
alpar@1
|
574 |
problem object (that is, the program object of type \verb|glp_prob|).
|
alpar@1
|
575 |
\item{\it Solving the problem.} On this step the problem object built
|
alpar@1
|
576 |
on the previous step is passed to a solver, which solves the problem
|
alpar@1
|
577 |
instance and stores its solution back to the problem object.
|
alpar@1
|
578 |
\item{\it Postsolving the model.} The translator copies the solution
|
alpar@1
|
579 |
from the problem object to the workspace and then executes the internal
|
alpar@1
|
580 |
code from the solve statement to the end of the model. (If model has
|
alpar@1
|
581 |
no solve statement, the translator does nothing on this step.)
|
alpar@1
|
582 |
\item{\it Freeing the workspace.} The translator frees all the memory
|
alpar@1
|
583 |
allocated to the workspace.
|
alpar@1
|
584 |
\end{enumerate}
|
alpar@1
|
585 |
|
alpar@1
|
586 |
Note that the MathProg translator performs no error correction, so if
|
alpar@1
|
587 |
any of steps 2 to 7 fails (due to errors in the model), the application
|
alpar@1
|
588 |
program should terminate processing and go to step 8.
|
alpar@1
|
589 |
|
alpar@1
|
590 |
\subsubsection*{Example 1}
|
alpar@1
|
591 |
|
alpar@1
|
592 |
In this example the program reads model and data sections from input
|
alpar@1
|
593 |
file \verb|egypt.mod|\footnote{This is an example model included in
|
alpar@1
|
594 |
the GLPK distribution.} and writes the model to output file
|
alpar@1
|
595 |
\verb|egypt.mps| in free MPS format (see Appendix B). No solution is
|
alpar@1
|
596 |
performed.
|
alpar@1
|
597 |
|
alpar@1
|
598 |
\begin{small}
|
alpar@1
|
599 |
\begin{verbatim}
|
alpar@1
|
600 |
/* mplsamp1.c */
|
alpar@1
|
601 |
|
alpar@1
|
602 |
#include <stdio.h>
|
alpar@1
|
603 |
#include <stdlib.h>
|
alpar@1
|
604 |
#include <glpk.h>
|
alpar@1
|
605 |
|
alpar@1
|
606 |
int main(void)
|
alpar@1
|
607 |
{ glp_prob *lp;
|
alpar@1
|
608 |
glp_tran *tran;
|
alpar@1
|
609 |
int ret;
|
alpar@1
|
610 |
lp = glp_create_prob();
|
alpar@1
|
611 |
tran = glp_mpl_alloc_wksp();
|
alpar@1
|
612 |
ret = glp_mpl_read_model(tran, "egypt.mod", 0);
|
alpar@1
|
613 |
if (ret != 0)
|
alpar@1
|
614 |
{ fprintf(stderr, "Error on translating model\n");
|
alpar@1
|
615 |
goto skip;
|
alpar@1
|
616 |
}
|
alpar@1
|
617 |
ret = glp_mpl_generate(tran, NULL);
|
alpar@1
|
618 |
if (ret != 0)
|
alpar@1
|
619 |
{ fprintf(stderr, "Error on generating model\n");
|
alpar@1
|
620 |
goto skip;
|
alpar@1
|
621 |
}
|
alpar@1
|
622 |
glp_mpl_build_prob(tran, lp);
|
alpar@1
|
623 |
ret = glp_write_mps(lp, GLP_MPS_FILE, NULL, "egypt.mps");
|
alpar@1
|
624 |
if (ret != 0)
|
alpar@1
|
625 |
fprintf(stderr, "Error on writing MPS file\n");
|
alpar@1
|
626 |
skip: glp_mpl_free_wksp(tran);
|
alpar@1
|
627 |
glp_delete_prob(lp);
|
alpar@1
|
628 |
return 0;
|
alpar@1
|
629 |
}
|
alpar@1
|
630 |
|
alpar@1
|
631 |
/* eof */
|
alpar@1
|
632 |
\end{verbatim}
|
alpar@1
|
633 |
\end{small}
|
alpar@1
|
634 |
|
alpar@1
|
635 |
\subsubsection*{Example 2}
|
alpar@1
|
636 |
|
alpar@1
|
637 |
In this example the program reads model section from file
|
alpar@1
|
638 |
\verb|sudoku.mod|\footnote{This is an example model which is included
|
alpar@1
|
639 |
in the GLPK distribution along with alternative data file
|
alpar@1
|
640 |
{\tt sudoku.dat}.} ignoring data section in this file, reads alternative
|
alpar@1
|
641 |
data section from file \verb|sudoku.dat|, solves the problem instance
|
alpar@1
|
642 |
and passes the solution found back to the model.
|
alpar@1
|
643 |
|
alpar@1
|
644 |
\begin{small}
|
alpar@1
|
645 |
\begin{verbatim}
|
alpar@1
|
646 |
/* mplsamp2.c */
|
alpar@1
|
647 |
|
alpar@1
|
648 |
#include <stdio.h>
|
alpar@1
|
649 |
#include <stdlib.h>
|
alpar@1
|
650 |
#include <glpk.h>
|
alpar@1
|
651 |
|
alpar@1
|
652 |
int main(void)
|
alpar@1
|
653 |
{ glp_prob *mip;
|
alpar@1
|
654 |
glp_tran *tran;
|
alpar@1
|
655 |
int ret;
|
alpar@1
|
656 |
mip = glp_create_prob();
|
alpar@1
|
657 |
tran = glp_mpl_alloc_wksp();
|
alpar@1
|
658 |
ret = glp_mpl_read_model(tran, "sudoku.mod", 1);
|
alpar@1
|
659 |
if (ret != 0)
|
alpar@1
|
660 |
{ fprintf(stderr, "Error on translating model\n");
|
alpar@1
|
661 |
goto skip;
|
alpar@1
|
662 |
}
|
alpar@1
|
663 |
ret = glp_mpl_read_data(tran, "sudoku.dat");
|
alpar@1
|
664 |
if (ret != 0)
|
alpar@1
|
665 |
{ fprintf(stderr, "Error on translating data\n");
|
alpar@1
|
666 |
goto skip;
|
alpar@1
|
667 |
}
|
alpar@1
|
668 |
ret = glp_mpl_generate(tran, NULL);
|
alpar@1
|
669 |
if (ret != 0)
|
alpar@1
|
670 |
{ fprintf(stderr, "Error on generating model\n");
|
alpar@1
|
671 |
goto skip;
|
alpar@1
|
672 |
}
|
alpar@1
|
673 |
glp_mpl_build_prob(tran, mip);
|
alpar@1
|
674 |
glp_simplex(mip, NULL);
|
alpar@1
|
675 |
glp_intopt(mip, NULL);
|
alpar@1
|
676 |
ret = glp_mpl_postsolve(tran, mip, GLP_MIP);
|
alpar@1
|
677 |
if (ret != 0)
|
alpar@1
|
678 |
fprintf(stderr, "Error on postsolving model\n");
|
alpar@1
|
679 |
skip: glp_mpl_free_wksp(tran);
|
alpar@1
|
680 |
glp_delete_prob(mip);
|
alpar@1
|
681 |
return 0;
|
alpar@1
|
682 |
}
|
alpar@1
|
683 |
|
alpar@1
|
684 |
/* eof */
|
alpar@1
|
685 |
\end{verbatim}
|
alpar@1
|
686 |
\end{small}
|
alpar@1
|
687 |
|
alpar@1
|
688 |
\subsection{glp\_mpl\_alloc\_wksp---allocate the translator workspace}
|
alpar@1
|
689 |
|
alpar@1
|
690 |
\subsubsection*{Synopsis}
|
alpar@1
|
691 |
|
alpar@1
|
692 |
\begin{verbatim}
|
alpar@1
|
693 |
glp_tran *glp_mpl_alloc_wksp(void);
|
alpar@1
|
694 |
\end{verbatim}
|
alpar@1
|
695 |
|
alpar@1
|
696 |
\subsubsection*{Description}
|
alpar@1
|
697 |
|
alpar@1
|
698 |
The routine \verb|glp_mpl_alloc_wksp| allocates the MathProg translator
|
alpar@1
|
699 |
work\-space. (Note that multiple instances of the workspace may be
|
alpar@1
|
700 |
allocated, if necessary.)
|
alpar@1
|
701 |
|
alpar@1
|
702 |
\subsubsection*{Returns}
|
alpar@1
|
703 |
|
alpar@1
|
704 |
The routine returns a pointer to the workspace, which should be used in
|
alpar@1
|
705 |
all subsequent operations.
|
alpar@1
|
706 |
|
alpar@1
|
707 |
\subsection{glp\_mpl\_read\_model---read and translate model section}
|
alpar@1
|
708 |
|
alpar@1
|
709 |
\subsubsection*{Synopsis}
|
alpar@1
|
710 |
|
alpar@1
|
711 |
\begin{verbatim}
|
alpar@1
|
712 |
int glp_mpl_read_model(glp_tran *tran, const char *fname,
|
alpar@1
|
713 |
int skip);
|
alpar@1
|
714 |
\end{verbatim}
|
alpar@1
|
715 |
|
alpar@1
|
716 |
\subsubsection*{Description}
|
alpar@1
|
717 |
|
alpar@1
|
718 |
The routine \verb|glp_mpl_read_model| reads model section and,
|
alpar@1
|
719 |
optionally, data section, which may follow the model section, from a
|
alpar@1
|
720 |
text file, whose name is the character string \verb|fname|, performs
|
alpar@1
|
721 |
translation of model statements and data blocks, and stores all the
|
alpar@1
|
722 |
information in the workspace.
|
alpar@1
|
723 |
|
alpar@1
|
724 |
The parameter \verb|skip| is a flag. If the input file contains the
|
alpar@1
|
725 |
data section and this flag is non-zero, the data section is not read as
|
alpar@1
|
726 |
if there were no data section and a warning message is printed. This
|
alpar@1
|
727 |
allows reading data section(s) from other file(s).
|
alpar@1
|
728 |
|
alpar@1
|
729 |
\subsubsection*{Returns}
|
alpar@1
|
730 |
|
alpar@1
|
731 |
If the operation is successful, the routine returns zero. Otherwise
|
alpar@1
|
732 |
the routine prints an error message and returns non-zero.
|
alpar@1
|
733 |
|
alpar@1
|
734 |
\subsection{glp\_mpl\_read\_data---read and translate data section}
|
alpar@1
|
735 |
|
alpar@1
|
736 |
\subsubsection*{Synopsis}
|
alpar@1
|
737 |
|
alpar@1
|
738 |
\begin{verbatim}
|
alpar@1
|
739 |
int glp_mpl_read_data(glp_tran *tran, const char *fname);
|
alpar@1
|
740 |
\end{verbatim}
|
alpar@1
|
741 |
|
alpar@1
|
742 |
\subsubsection*{Description}
|
alpar@1
|
743 |
|
alpar@1
|
744 |
The routine \verb|glp_mpl_read_data| reads data section from a text
|
alpar@1
|
745 |
file, whose name is the character string \verb|fname|, performs
|
alpar@1
|
746 |
translation of data blocks, and stores the data read in the translator
|
alpar@1
|
747 |
workspace. If necessary, this routine may be called more than once.
|
alpar@1
|
748 |
|
alpar@1
|
749 |
\subsubsection*{Returns}
|
alpar@1
|
750 |
|
alpar@1
|
751 |
If the operation is successful, the routine returns zero. Otherwise
|
alpar@1
|
752 |
the routine prints an error message and returns non-zero.
|
alpar@1
|
753 |
|
alpar@1
|
754 |
\subsection{glp\_mpl\_generate---generate the model}
|
alpar@1
|
755 |
|
alpar@1
|
756 |
\subsubsection*{Synopsis}
|
alpar@1
|
757 |
|
alpar@1
|
758 |
\begin{verbatim}
|
alpar@1
|
759 |
int glp_mpl_generate(glp_tran *tran, const char *fname);
|
alpar@1
|
760 |
\end{verbatim}
|
alpar@1
|
761 |
|
alpar@1
|
762 |
\subsubsection*{Description}
|
alpar@1
|
763 |
|
alpar@1
|
764 |
The routine \verb|glp_mpl_generate| generates the model using its
|
alpar@1
|
765 |
description stored in the translator workspace. This operation means
|
alpar@1
|
766 |
generating all variables, constraints, and objectives, executing check
|
alpar@1
|
767 |
and display statements, which precede the solve statement (if it is
|
alpar@1
|
768 |
presented).
|
alpar@1
|
769 |
|
alpar@1
|
770 |
The character string \verb|fname| specifies the name of an output text
|
alpar@1
|
771 |
file, to which output produced by display statements should be written.
|
alpar@1
|
772 |
If \verb|fname| is \verb|NULL|, the output is sent to the terminal.
|
alpar@1
|
773 |
|
alpar@1
|
774 |
\subsubsection*{Returns}
|
alpar@1
|
775 |
|
alpar@1
|
776 |
If the operation is successful, the routine returns zero. Otherwise
|
alpar@1
|
777 |
the routine prints an error message and returns non-zero.
|
alpar@1
|
778 |
|
alpar@1
|
779 |
\subsection{glp\_mpl\_build\_prob---build problem instance from the
|
alpar@1
|
780 |
model}
|
alpar@1
|
781 |
|
alpar@1
|
782 |
\subsubsection*{Synopsis}
|
alpar@1
|
783 |
|
alpar@1
|
784 |
\begin{verbatim}
|
alpar@1
|
785 |
void glp_mpl_build_prob(glp_tran *tran, glp_prob *prob);
|
alpar@1
|
786 |
\end{verbatim}
|
alpar@1
|
787 |
|
alpar@1
|
788 |
\subsubsection*{Description}
|
alpar@1
|
789 |
|
alpar@1
|
790 |
The routine \verb|glp_mpl_build_prob| obtains all necessary information
|
alpar@1
|
791 |
from the translator workspace and stores it in the specified problem
|
alpar@1
|
792 |
object \verb|prob|. Note that before building the current content of
|
alpar@1
|
793 |
the problem object is erased with the routine \verb|glp_erase_prob|.
|
alpar@1
|
794 |
|
alpar@1
|
795 |
\subsection{glp\_mpl\_postsolve---postsolve the model}
|
alpar@1
|
796 |
|
alpar@1
|
797 |
\subsubsection*{Synopsis}
|
alpar@1
|
798 |
|
alpar@1
|
799 |
\begin{verbatim}
|
alpar@1
|
800 |
int glp_mpl_postsolve(glp_tran *tran, glp_prob *prob,
|
alpar@1
|
801 |
int sol);
|
alpar@1
|
802 |
\end{verbatim}
|
alpar@1
|
803 |
|
alpar@1
|
804 |
\subsubsection*{Description}
|
alpar@1
|
805 |
|
alpar@1
|
806 |
The routine \verb|glp_mpl_postsolve| copies the solution from the
|
alpar@1
|
807 |
specified problem object \verb|prob| to the translator workspace and
|
alpar@1
|
808 |
then executes all the remaining model statements, which follow the
|
alpar@1
|
809 |
solve statement.
|
alpar@1
|
810 |
|
alpar@1
|
811 |
The parameter \verb|sol| specifies which solution should be copied
|
alpar@1
|
812 |
from the problem object to the workspace as follows:
|
alpar@1
|
813 |
|
alpar@1
|
814 |
\begin{tabular}{@{}ll}
|
alpar@1
|
815 |
\verb|GLP_SOL| & basic solution; \\
|
alpar@1
|
816 |
\verb|GLP_IPT| & interior-point solution; \\
|
alpar@1
|
817 |
\verb|GLP_MIP| & mixed integer solution. \\
|
alpar@1
|
818 |
\end{tabular}
|
alpar@1
|
819 |
|
alpar@1
|
820 |
\subsubsection*{Returns}
|
alpar@1
|
821 |
|
alpar@1
|
822 |
If the operation is successful, the routine returns zero. Otherwise
|
alpar@1
|
823 |
the routine prints an error message and returns non-zero.
|
alpar@1
|
824 |
|
alpar@1
|
825 |
\subsection{glp\_mpl\_free\_wksp---free the translator workspace}
|
alpar@1
|
826 |
|
alpar@1
|
827 |
\subsubsection*{Synopsis}
|
alpar@1
|
828 |
|
alpar@1
|
829 |
\begin{verbatim}
|
alpar@1
|
830 |
void glp_mpl_free_wksp(glp_tran *tran);
|
alpar@1
|
831 |
\end{verbatim}
|
alpar@1
|
832 |
|
alpar@1
|
833 |
\subsubsection*{Description}
|
alpar@1
|
834 |
|
alpar@1
|
835 |
The routine \verb|glp_mpl_free_wksp| frees all the memory allocated to
|
alpar@1
|
836 |
the translator workspace. It also frees all other resources, which are
|
alpar@1
|
837 |
still used by the translator.
|
alpar@1
|
838 |
|
alpar@1
|
839 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
alpar@1
|
840 |
|
alpar@1
|
841 |
\newpage
|
alpar@1
|
842 |
|
alpar@1
|
843 |
\section{Problem solution reading/writing routines}
|
alpar@1
|
844 |
|
alpar@1
|
845 |
\subsection{glp\_print\_sol---write basic solution in printable format}
|
alpar@1
|
846 |
|
alpar@1
|
847 |
\subsubsection*{Synopsis}
|
alpar@1
|
848 |
|
alpar@1
|
849 |
\begin{verbatim}
|
alpar@1
|
850 |
int glp_print_sol(glp_prob *lp, const char *fname);
|
alpar@1
|
851 |
\end{verbatim}
|
alpar@1
|
852 |
|
alpar@1
|
853 |
\subsubsection*{Description}
|
alpar@1
|
854 |
|
alpar@1
|
855 |
The routine \verb|glp_print_sol writes| the current basic solution of
|
alpar@1
|
856 |
an LP problem, which is specified by the pointer \verb|lp|, to a text
|
alpar@1
|
857 |
file, whose name is the character string \verb|fname|, in printable
|
alpar@1
|
858 |
format.
|
alpar@1
|
859 |
|
alpar@1
|
860 |
Information reported by the routine \verb|glp_print_sol| is intended
|
alpar@1
|
861 |
mainly for visual analysis.
|
alpar@1
|
862 |
|
alpar@1
|
863 |
\subsubsection*{Returns}
|
alpar@1
|
864 |
|
alpar@1
|
865 |
If no errors occurred, the routine returns zero. Otherwise the routine
|
alpar@1
|
866 |
prints an error message and returns non-zero.
|
alpar@1
|
867 |
|
alpar@1
|
868 |
\subsection{glp\_read\_sol---read basic solution from text file}
|
alpar@1
|
869 |
|
alpar@1
|
870 |
\subsubsection*{Synopsis}
|
alpar@1
|
871 |
|
alpar@1
|
872 |
\begin{verbatim}
|
alpar@1
|
873 |
int glp_read_sol(glp_prob *lp, const char *fname);
|
alpar@1
|
874 |
\end{verbatim}
|
alpar@1
|
875 |
|
alpar@1
|
876 |
\subsubsection*{Description}
|
alpar@1
|
877 |
|
alpar@1
|
878 |
The routine \verb|glp_read_sol| reads basic solution from a text file
|
alpar@1
|
879 |
whose name is specified by the parameter \verb|fname| into the problem
|
alpar@1
|
880 |
object.
|
alpar@1
|
881 |
|
alpar@1
|
882 |
For the file format see description of the routine \verb|glp_write_sol|.
|
alpar@1
|
883 |
|
alpar@1
|
884 |
\subsubsection*{Returns}
|
alpar@1
|
885 |
|
alpar@1
|
886 |
On success the routine returns zero, otherwise non-zero.
|
alpar@1
|
887 |
|
alpar@1
|
888 |
\newpage
|
alpar@1
|
889 |
|
alpar@1
|
890 |
\subsection{glp\_write\_sol---write basic solution to text file}
|
alpar@1
|
891 |
|
alpar@1
|
892 |
\subsubsection*{Synopsis}
|
alpar@1
|
893 |
|
alpar@1
|
894 |
\begin{verbatim}
|
alpar@1
|
895 |
int glp_write_sol(glp_prob *lp, const char *fname);
|
alpar@1
|
896 |
\end{verbatim}
|
alpar@1
|
897 |
|
alpar@1
|
898 |
\subsubsection*{Description}
|
alpar@1
|
899 |
|
alpar@1
|
900 |
The routine \verb|glp_write_sol| writes the current basic solution to a
|
alpar@1
|
901 |
text file whose name is specified by the parameter \verb|fname|. This
|
alpar@1
|
902 |
file can be read back with the routine \verb|glp_read_sol|.
|
alpar@1
|
903 |
|
alpar@1
|
904 |
\subsubsection*{Returns}
|
alpar@1
|
905 |
|
alpar@1
|
906 |
On success the routine returns zero, otherwise non-zero.
|
alpar@1
|
907 |
|
alpar@1
|
908 |
\subsubsection*{File format}
|
alpar@1
|
909 |
|
alpar@1
|
910 |
The file created by the routine \verb|glp_write_sol| is a plain text
|
alpar@1
|
911 |
file, which contains the following information:
|
alpar@1
|
912 |
|
alpar@1
|
913 |
\begin{verbatim}
|
alpar@1
|
914 |
m n
|
alpar@1
|
915 |
p_stat d_stat obj_val
|
alpar@1
|
916 |
r_stat[1] r_prim[1] r_dual[1]
|
alpar@1
|
917 |
. . .
|
alpar@1
|
918 |
r_stat[m] r_prim[m] r_dual[m]
|
alpar@1
|
919 |
c_stat[1] c_prim[1] c_dual[1]
|
alpar@1
|
920 |
. . .
|
alpar@1
|
921 |
c_stat[n] c_prim[n] c_dual[n]
|
alpar@1
|
922 |
\end{verbatim}
|
alpar@1
|
923 |
|
alpar@1
|
924 |
\noindent
|
alpar@1
|
925 |
where:
|
alpar@1
|
926 |
|
alpar@1
|
927 |
\noindent
|
alpar@1
|
928 |
$m$ is the number of rows (auxiliary variables);
|
alpar@1
|
929 |
|
alpar@1
|
930 |
\noindent
|
alpar@1
|
931 |
$n$ is the number of columns (structural variables);
|
alpar@1
|
932 |
|
alpar@1
|
933 |
\noindent
|
alpar@1
|
934 |
\verb|p_stat| is the primal status of the basic solution
|
alpar@1
|
935 |
(\verb|GLP_UNDEF| = 1, \verb|GLP_FEAS| = 2, \verb|GLP_INFEAS| = 3, or
|
alpar@1
|
936 |
\verb|GLP_NOFEAS| = 4);
|
alpar@1
|
937 |
|
alpar@1
|
938 |
\noindent
|
alpar@1
|
939 |
\verb|d_stat| is the dual status of the basic solution
|
alpar@1
|
940 |
(\verb|GLP_UNDEF| = 1, \verb|GLP_FEAS| = 2, \verb|GLP_INFEAS| = 3, or
|
alpar@1
|
941 |
\verb|GLP_NOFEAS| = 4);
|
alpar@1
|
942 |
|
alpar@1
|
943 |
\noindent
|
alpar@1
|
944 |
\verb|obj_val| is the objective value;
|
alpar@1
|
945 |
|
alpar@1
|
946 |
\noindent
|
alpar@1
|
947 |
\verb|r_stat[i]|, $i=1,\dots,m$, is the status of $i$-th row
|
alpar@1
|
948 |
(\verb|GLP_BS| = 1, \verb|GLP_NL| = 2, \verb|GLP_NU| = 3,
|
alpar@1
|
949 |
\verb|GLP_NF| = 4, or \verb|GLP_NS| = 5);
|
alpar@1
|
950 |
|
alpar@1
|
951 |
\noindent
|
alpar@1
|
952 |
\verb|r_prim[i]|, $i=1,\dots,m$, is the primal value of $i$-th row;
|
alpar@1
|
953 |
|
alpar@1
|
954 |
\noindent
|
alpar@1
|
955 |
\verb|r_dual[i]|, $i=1,\dots,m$, is the dual value of $i$-th row;
|
alpar@1
|
956 |
|
alpar@1
|
957 |
\noindent
|
alpar@1
|
958 |
\verb|c_stat[j]|, $j=1,\dots,n$, is the status of $j$-th column
|
alpar@1
|
959 |
(\verb|GLP_BS| = 1, \verb|GLP_NL| = 2, \verb|GLP_NU| = 3,
|
alpar@1
|
960 |
\verb|GLP_NF| = 4, or \verb|GLP_NS| = 5);
|
alpar@1
|
961 |
|
alpar@1
|
962 |
\noindent
|
alpar@1
|
963 |
\verb|c_prim[j]|, $j=1,\dots,n$, is the primal value of $j$-th column;
|
alpar@1
|
964 |
|
alpar@1
|
965 |
\noindent
|
alpar@1
|
966 |
\verb|c_dual[j]|, $j=1,\dots,n$, is the dual value of $j$-th column.
|
alpar@1
|
967 |
|
alpar@1
|
968 |
\subsection{glp\_print\_ipt---write interior-point solution in
|
alpar@1
|
969 |
printable format}
|
alpar@1
|
970 |
|
alpar@1
|
971 |
\subsubsection*{Synopsis}
|
alpar@1
|
972 |
|
alpar@1
|
973 |
\begin{verbatim}
|
alpar@1
|
974 |
int glp_print_ipt(glp_prob *lp, const char *fname);
|
alpar@1
|
975 |
\end{verbatim}
|
alpar@1
|
976 |
|
alpar@1
|
977 |
\subsubsection*{Description}
|
alpar@1
|
978 |
|
alpar@1
|
979 |
The routine \verb|glp_print_ipt| writes the current interior point
|
alpar@1
|
980 |
solution of an LP problem, which the parameter \verb|lp| points to, to
|
alpar@1
|
981 |
a text file, whose name is the character string \verb|fname|, in
|
alpar@1
|
982 |
printable format.
|
alpar@1
|
983 |
|
alpar@1
|
984 |
Information reported by the routine \verb|glp_print_ipt| is intended
|
alpar@1
|
985 |
mainly for visual analysis.
|
alpar@1
|
986 |
|
alpar@1
|
987 |
\subsubsection*{Returns}
|
alpar@1
|
988 |
|
alpar@1
|
989 |
If no errors occurred, the routine returns zero. Otherwise the routine
|
alpar@1
|
990 |
prints an error message and returns non-zero.
|
alpar@1
|
991 |
|
alpar@1
|
992 |
\subsection{glp\_read\_ipt---read interior-point solution from text
|
alpar@1
|
993 |
file}
|
alpar@1
|
994 |
|
alpar@1
|
995 |
\subsubsection*{Synopsis}
|
alpar@1
|
996 |
|
alpar@1
|
997 |
\begin{verbatim}
|
alpar@1
|
998 |
int glp_read_ipt(glp_prob *lp, const char *fname);
|
alpar@1
|
999 |
\end{verbatim}
|
alpar@1
|
1000 |
|
alpar@1
|
1001 |
\subsubsection*{Description}
|
alpar@1
|
1002 |
|
alpar@1
|
1003 |
The routine \verb|glp_read_ipt| reads interior-point solution from a
|
alpar@1
|
1004 |
text file whose name is specified by the parameter \verb|fname| into the
|
alpar@1
|
1005 |
problem object.
|
alpar@1
|
1006 |
|
alpar@1
|
1007 |
For the file format see description of the routine \verb|glp_write_ipt|.
|
alpar@1
|
1008 |
|
alpar@1
|
1009 |
\subsubsection*{Returns}
|
alpar@1
|
1010 |
|
alpar@1
|
1011 |
On success the routine returns zero, otherwise non-zero.
|
alpar@1
|
1012 |
|
alpar@1
|
1013 |
\subsection{glp\_write\_ipt---write interior-point solution to text
|
alpar@1
|
1014 |
file}
|
alpar@1
|
1015 |
|
alpar@1
|
1016 |
\subsubsection*{Synopsis}
|
alpar@1
|
1017 |
|
alpar@1
|
1018 |
\begin{verbatim}
|
alpar@1
|
1019 |
int glp_write_ipt(glp_prob *lp, const char *fname);
|
alpar@1
|
1020 |
\end{verbatim}
|
alpar@1
|
1021 |
|
alpar@1
|
1022 |
\subsubsection*{Description}
|
alpar@1
|
1023 |
|
alpar@1
|
1024 |
The routine \verb|glp_write_ipt| writes the current interior-point
|
alpar@1
|
1025 |
solution to a text file whose name is specified by the parameter
|
alpar@1
|
1026 |
\verb|fname|. This file can be read back with the routine
|
alpar@1
|
1027 |
\verb|glp_read_ipt|.
|
alpar@1
|
1028 |
|
alpar@1
|
1029 |
\subsubsection*{Returns}
|
alpar@1
|
1030 |
|
alpar@1
|
1031 |
On success the routine returns zero, otherwise non-zero.
|
alpar@1
|
1032 |
|
alpar@1
|
1033 |
\subsubsection*{File format}
|
alpar@1
|
1034 |
|
alpar@1
|
1035 |
The file created by the routine \verb|glp_write_ipt| is a plain text
|
alpar@1
|
1036 |
file, which contains the following information:
|
alpar@1
|
1037 |
|
alpar@1
|
1038 |
\begin{verbatim}
|
alpar@1
|
1039 |
m n
|
alpar@1
|
1040 |
stat obj_val
|
alpar@1
|
1041 |
r_prim[1] r_dual[1]
|
alpar@1
|
1042 |
. . .
|
alpar@1
|
1043 |
r_prim[m] r_dual[m]
|
alpar@1
|
1044 |
c_prim[1] c_dual[1]
|
alpar@1
|
1045 |
. . .
|
alpar@1
|
1046 |
c_prim[n] c_dual[n]
|
alpar@1
|
1047 |
\end{verbatim}
|
alpar@1
|
1048 |
|
alpar@1
|
1049 |
\noindent
|
alpar@1
|
1050 |
where:
|
alpar@1
|
1051 |
|
alpar@1
|
1052 |
\noindent
|
alpar@1
|
1053 |
$m$ is the number of rows (auxiliary variables);
|
alpar@1
|
1054 |
|
alpar@1
|
1055 |
\noindent
|
alpar@1
|
1056 |
$n$ is the number of columns (structural variables);
|
alpar@1
|
1057 |
|
alpar@1
|
1058 |
\noindent
|
alpar@1
|
1059 |
\verb|stat| is the solution status (\verb|GLP_UNDEF| = 1 or
|
alpar@1
|
1060 |
\verb|GLP_OPT| = 5);
|
alpar@1
|
1061 |
|
alpar@1
|
1062 |
\noindent
|
alpar@1
|
1063 |
\verb|obj_val| is the objective value;
|
alpar@1
|
1064 |
|
alpar@1
|
1065 |
\noindent
|
alpar@1
|
1066 |
\verb|r_prim[i]|, $i=1,\dots,m$, is the primal value of $i$-th row;
|
alpar@1
|
1067 |
|
alpar@1
|
1068 |
\noindent
|
alpar@1
|
1069 |
\verb|r_dual[i]|, $i=1,\dots,m$, is the dual value of $i$-th row;
|
alpar@1
|
1070 |
|
alpar@1
|
1071 |
\noindent
|
alpar@1
|
1072 |
\verb|c_prim[j]|, $j=1,\dots,n$, is the primal value of $j$-th column;
|
alpar@1
|
1073 |
|
alpar@1
|
1074 |
\noindent
|
alpar@1
|
1075 |
\verb|c_dual[j]|, $j=1,\dots,n$, is the dual value of $j$-th column.
|
alpar@1
|
1076 |
|
alpar@1
|
1077 |
\subsection{glp\_print\_mip---write MIP solution in printable format}
|
alpar@1
|
1078 |
|
alpar@1
|
1079 |
\subsubsection*{Synopsis}
|
alpar@1
|
1080 |
|
alpar@1
|
1081 |
\begin{verbatim}
|
alpar@1
|
1082 |
int glp_print_mip(glp_prob *lp, const char *fname);
|
alpar@1
|
1083 |
\end{verbatim}
|
alpar@1
|
1084 |
|
alpar@1
|
1085 |
\subsubsection*{Description}
|
alpar@1
|
1086 |
|
alpar@1
|
1087 |
The routine \verb|glp_print_mip| writes a best known integer solution
|
alpar@1
|
1088 |
of a MIP problem, which is specified by the pointer \verb|lp|, to a text
|
alpar@1
|
1089 |
file, whose name is the character string \verb|fname|, in printable
|
alpar@1
|
1090 |
format.
|
alpar@1
|
1091 |
|
alpar@1
|
1092 |
Information reported by the routine \verb|glp_print_mip| is intended
|
alpar@1
|
1093 |
mainly for visual analysis.
|
alpar@1
|
1094 |
|
alpar@1
|
1095 |
\subsubsection*{Returns}
|
alpar@1
|
1096 |
|
alpar@1
|
1097 |
If no errors occurred, the routine returns zero. Otherwise the routine
|
alpar@1
|
1098 |
prints an error message and returns non-zero.
|
alpar@1
|
1099 |
|
alpar@1
|
1100 |
\newpage
|
alpar@1
|
1101 |
|
alpar@1
|
1102 |
\subsection{glp\_read\_mip---read MIP solution from text file}
|
alpar@1
|
1103 |
|
alpar@1
|
1104 |
\subsubsection*{Synopsis}
|
alpar@1
|
1105 |
|
alpar@1
|
1106 |
\begin{verbatim}
|
alpar@1
|
1107 |
int glp_read_mip(glp_prob *mip, const char *fname);
|
alpar@1
|
1108 |
\end{verbatim}
|
alpar@1
|
1109 |
|
alpar@1
|
1110 |
\subsubsection*{Description}
|
alpar@1
|
1111 |
|
alpar@1
|
1112 |
The routine \verb|glp_read_mip| reads MIP solution from a text file
|
alpar@1
|
1113 |
whose name is specified by the parameter \verb|fname| into the problem
|
alpar@1
|
1114 |
object.
|
alpar@1
|
1115 |
|
alpar@1
|
1116 |
For the file format see description of the routine \verb|glp_write_mip|.
|
alpar@1
|
1117 |
|
alpar@1
|
1118 |
\subsubsection*{Returns}
|
alpar@1
|
1119 |
|
alpar@1
|
1120 |
On success the routine returns zero, otherwise non-zero.
|
alpar@1
|
1121 |
|
alpar@1
|
1122 |
\subsection{glp\_write\_mip---write MIP solution to text file}
|
alpar@1
|
1123 |
|
alpar@1
|
1124 |
\subsubsection*{Synopsis}
|
alpar@1
|
1125 |
|
alpar@1
|
1126 |
\begin{verbatim}
|
alpar@1
|
1127 |
int glp_write_mip(glp_prob *mip, const char *fname);
|
alpar@1
|
1128 |
\end{verbatim}
|
alpar@1
|
1129 |
|
alpar@1
|
1130 |
\subsubsection*{Description}
|
alpar@1
|
1131 |
|
alpar@1
|
1132 |
The routine \verb|glp_write_mip| writes the current MIP solution to a
|
alpar@1
|
1133 |
text file whose name is specified by the parameter \verb|fname|. This
|
alpar@1
|
1134 |
file can be read back with the routine \verb|glp_read_mip|.
|
alpar@1
|
1135 |
|
alpar@1
|
1136 |
\subsubsection*{Returns}
|
alpar@1
|
1137 |
|
alpar@1
|
1138 |
On success the routine returns zero, otherwise non-zero.
|
alpar@1
|
1139 |
|
alpar@1
|
1140 |
\subsubsection*{File format}
|
alpar@1
|
1141 |
|
alpar@1
|
1142 |
The file created by the routine \verb|glp_write_sol| is a plain text
|
alpar@1
|
1143 |
file, which contains the following information:
|
alpar@1
|
1144 |
|
alpar@1
|
1145 |
\begin{verbatim}
|
alpar@1
|
1146 |
m n
|
alpar@1
|
1147 |
stat obj_val
|
alpar@1
|
1148 |
r_val[1]
|
alpar@1
|
1149 |
. . .
|
alpar@1
|
1150 |
r_val[m]
|
alpar@1
|
1151 |
c_val[1]
|
alpar@1
|
1152 |
. . .
|
alpar@1
|
1153 |
c_val[n]
|
alpar@1
|
1154 |
\end{verbatim}
|
alpar@1
|
1155 |
|
alpar@1
|
1156 |
\noindent
|
alpar@1
|
1157 |
where:
|
alpar@1
|
1158 |
|
alpar@1
|
1159 |
\noindent
|
alpar@1
|
1160 |
$m$ is the number of rows (auxiliary variables);
|
alpar@1
|
1161 |
|
alpar@1
|
1162 |
\noindent
|
alpar@1
|
1163 |
$n$ is the number of columns (structural variables);
|
alpar@1
|
1164 |
|
alpar@1
|
1165 |
\noindent
|
alpar@1
|
1166 |
\verb|stat| is the solution status (\verb|GLP_UNDEF| = 1,
|
alpar@1
|
1167 |
\verb|GLP_FEAS| = 2, \verb|GLP_NOFEAS| = 4, or \verb|GLP_OPT| = 5);
|
alpar@1
|
1168 |
|
alpar@1
|
1169 |
\noindent
|
alpar@1
|
1170 |
\verb|obj_val| is the objective value;
|
alpar@1
|
1171 |
|
alpar@1
|
1172 |
\noindent
|
alpar@1
|
1173 |
\verb|r_val[i]|, $i=1,\dots,m$, is the value of $i$-th row;
|
alpar@1
|
1174 |
|
alpar@1
|
1175 |
\noindent
|
alpar@1
|
1176 |
\verb|c_val[j]|, $j=1,\dots,n$, is the value of $j$-th column.
|
alpar@1
|
1177 |
|
alpar@1
|
1178 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
alpar@1
|
1179 |
|
alpar@1
|
1180 |
\newpage
|
alpar@1
|
1181 |
|
alpar@1
|
1182 |
\section{Post-optimal analysis routines}
|
alpar@1
|
1183 |
|
alpar@1
|
1184 |
\subsection{glp\_print\_ranges---print sensitivity analysis report}
|
alpar@1
|
1185 |
|
alpar@1
|
1186 |
\subsubsection*{Synopsis}
|
alpar@1
|
1187 |
|
alpar@1
|
1188 |
\begin{verbatim}
|
alpar@1
|
1189 |
int glp_print_ranges(glp_prob *P, int len, const int list[],
|
alpar@1
|
1190 |
int flags, const char *fname);
|
alpar@1
|
1191 |
\end{verbatim}
|
alpar@1
|
1192 |
|
alpar@1
|
1193 |
\subsubsection*{Description}
|
alpar@1
|
1194 |
|
alpar@1
|
1195 |
The routine \verb|glp_print_ranges| performs sensitivity analysis of
|
alpar@1
|
1196 |
current optimal basic solution and writes the analysis report in
|
alpar@1
|
1197 |
human-readable format to a text file, whose name is the character
|
alpar@1
|
1198 |
string {\it fname}. (Detailed description of the report structure is
|
alpar@1
|
1199 |
given below.)
|
alpar@1
|
1200 |
|
alpar@1
|
1201 |
The parameter {\it len} specifies the length of the row/column list.
|
alpar@1
|
1202 |
|
alpar@1
|
1203 |
The array {\it list} specifies ordinal number of rows and columns to be
|
alpar@1
|
1204 |
analyzed. The ordinal numbers should be passed in locations
|
alpar@1
|
1205 |
{\it list}[1], {\it list}[2], \dots, {\it list}[{\it len}]. Ordinal
|
alpar@1
|
1206 |
numbers from 1 to $m$ refer to rows, and ordinal numbers from $m+1$ to
|
alpar@1
|
1207 |
$m+n$ refer to columns, where $m$ and $n$ are, resp., the total number
|
alpar@1
|
1208 |
of rows and columns in the problem object. Rows and columns appear in
|
alpar@1
|
1209 |
the analysis report in the same order as they follow in the array list.
|
alpar@1
|
1210 |
|
alpar@1
|
1211 |
It is allowed to specify $len=0$, in which case the array {\it list} is
|
alpar@1
|
1212 |
not used (so it can be specified as \verb|NULL|), and the routine
|
alpar@1
|
1213 |
performs analysis for all rows and columns of the problem object.
|
alpar@1
|
1214 |
|
alpar@1
|
1215 |
The parameter {\it flags} is reserved for use in the future and must be
|
alpar@1
|
1216 |
specified as zero.
|
alpar@1
|
1217 |
|
alpar@1
|
1218 |
On entry to the routine \verb|glp_print_ranges| the current basic
|
alpar@1
|
1219 |
solution must be optimal and the basis factorization must exist.
|
alpar@1
|
1220 |
The application program can check that with the routine
|
alpar@1
|
1221 |
\verb|glp_bf_exists|, and if the factorization does
|
alpar@1
|
1222 |
not exist, compute it with the routine \verb|glp_factorize|. Note that
|
alpar@1
|
1223 |
if the LP preprocessor is not used, on normal exit from the simplex
|
alpar@1
|
1224 |
solver routine \verb|glp_simplex| the basis factorization always exists.
|
alpar@1
|
1225 |
|
alpar@1
|
1226 |
\subsubsection*{Returns}
|
alpar@1
|
1227 |
|
alpar@1
|
1228 |
If the operation was successful, the routine \verb|glp_print_ranges|
|
alpar@1
|
1229 |
returns zero. Otherwise, it prints an error message and returns
|
alpar@1
|
1230 |
non-zero.
|
alpar@1
|
1231 |
|
alpar@1
|
1232 |
\subsubsection*{Analysis report example}
|
alpar@1
|
1233 |
|
alpar@1
|
1234 |
An example of the sensitivity analysis report is shown on the next two
|
alpar@1
|
1235 |
pages. This example corresponds to the example of LP problem described
|
alpar@1
|
1236 |
in Subsection ``Example of MPS file''.
|
alpar@1
|
1237 |
|
alpar@1
|
1238 |
\subsubsection*{Structure of the analysis report}
|
alpar@1
|
1239 |
|
alpar@1
|
1240 |
For each row and column specified in the array {\it list} the routine
|
alpar@1
|
1241 |
prints two lines containing generic information and analysis
|
alpar@1
|
1242 |
information, which depends on the status of corresponding row or column.
|
alpar@1
|
1243 |
|
alpar@1
|
1244 |
Note that analysis of a row is analysis of its auxiliary variable,
|
alpar@1
|
1245 |
which is equal to the row linear form $\sum a_jx_j$, and analysis of
|
alpar@1
|
1246 |
a column is analysis of corresponding structural variable. Therefore,
|
alpar@1
|
1247 |
formally, on performing the sensitivity analysis there is no difference
|
alpar@1
|
1248 |
between rows and columns.
|
alpar@1
|
1249 |
|
alpar@1
|
1250 |
\bigskip
|
alpar@1
|
1251 |
|
alpar@1
|
1252 |
\noindent
|
alpar@1
|
1253 |
{\it Generic information}
|
alpar@1
|
1254 |
|
alpar@1
|
1255 |
\medskip
|
alpar@1
|
1256 |
|
alpar@1
|
1257 |
\noindent
|
alpar@1
|
1258 |
{\tt No.} is the row or column ordinal number in the problem object.
|
alpar@1
|
1259 |
Rows are numbered from 1 to $m$, and columns are numbered from 1 to $n$,
|
alpar@1
|
1260 |
where $m$ and $n$ are, resp., the total number of rows and columns in
|
alpar@1
|
1261 |
the problem object.
|
alpar@1
|
1262 |
|
alpar@1
|
1263 |
\medskip
|
alpar@1
|
1264 |
|
alpar@1
|
1265 |
\noindent
|
alpar@1
|
1266 |
{\tt Row name} is the symbolic name assigned to the row. If the row has
|
alpar@1
|
1267 |
no name assigned, this field contains blanks.
|
alpar@1
|
1268 |
|
alpar@1
|
1269 |
\medskip
|
alpar@1
|
1270 |
|
alpar@1
|
1271 |
\noindent
|
alpar@1
|
1272 |
{\tt Column name} is the symbolic name assigned to the column. If the
|
alpar@1
|
1273 |
column has no name assigned, this field contains blanks.
|
alpar@1
|
1274 |
|
alpar@1
|
1275 |
\medskip
|
alpar@1
|
1276 |
|
alpar@1
|
1277 |
\noindent
|
alpar@1
|
1278 |
{\tt St} is the status of the row or column in the optimal solution:
|
alpar@1
|
1279 |
|
alpar@1
|
1280 |
{\tt BS} --- non-active constraint (row), basic column;
|
alpar@1
|
1281 |
|
alpar@1
|
1282 |
{\tt NL} --- inequality constraint having its lower right-hand side
|
alpar@1
|
1283 |
active (row), non-basic column having its lower bound active;
|
alpar@1
|
1284 |
|
alpar@1
|
1285 |
{\tt NU} --- inequality constraint having its upper right-hand side
|
alpar@1
|
1286 |
active (row), non-basic column having its upper bound active;
|
alpar@1
|
1287 |
|
alpar@1
|
1288 |
{\tt NS} --- active equality constraint (row), non-basic fixed column.
|
alpar@1
|
1289 |
|
alpar@1
|
1290 |
{\tt NF} --- active free row, non-basic free (unbounded) column. (This
|
alpar@1
|
1291 |
case means that the optimal solution is dual degenerate.)
|
alpar@1
|
1292 |
|
alpar@1
|
1293 |
\medskip
|
alpar@1
|
1294 |
|
alpar@1
|
1295 |
\noindent
|
alpar@1
|
1296 |
{\tt Activity} is the (primal) value of the auxiliary variable (row) or
|
alpar@1
|
1297 |
structural variable (column) in the optimal solution.
|
alpar@1
|
1298 |
|
alpar@1
|
1299 |
\medskip
|
alpar@1
|
1300 |
|
alpar@1
|
1301 |
\noindent
|
alpar@1
|
1302 |
{\tt Slack} is the (primal) value of the row slack variable.
|
alpar@1
|
1303 |
|
alpar@1
|
1304 |
\medskip
|
alpar@1
|
1305 |
|
alpar@1
|
1306 |
\noindent
|
alpar@1
|
1307 |
{\tt Obj coef} is the objective coefficient of the column (structural
|
alpar@1
|
1308 |
variable).
|
alpar@1
|
1309 |
|
alpar@1
|
1310 |
\begin{landscape}
|
alpar@1
|
1311 |
\begin{scriptsize}
|
alpar@1
|
1312 |
\begin{verbatim}
|
alpar@1
|
1313 |
GLPK 4.42 - SENSITIVITY ANALYSIS REPORT Page 1
|
alpar@1
|
1314 |
|
alpar@1
|
1315 |
Problem: PLAN
|
alpar@1
|
1316 |
Objective: VALUE = 296.2166065 (MINimum)
|
alpar@1
|
1317 |
|
alpar@1
|
1318 |
No. Row name St Activity Slack Lower bound Activity Obj coef Obj value at Limiting
|
alpar@1
|
1319 |
Marginal Upper bound range range break point variable
|
alpar@1
|
1320 |
------ ------------ -- ------------- ------------- ------------- ------------- ------------- ------------- ------------
|
alpar@1
|
1321 |
1 VALUE BS 296.21661 -296.21661 -Inf 299.25255 -1.00000 . MN
|
alpar@1
|
1322 |
. +Inf 296.21661 +Inf +Inf
|
alpar@1
|
1323 |
|
alpar@1
|
1324 |
2 YIELD NS 2000.00000 . 2000.00000 1995.06864 -Inf 296.28365 BIN3
|
alpar@1
|
1325 |
-.01360 2000.00000 2014.03479 +Inf 296.02579 CU
|
alpar@1
|
1326 |
|
alpar@1
|
1327 |
3 FE NU 60.00000 . -Inf 55.89016 -Inf 306.77162 BIN4
|
alpar@1
|
1328 |
-2.56823 60.00000 62.69978 2.56823 289.28294 BIN3
|
alpar@1
|
1329 |
|
alpar@1
|
1330 |
4 CU BS 83.96751 16.03249 -Inf 93.88467 -.30613 270.51157 MN
|
alpar@1
|
1331 |
. 100.00000 79.98213 .21474 314.24798 BIN5
|
alpar@1
|
1332 |
|
alpar@1
|
1333 |
5 MN NU 40.00000 . -Inf 34.42336 -Inf 299.25255 BIN4
|
alpar@1
|
1334 |
-.54440 40.00000 41.68691 .54440 295.29825 BIN3
|
alpar@1
|
1335 |
|
alpar@1
|
1336 |
6 MG BS 19.96029 10.03971 -Inf 24.74427 -1.79618 260.36433 BIN1
|
alpar@1
|
1337 |
. 30.00000 9.40292 .28757 301.95652 MN
|
alpar@1
|
1338 |
|
alpar@1
|
1339 |
7 AL NL 1500.00000 . 1500.00000 1485.78425 -.25199 292.63444 CU
|
alpar@1
|
1340 |
.25199 +Inf 1504.92126 +Inf 297.45669 BIN3
|
alpar@1
|
1341 |
|
alpar@1
|
1342 |
8 SI NL 250.00000 50.00000 250.00000 235.32871 -.48520 289.09812 CU
|
alpar@1
|
1343 |
.48520 300.00000 255.06073 +Inf 298.67206 BIN3
|
alpar@1
|
1344 |
\end{verbatim}
|
alpar@1
|
1345 |
\end{scriptsize}
|
alpar@1
|
1346 |
\end{landscape}
|
alpar@1
|
1347 |
|
alpar@1
|
1348 |
\begin{landscape}
|
alpar@1
|
1349 |
\begin{scriptsize}
|
alpar@1
|
1350 |
\begin{verbatim}
|
alpar@1
|
1351 |
GLPK 4.42 - SENSITIVITY ANALYSIS REPORT Page 2
|
alpar@1
|
1352 |
|
alpar@1
|
1353 |
Problem: PLAN
|
alpar@1
|
1354 |
Objective: VALUE = 296.2166065 (MINimum)
|
alpar@1
|
1355 |
|
alpar@1
|
1356 |
No. Column name St Activity Obj coef Lower bound Activity Obj coef Obj value at Limiting
|
alpar@1
|
1357 |
Marginal Upper bound range range break point variable
|
alpar@1
|
1358 |
------ ------------ -- ------------- ------------- ------------- ------------- ------------- ------------- ------------
|
alpar@1
|
1359 |
1 BIN1 NL . .03000 . -28.82475 -.22362 288.90594 BIN4
|
alpar@1
|
1360 |
.25362 200.00000 33.88040 +Inf 304.80951 BIN4
|
alpar@1
|
1361 |
|
alpar@1
|
1362 |
2 BIN2 BS 665.34296 .08000 . 802.22222 .01722 254.44822 BIN1
|
alpar@1
|
1363 |
. 2500.00000 313.43066 .08863 301.95652 MN
|
alpar@1
|
1364 |
|
alpar@1
|
1365 |
3 BIN3 BS 490.25271 .17000 400.00000 788.61314 .15982 291.22807 MN
|
alpar@1
|
1366 |
. 800.00000 -347.42857 .17948 300.86548 BIN5
|
alpar@1
|
1367 |
|
alpar@1
|
1368 |
4 BIN4 BS 424.18773 .12000 100.00000 710.52632 .10899 291.54745 MN
|
alpar@1
|
1369 |
. 700.00000 -256.15524 .14651 307.46010 BIN1
|
alpar@1
|
1370 |
|
alpar@1
|
1371 |
5 BIN5 NL . .15000 . -201.78739 .13544 293.27940 BIN3
|
alpar@1
|
1372 |
.01456 1500.00000 58.79586 +Inf 297.07244 BIN3
|
alpar@1
|
1373 |
|
alpar@1
|
1374 |
6 ALUM BS 299.63899 .21000 . 358.26772 .18885 289.87879 AL
|
alpar@1
|
1375 |
. +Inf 112.40876 .22622 301.07527 MN
|
alpar@1
|
1376 |
|
alpar@1
|
1377 |
7 SILICON BS 120.57762 .38000 . 124.27093 .14828 268.27586 BIN5
|
alpar@1
|
1378 |
. +Inf 85.54745 .46667 306.66667 MN
|
alpar@1
|
1379 |
|
alpar@1
|
1380 |
End of report
|
alpar@1
|
1381 |
\end{verbatim}
|
alpar@1
|
1382 |
\end{scriptsize}
|
alpar@1
|
1383 |
\end{landscape}
|
alpar@1
|
1384 |
|
alpar@1
|
1385 |
\noindent
|
alpar@1
|
1386 |
{\tt Marginal} is the reduced cost (dual activity) of the auxiliary
|
alpar@1
|
1387 |
variable (row) or structural variable (column).
|
alpar@1
|
1388 |
|
alpar@1
|
1389 |
\medskip
|
alpar@1
|
1390 |
|
alpar@1
|
1391 |
\noindent
|
alpar@1
|
1392 |
{\tt Lower bound} is the lower right-hand side (row) or lower bound
|
alpar@1
|
1393 |
(column). If the row or column has no lower bound, this field contains
|
alpar@1
|
1394 |
{\tt -Inf}.
|
alpar@1
|
1395 |
|
alpar@1
|
1396 |
\medskip
|
alpar@1
|
1397 |
|
alpar@1
|
1398 |
\noindent
|
alpar@1
|
1399 |
{\tt Upper bound} is the upper right-hand side (row) or upper bound
|
alpar@1
|
1400 |
(column). If the row or column has no upper bound, this field contains
|
alpar@1
|
1401 |
{\tt +Inf}.
|
alpar@1
|
1402 |
|
alpar@1
|
1403 |
\bigskip
|
alpar@1
|
1404 |
|
alpar@1
|
1405 |
\noindent
|
alpar@1
|
1406 |
{\it Sensitivity analysis of active bounds}
|
alpar@1
|
1407 |
|
alpar@1
|
1408 |
\medskip
|
alpar@1
|
1409 |
|
alpar@1
|
1410 |
\noindent
|
alpar@1
|
1411 |
The sensitivity analysis of active bounds is performed only for rows,
|
alpar@1
|
1412 |
which are active constraints, and only for non-basic columns, because
|
alpar@1
|
1413 |
inactive constraints and basic columns have no active bounds.
|
alpar@1
|
1414 |
|
alpar@1
|
1415 |
For every auxiliary (row) or structural (column) non-basic variable the
|
alpar@1
|
1416 |
routine starts changing its active bound in both direction. The first
|
alpar@1
|
1417 |
of the two lines in the report corresponds to decreasing, and the
|
alpar@1
|
1418 |
second line corresponds to increasing of the active bound. Since the
|
alpar@1
|
1419 |
variable being analyzed is non-basic, its activity, which is equal to
|
alpar@1
|
1420 |
its active bound, also starts changing. This changing leads to changing
|
alpar@1
|
1421 |
of basic (auxiliary and structural) variables, which depend on the
|
alpar@1
|
1422 |
non-basic variable. The current basis remains primal feasible and
|
alpar@1
|
1423 |
therefore optimal while values of all basic variables are primal
|
alpar@1
|
1424 |
feasible, i.e. are within their bounds. Therefore, if some basic
|
alpar@1
|
1425 |
variable called the {\it limiting variable} reaches its (lower or
|
alpar@1
|
1426 |
upper) bound first, before any other basic variables, it thereby limits
|
alpar@1
|
1427 |
further changing of the non-basic variable, because otherwise the
|
alpar@1
|
1428 |
current basis would become primal infeasible. The point, at which this
|
alpar@1
|
1429 |
happens, is called the {\it break point}. Note that there are two break
|
alpar@1
|
1430 |
points: the lower break point, which corresponds to decreasing of the
|
alpar@1
|
1431 |
non-basic variable, and the upper break point, which corresponds to
|
alpar@1
|
1432 |
increasing of the non-basic variable.
|
alpar@1
|
1433 |
|
alpar@1
|
1434 |
In the analysis report values of the non-basic variable (i.e. of its
|
alpar@1
|
1435 |
active bound) being analyzed at both lower and upper break points are
|
alpar@1
|
1436 |
printed in the field `{\tt Activity range}'. Corresponding values of
|
alpar@1
|
1437 |
the objective function are printed in the field `{\tt Obj value at
|
alpar@1
|
1438 |
break point}', and symbolic names of corresponding limiting basic
|
alpar@1
|
1439 |
variables are printed in the field `{\tt Limiting variable}'.
|
alpar@1
|
1440 |
If the active bound can decrease or/and increase unlimitedly, the field
|
alpar@1
|
1441 |
`{\tt Activity range}' contains {\tt -Inf} or/and {\tt +Inf}, resp.
|
alpar@1
|
1442 |
|
alpar@1
|
1443 |
For example (see the example report above), row SI is a double-sided
|
alpar@1
|
1444 |
constraint, which is active on its lower bound (right-hand side), and
|
alpar@1
|
1445 |
its activity in the optimal solution being equal to the lower bound is
|
alpar@1
|
1446 |
250. The activity range for this row is $[235.32871,255.06073]$. This
|
alpar@1
|
1447 |
means that the basis remains optimal while the lower bound is
|
alpar@1
|
1448 |
increasing up to 255.06073, and further increasing is limited by
|
alpar@1
|
1449 |
(structural) variable BIN3. If the lower bound reaches this upper break
|
alpar@1
|
1450 |
point, the objective value becomes equal to 298.67206.
|
alpar@1
|
1451 |
|
alpar@1
|
1452 |
Note that if the basis does not change, the objective function depends
|
alpar@1
|
1453 |
on the non-basic variable linearly, and the per-unit change of the
|
alpar@1
|
1454 |
objective function is the reduced cost (marginal value) of the
|
alpar@1
|
1455 |
non-basic variable.
|
alpar@1
|
1456 |
|
alpar@1
|
1457 |
\bigskip
|
alpar@1
|
1458 |
|
alpar@1
|
1459 |
\noindent
|
alpar@1
|
1460 |
{\it Sensitivity analysis of objective coefficients at non-basic
|
alpar@1
|
1461 |
variables}
|
alpar@1
|
1462 |
|
alpar@1
|
1463 |
\medskip
|
alpar@1
|
1464 |
|
alpar@1
|
1465 |
\noindent
|
alpar@1
|
1466 |
The sensitivity analysis of the objective coefficient at a non-basic
|
alpar@1
|
1467 |
variable is quite simple, because in this case change in the objective
|
alpar@1
|
1468 |
coefficient leads to equivalent change in the reduced cost (marginal
|
alpar@1
|
1469 |
value).
|
alpar@1
|
1470 |
|
alpar@1
|
1471 |
For every auxiliary (row) or structural (column) non-basic variable the
|
alpar@1
|
1472 |
routine starts changing its objective coefficient in both direction.
|
alpar@1
|
1473 |
(Note that auxiliary variables are not included in the objective
|
alpar@1
|
1474 |
function and therefore always have zero objective coefficients.) The
|
alpar@1
|
1475 |
first of the two lines in the report corresponds to decreasing, and the
|
alpar@1
|
1476 |
second line corresponds to increasing of the objective coefficient.
|
alpar@1
|
1477 |
This changing leads to changing of the reduced cost of the non-basic
|
alpar@1
|
1478 |
variable to be analyzed and does affect reduced costs of all other
|
alpar@1
|
1479 |
non-basic variables. The current basis remains dual feasible and
|
alpar@1
|
1480 |
therefore optimal while the reduced cost keeps its sign. Therefore, if
|
alpar@1
|
1481 |
the reduced cost reaches zero, it limits further changing of the
|
alpar@1
|
1482 |
objective coefficient (if only the non-basic variable is non-fixed).
|
alpar@1
|
1483 |
|
alpar@1
|
1484 |
In the analysis report minimal and maximal values of the objective
|
alpar@1
|
1485 |
coefficient, on which the basis remains optimal, are printed in the
|
alpar@1
|
1486 |
field `\verb|Obj coef range|'. If the objective coefficient can
|
alpar@1
|
1487 |
decrease or/and increase unlimitedly, this field contains {\tt -Inf}
|
alpar@1
|
1488 |
or/and {\tt +Inf}, resp.
|
alpar@1
|
1489 |
|
alpar@1
|
1490 |
For example (see the example report above), column BIN5 is non-basic
|
alpar@1
|
1491 |
having its lower bound active. Its objective coefficient is 0.15, and
|
alpar@1
|
1492 |
reduced cost in the optimal solution 0.01456. The column lower bound
|
alpar@1
|
1493 |
remains active while the column reduced cost remains non-negative,
|
alpar@1
|
1494 |
thus, minimal value of the objective coefficient, on which the current
|
alpar@1
|
1495 |
basis still remains optimal, is $0.15-0.01456=0.13644$, that is
|
alpar@1
|
1496 |
indicated in the field `\verb|Obj coef range|'.
|
alpar@1
|
1497 |
|
alpar@1
|
1498 |
\bigskip
|
alpar@1
|
1499 |
|
alpar@1
|
1500 |
\noindent
|
alpar@1
|
1501 |
{\it Sensitivity analysis of objective coefficients at basic variables}
|
alpar@1
|
1502 |
|
alpar@1
|
1503 |
\medskip
|
alpar@1
|
1504 |
|
alpar@1
|
1505 |
\noindent
|
alpar@1
|
1506 |
To perform sensitivity analysis for every auxiliary (row) or structural
|
alpar@1
|
1507 |
(column) variable the routine starts changing its objective coefficient
|
alpar@1
|
1508 |
in both direction. (Note that auxiliary variables are not included in
|
alpar@1
|
1509 |
the objective function and therefore always have zero objective
|
alpar@1
|
1510 |
coefficients.) The first of the two lines in the report corresponds to
|
alpar@1
|
1511 |
decreasing, and the second line corresponds to increasing of the
|
alpar@1
|
1512 |
objective coefficient. This changing leads to changing of reduced costs
|
alpar@1
|
1513 |
of non-basic variables. The current basis remains dual feasible and
|
alpar@1
|
1514 |
therefore optimal while reduced costs of all non-basic variables
|
alpar@1
|
1515 |
(except fixed variables) keep their signs. Therefore, if the reduced
|
alpar@1
|
1516 |
cost of some non-basic non-fixed variable called the {\it limiting
|
alpar@1
|
1517 |
variable} reaches zero first, before reduced cost of any other
|
alpar@1
|
1518 |
non-basic non-fixed variable, it thereby limits further changing of the
|
alpar@1
|
1519 |
objective coefficient, because otherwise the current basis would become
|
alpar@1
|
1520 |
dual infeasible (non-optimal). The point, at which this happens, is
|
alpar@1
|
1521 |
called the {\it break point}. Note that there are two break points: the
|
alpar@1
|
1522 |
lower break point, which corresponds to decreasing of the objective
|
alpar@1
|
1523 |
coefficient, and the upper break point, which corresponds to increasing
|
alpar@1
|
1524 |
of the objective coefficient. Let the objective coefficient reach its
|
alpar@1
|
1525 |
limit value and continue changing a bit further in the same direction
|
alpar@1
|
1526 |
that makes the current basis dual infeasible (non-optimal). Then the
|
alpar@1
|
1527 |
reduced cost of the non-basic limiting variable becomes ``a bit'' dual
|
alpar@1
|
1528 |
infeasible that forces the limiting variable to enter the basis
|
alpar@1
|
1529 |
replacing there some basic variable, which leaves the basis to keep its
|
alpar@1
|
1530 |
primal feasibility. It should be understood that if we change the
|
alpar@1
|
1531 |
current basis in this way exactly at the break point, both the current
|
alpar@1
|
1532 |
and adjacent bases will be optimal with the same objective value,
|
alpar@1
|
1533 |
because at the break point the limiting variable has zero reduced cost.
|
alpar@1
|
1534 |
On the other hand, in the adjacent basis the value of the limiting
|
alpar@1
|
1535 |
variable changes, because there it becomes basic, that leads to
|
alpar@1
|
1536 |
changing of the value of the basic variable being analyzed. Note that
|
alpar@1
|
1537 |
on determining the adjacent basis the bounds of the analyzed basic
|
alpar@1
|
1538 |
variable are ignored as if it were a free (unbounded) variable, so it
|
alpar@1
|
1539 |
cannot leave the current basis.
|
alpar@1
|
1540 |
|
alpar@1
|
1541 |
In the analysis report lower and upper limits of the objective
|
alpar@1
|
1542 |
coefficient at the basic variable being analyzed, when the basis
|
alpar@1
|
1543 |
remains optimal, are printed in the field `{\tt Obj coef range}'.
|
alpar@1
|
1544 |
Corresponding values of the objective function at both lower and upper
|
alpar@1
|
1545 |
break points are printed in the field `{\tt Obj value at break point}',
|
alpar@1
|
1546 |
symbolic names of corresponding non-basic limiting variables are
|
alpar@1
|
1547 |
printed in the field `{\tt Limiting variable}', and values of the basic
|
alpar@1
|
1548 |
variable, which it would take on in the adjacent bases (as was
|
alpar@1
|
1549 |
explained above) are printed in the field `{\tt Activity range}'.
|
alpar@1
|
1550 |
If the objective coefficient can increase or/and decrease unlimitedly,
|
alpar@1
|
1551 |
the field `{\tt Obj coef range}' contains {\tt -Inf} and/or {\tt +Inf},
|
alpar@1
|
1552 |
resp. It also may happen that no dual feasible adjacent basis exists
|
alpar@1
|
1553 |
(i.e. on entering the basis the limiting variable can increase or
|
alpar@1
|
1554 |
decrease unlimitedly), in which case the field `{\tt Activity range}'
|
alpar@1
|
1555 |
contains {\tt -Inf} and/or {\tt +Inf}.
|
alpar@1
|
1556 |
|
alpar@1
|
1557 |
\newpage
|
alpar@1
|
1558 |
|
alpar@1
|
1559 |
For example (see the example report above), structural variable
|
alpar@1
|
1560 |
(column) BIN3 is basic, its optimal value is 490.25271, and its
|
alpar@1
|
1561 |
objective coefficient is 0.17. The objective coefficient range for this
|
alpar@1
|
1562 |
column is $[0.15982,0.17948]$. This means that the basis remains
|
alpar@1
|
1563 |
optimal while the objective coefficient is decreasing down to 0.15982,
|
alpar@1
|
1564 |
and further decreasing is limited by (auxiliary) variable MN. If we
|
alpar@1
|
1565 |
make the objective coefficient a bit less than 0.15982, the limiting
|
alpar@1
|
1566 |
variable MN will enter the basis, and in that adjacent basis the
|
alpar@1
|
1567 |
structural variable BIN3 will take on new optimal value 788.61314. At
|
alpar@1
|
1568 |
the lower break point, where the objective coefficient is exactly
|
alpar@1
|
1569 |
0.15982, the objective function takes on the value 291.22807 in both
|
alpar@1
|
1570 |
the current and adjacent bases.
|
alpar@1
|
1571 |
|
alpar@1
|
1572 |
Note that if the basis does not change, the objective function depends
|
alpar@1
|
1573 |
on the objective coefficient at the basic variable linearly, and the
|
alpar@1
|
1574 |
per-unit change of the objective function is the value of the basic
|
alpar@1
|
1575 |
variable.
|
alpar@1
|
1576 |
|
alpar@1
|
1577 |
%* eof *%
|