summaryrefslogtreecommitdiff
path: root/glpk-5.0/examples/qfit.mod
diff options
context:
space:
mode:
authorPasha <pasha@member.fsf.org>2023-01-27 00:54:07 +0000
committerPasha <pasha@member.fsf.org>2023-01-27 00:54:07 +0000
commitef800d4ffafdbde7d7a172ad73bd984b1695c138 (patch)
tree920cc189130f1e98f252283fce94851443641a6d /glpk-5.0/examples/qfit.mod
parentec4ae3c2b5cb0e83fb667f14f832ea94f68ef075 (diff)
downloadoneapi-master.tar.gz
oneapi-master.tar.bz2
simplex-glpk with modified glpk for fpgaHEADmaster
Diffstat (limited to 'glpk-5.0/examples/qfit.mod')
-rw-r--r--glpk-5.0/examples/qfit.mod49
1 files changed, 49 insertions, 0 deletions
diff --git a/glpk-5.0/examples/qfit.mod b/glpk-5.0/examples/qfit.mod
new file mode 100644
index 0000000..f168c4b
--- /dev/null
+++ b/glpk-5.0/examples/qfit.mod
@@ -0,0 +1,49 @@
+/*Quadratic Curve Fitting Solution
+
+ Find a plausable quadratic fit to a sample of points
+
+ Nigel_Galloway@operamail.com
+ February 1st., 2009
+*/
+set Sample;
+param Sx {z in Sample};
+param Sy {z in Sample};
+
+var a;
+var b;
+var c;
+
+equalz1 :sum{z in Sample} a*Sx[z]*Sx[z]*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z]*Sx[z]*Sx[z] + sum{z in Sample} c*Sx[z]*Sx[z] = sum{z in Sample} Sy[z]*Sx[z]*Sx[z];
+equalz2 :sum{z in Sample} a*Sx[z]*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z]*Sx[z] + sum{z in Sample} c*Sx[z] = sum{z in Sample} Sy[z]*Sx[z];
+equalz3 :sum{z in Sample} a*Sx[z]*Sx[z] + sum{z in Sample} b*Sx[z] + sum{z in Sample} c = sum{z in Sample} Sy[z];
+
+solve;
+
+printf "\nbest quadratic fit is:\n\ty = %f %s %fx %s %fx^2\n\n", c, if b < 0 then "-" else "+", abs(b), if a < 0 then "-" else "+", abs(a);
+
+data;
+
+param:
+Sample: Sx Sy :=
+ 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;