/usr/share/doc/glpk-utils/examples/cf12a.mod is in glpk-utils 4.52.1-2build1.
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 | /*
Curve fitting problem 12.11(a) H P Williams "Model Building in Mathematical Programming"
Dr. H J Mackenzie
HARD software
hjm@hardsoftware.com
2006-01-05
*/
# set of points
set I;
# independent variable
param x {i in I};
# dependent variable
param y {i in I};
# output input values
printf {i in I} "x = %.1f; y = %.1f\n", x[i], y[i];
# define equation variables
var a;
var b;
var u {i in I}, >= 0;
var v {i in I}, >= 0;
# define objective function
minimize error: sum {i in I} u[i] + sum {i in I} v[i];
# define equation constraint
s.t. equation {i in I} : b * x[i] + a + u[i] - v[i] = y[i];
solve;
printf "y = %.4fx + %.4f\n", b, a;
/*
*
* DATA section
*
*/
data;
param : I : x y :=
1 0 1
2 0.5 0.9
3 1 0.7
4 1.5 1.5
5 1.9 2
6 2.5 2.4
7 3 3.2
8 3.5 2
9 4 2.7
10 4.5 3.5
11 5 1
12 5.5 4
13 6 3.6
14 6.6 2.7
15 7 5.7
16 7.6 4.6
17 8.5 6
18 9 6.8
19 10 7.3
;
end;
|