COIN-OR::LEMON - Graph Library

source: lemon-project-template-glpk/deps/glpk/examples/cf12a.mod @ 10:5545663ca997

subpack-glpk
Last change on this file since 10:5545663ca997 was 9:33de93886c88, checked in by Alpar Juttner <alpar@…>, 13 years ago

Import GLPK 4.47

File size: 1.1 KB
Line 
1/*
2
3  Curve fitting problem 12.11(a) H P Williams "Model Building in Mathematical Programming"
4
5  Dr. H J Mackenzie
6  HARD software
7  hjm@hardsoftware.com
8
9  2006-01-05
10
11 */
12
13# set of points
14
15set I;
16
17# independent variable
18
19param x {i in I};
20
21# dependent variable
22
23param y {i in I};
24
25# output input values
26
27printf {i in I} "x = %.1f; y = %.1f\n", x[i], y[i];
28
29# define equation variables
30
31var a;
32
33var b;
34
35var u {i in I}, >= 0;
36
37var v {i in I}, >= 0;
38
39# define objective function
40
41minimize error: sum {i in I} u[i] + sum {i in I} v[i];
42
43# define equation constraint
44
45s.t. equation {i in I} : b * x[i] + a + u[i] - v[i] = y[i];
46
47solve;
48
49printf "y = %.4fx + %.4f\n", b, a;
50
51/*
52 *
53 * DATA section
54 *
55 */
56
57data;
58
59param : I :   x    y :=
60        1     0    1
61        2   0.5  0.9
62        3     1  0.7
63        4   1.5  1.5
64        5   1.9    2
65        6   2.5  2.4
66        7     3  3.2
67        8   3.5    2
68        9     4  2.7
69       10   4.5  3.5
70       11     5    1
71       12   5.5    4
72       13     6  3.6
73       14   6.6  2.7
74       15     7  5.7
75       16   7.6  4.6
76       17   8.5    6
77       18     9  6.8
78       19    10  7.3
79;
80
81end;
Note: See TracBrowser for help on using the repository browser.