help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] Yet Another (and the best!!!) Curve Fitting Solution:


From: Nigel Galloway
Subject: [Help-glpk] Yet Another (and the best!!!) Curve Fitting Solution:
Date: Mon, 2 Feb 2009 15:34:34 +0100

Andrew,

Yet Another (and the best!) Curve Fitting Solution:
  YACFS.mod produces the same result as examples/cflsq.mod;
  Qfit.mod find a plausable fit of the form a + bx + bx^2
  It reduces the size of the triangular part from 38 to 1 which I 
assume is good;
  It is independant of the sample size;
  More importantly, I think it looks rather neat in Mathprog.

If you agree please add YACFS.mod and Qfit.mod to examples.

YACFS.png displays:
  The data points in red;
  The best fit suggested by examples/cf12a.mod in pink;
  The best fit suggested by YACFS.mod in blue;
  and The best fit suggested by Qfit.mod in green.

Conclusion - more measurements with x > 10 required.

First using the existing cflsq.mod

address@hidden:~$ /opt/glpk_4_35/bin/glpsol --math 
'/home/nigel/myGLPK/glpk-4.35/examples/cflsq.mod'
Reading model section from /home/nigel/myGLPK/glpk-4.35/examples/cflsq.mod...
Reading data section from /home/nigel/myGLPK/glpk-4.35/examples/cflsq.mod...
51 lines were read
Generating variencesX...
Generating zumVariancesX...
Generating variencesY...
Generating zumVariancesY...
Model has been successfully generated
glp_simplex: original LP has 40 rows, 40 columns, 114 non-zeros
glp_simplex: presolved LP has 40 rows, 40 columns, 114 non-zeros
Scaling...
  A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
Crashing...
Size of triangular part = 38
       0: obj =   0.000000000e+00  infeas =  1.492e+02 (2)
*     2: obj =   0.000000000e+00  infeas =  0.000e+00 (0)
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.2 Mb (173591 bytes)

best linear fit is:
        y = 0.426126 + 0.610772x

Model has been successfully processed

Compares with YACFS.mod

address@hidden:~$ /opt/glpk_4_35/bin/glpsol --math 
'/home/nigel/myGLPK/YACFS.mod'
Reading model section from /home/nigel/myGLPK/YACFS.mod...
Reading data section from /home/nigel/myGLPK/YACFS.mod...
48 lines were read
Generating equalz1...
Generating equalz2...
Model has been successfully generated
glp_simplex: original LP has 2 rows, 2 columns, 4 non-zeros
glp_simplex: presolved LP has 2 rows, 2 columns, 4 non-zeros
Scaling...
  A: min|aij| =  1.900e+01  max|aij| =  5.657e+02  ratio =  2.977e+01
GM: min|aij| =  9.192e-01  max|aij| =  1.088e+00  ratio =  1.183e+00
EQ: min|aij| =  8.450e-01  max|aij| =  1.000e+00  ratio =  1.183e+00
Crashing...
Size of triangular part = 1
       0: obj =   0.000000000e+00  infeas =  5.218e-02 (1)
*     1: obj =   0.000000000e+00  infeas =  0.000e+00 (0)
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (128573 bytes)

best linear fit is:
        y = 0.426126 + 0.610772x

Model has been successfully processed
address@hidden:~$

And using Qfit:

address@hidden:~$ /opt/glpk_4_35/bin/glpsol --math 
'/home/nigel/myGLPK/Qfit.mod'
Reading model section from /home/nigel/myGLPK/Qfit.mod...
Reading data section from /home/nigel/myGLPK/Qfit.mod...
49 lines were read
Generating equalz1...
Generating equalz2...
Generating equalz3...
Model has been successfully generated
glp_simplex: original LP has 3 rows, 3 columns, 9 non-zeros
glp_simplex: presolved LP has 3 rows, 3 columns, 9 non-zeros
Scaling...
  A: min|aij| =  1.900e+01  max|aij| =  3.321e+04  ratio =  1.748e+03
GM: min|aij| =  8.439e-01  max|aij| =  1.185e+00  ratio =  1.404e+00
EQ: min|aij| =  7.122e-01  max|aij| =  1.000e+00  ratio =  1.404e+00
Crashing...
Size of triangular part = 1
       0: obj =   0.000000000e+00  infeas =  1.694e-01 (2)
*     2: obj =   0.000000000e+00  infeas =  0.000e+00 (0)
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (136640 bytes)

best quadratic fit is:
        y = 1.103634 + 0.168031x + 0.045806x^2

Model has been successfully processed
address@hidden:~$

and using examples/cf12a.mod

address@hidden:~$ /opt/glpk_4_35/bin/glpsol --math 
'/home/nigel/myGLPK/glpk-4.35/examples/cf12a.mod'
Reading model section from /home/nigel/myGLPK/glpk-4.35/examples/cf12a.mod...
Reading data section from /home/nigel/myGLPK/glpk-4.35/examples/cf12a.mod...
81 lines were read
x = 0.0; y = 1.0
x = 0.5; y = 0.9
x = 1.0; y = 0.7
x = 1.5; y = 1.5
x = 1.9; y = 2.0
x = 2.5; y = 2.4
x = 3.0; y = 3.2
x = 3.5; y = 2.0
x = 4.0; y = 2.7
x = 4.5; y = 3.5
x = 5.0; y = 1.0
x = 5.5; y = 4.0
x = 6.0; y = 3.6
x = 6.6; y = 2.7
x = 7.0; y = 5.7
x = 7.6; y = 4.6
x = 8.5; y = 6.0
x = 9.0; y = 6.8
x = 10.0; y = 7.3
Generating error...
Generating equation...
Model has been successfully generated
glp_simplex: original LP has 20 rows, 40 columns, 113 non-zeros
glp_simplex: presolved LP has 19 rows, 21 columns, 56 non-zeros
Scaling...
  A: min|aij| =  5.000e-01  max|aij| =  1.000e+01  ratio =  2.000e+01
Problem data seem to be well scaled
Crashing...
Size of triangular part = 19
*     0: obj =   6.160000000e+01  infeas =  0.000e+00 (0)
*    11: obj =   1.146625000e+01  infeas =  0.000e+00 (0)
OPTIMAL SOLUTION FOUND
Time used:   0.0 secs
Memory used: 0.1 Mb (156072 bytes)
y = 0.6375x + 0.5813
Model has been successfully processed


-- 
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com

Powered by Outblaze

PNG image

Attachment: YACFS.mod
Description: Binary data

Attachment: Qfit.mod
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]