1 /* -*- Mode: maxima; Package: MAXIMA -*- */
5 * Author: Leo Butler (l_butler@users.sourceforge.net)
7 * This file is Maxima code (http://maxima.sourceforge.net/)
9 * It is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or (at your
12 * option) any later version.
14 * This software is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 * License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this file. If not, see http://www.gnu.org/licenses/.
23 %simplex_netlib_case(opts) := block([A,b,c,csv_file,root,scale_sx],
24 [root,scale_sx] : opts,
25 csv_file : lambda([x],printf(false,"Tests/~a_~a.csv",root,x)),
26 A : read_matrix(csv_file('A),'csv),
27 b : read_list(csv_file('b),'csv),
28 c : read_list(csv_file('c),'csv),
29 cons(root,cons(scale_sx,linear_program(A,b,c))))$
30 simplex_netlib() := block([cases : [[adlittle,false], [afiro,false], [kb2,true], [sc50a,false], [share2b,false]]],
31 map(%simplex_netlib_case,cases))$
32 /* print table simpex.texi */
33 print_simplex_netlib() := block([results : simplex_netlib(), printer],
34 /* BUG in the ~< directive makes us print both the case and min-value as strings before justification */
35 printer : lambda([x], printf(false,"~2,15,,' <~a~;~a~> ~a~%",
36 printf(false,"~a",part(x,1)),printf(false,"~16,10,2,1,,,'E@E",part(x,4)),printf(false,"~a",part(x,2)))),
37 printf(true,"~%PROBLEM MINIMUM SCALING~%~{~a~}",map(printer,results)))$
38 print_simplex_netlib();
40 /* from http://www.netlib.org/lp/data/readme */
42 [adlittle,2.2549496316E+05],
43 [afiro,- 4.6475314286E+02],
44 [kb2,- 1.7499001299E+03],
45 [sc50a,- 6.4575077059E+01],
46 [share2b,- 4.1573224074E+02]
48 simplex_results : map(lambda([x],[first(x),last(x)]),simplex_netlib());
49 (simplex_results - netlib_results)/netlib_results;
51 /* end of netlib.mac */