lemon-project-template-glpk

diff deps/glpk/examples/yacfs.mod @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/deps/glpk/examples/yacfs.mod	Sun Nov 06 20:59:10 2011 +0100
     1.3 @@ -0,0 +1,48 @@
     1.4 +/*Yet Another Curve Fitting Solution
     1.5 +
     1.6 +  Obviously this solution produces the same answer
     1.7 +  as examples/cflsq.mod
     1.8 +
     1.9 +  Nigel_Galloway@operamail.com
    1.10 +  February 1st., 2009
    1.11 +*/
    1.12 +set Sample;
    1.13 +param Sx {z in Sample};
    1.14 +param Sy {z in Sample};
    1.15 +
    1.16 +var a;
    1.17 +var b;
    1.18 +
    1.19 +equalz1 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
    1.20 +equalz2 :sum{z in Sample} a*Sx[z] + sum{z in Sample} b = sum{z in Sample} Sy[z];
    1.21 +
    1.22 +solve;
    1.23 +
    1.24 +printf "\nbest linear fit is:\n\ty = %f %s %fx\n\n", b, if a < 0 then "-" else "+", abs(a);
    1.25 +
    1.26 +data;
    1.27 +
    1.28 +param:
    1.29 +Sample:   Sx    Sy :=
    1.30 +  1         0    1
    1.31 +  2       0.5  0.9
    1.32 +  3         1  0.7
    1.33 +  4       1.5  1.5
    1.34 +  5       1.9    2
    1.35 +  6       2.5  2.4
    1.36 +  7         3  3.2
    1.37 +  8       3.5    2
    1.38 +  9         4  2.7
    1.39 + 10       4.5  3.5
    1.40 + 11         5    1
    1.41 + 12       5.5    4
    1.42 + 13         6  3.6
    1.43 + 14       6.6  2.7
    1.44 + 15         7  5.7
    1.45 + 16       7.6  4.6
    1.46 + 17       8.5    6
    1.47 + 18         9  6.8
    1.48 + 19        10  7.3
    1.49 +;
    1.50 +
    1.51 +end;