COIN-OR::LEMON - Graph Library

source: glpk-cmake/examples/yacfs.mod @ 2:4c8956a7bdf4

Last change on this file since 2:4c8956a7bdf4 was 1:c445c931472f, checked in by Alpar Juttner <alpar@…>, 14 years ago

Import glpk-4.45

  • Generated files and doc/notes are removed
File size: 933 bytes
Line 
1/*Yet Another Curve Fitting Solution
2
3  Obviously this solution produces the same answer
4  as examples/cflsq.mod
5
6  Nigel_Galloway@operamail.com
7  February 1st., 2009
8*/
9set Sample;
10param Sx {z in Sample};
11param Sy {z in Sample};
12
13var a;
14var b;
15
16equalz1 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
17equalz2 :sum{z in Sample} a*Sx[z] + sum{z in Sample} b = sum{z in Sample} Sy[z];
18
19solve;
20
21printf "\nbest linear fit is:\n\ty = %f %s %fx\n\n", b, if a < 0 then "-" else "+", abs(a);
22
23data;
24
25param:
26Sample:   Sx    Sy :=
27  1         0    1
28  2       0.5  0.9
29  3         1  0.7
30  4       1.5  1.5
31  5       1.9    2
32  6       2.5  2.4
33  7         3  3.2
34  8       3.5    2
35  9         4  2.7
36 10       4.5  3.5
37 11         5    1
38 12       5.5    4
39 13         6  3.6
40 14       6.6  2.7
41 15         7  5.7
42 16       7.6  4.6
43 17       8.5    6
44 18         9  6.8
45 19        10  7.3
46;
47
48end;
Note: See TracBrowser for help on using the repository browser.