[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN Makefile.in numdiff.awk test/simplex_view....
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN Makefile.in numdiff.awk test/simplex_view.... |
Date: |
Wed, 21 Oct 2009 12:35:08 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/10/21 12:35:08
Modified files:
. : Makefile.in numdiff.awk
test : simplex_view.gnuplot
Added files:
regressions : simplex.cc simplex.txt
Removed files:
test : gauss_jordan.cc resize_test.cc
Log message:
Added Downhill Simplex regression test.
- Added test.
- Removved some old tests.
- Update regression framework to ignore blocks of text.
- Add bounds checking to regression builds.
Regression test fails for variable size.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/Makefile.in?cvsroot=toon&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/TooN/numdiff.awk?cvsroot=toon&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/simplex.cc?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/simplex.txt?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/test/simplex_view.gnuplot?cvsroot=toon&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/TooN/test/gauss_jordan.cc?cvsroot=toon&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/TooN/test/resize_test.cc?cvsroot=toon&r1=1.2&r2=0
Patches:
Index: Makefile.in
===================================================================
RCS file: /cvsroot/toon/TooN/Makefile.in,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- Makefile.in 19 Oct 2009 14:08:52 -0000 1.17
+++ Makefile.in 21 Oct 2009 12:35:06 -0000 1.18
@@ -36,7 +36,7 @@
doxygen
-TESTS=lu slice vector_resize gauss_jordan eigen-sqrt determinant chol_toon
chol_lapack
+TESTS=lu slice vector_resize gauss_jordan eigen-sqrt determinant chol_toon
chol_lapack simplex
TEST_RESULT=$(TESTS:%=regressions/%.result)
@@ -60,7 +60,7 @@
#Build a test executable from a test program. On compile error,
#create an execuaable which decalres the error.
regressions/%.test: regressions/%.cc
- $(CXX) -I. $< -o $@ -llapack -DTOON_INITIALIZE_SNAN -I .. -I . ||\
+ $(CXX) -I. $< -o $@ -llapack -DTOON_CHECK_BOUNDS -DTOON_INITIALIZE_SNAN
-I .. -I . ||\
{ \
echo "echo 'Compile error!'" > $@ ; \
chmod +x $@; \
Index: numdiff.awk
===================================================================
RCS file: /cvsroot/toon/TooN/numdiff.awk,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- numdiff.awk 28 Sep 2009 10:48:13 -0000 1.3
+++ numdiff.awk 21 Oct 2009 12:35:06 -0000 1.4
@@ -18,13 +18,17 @@
split(line, a)
if(a[2] == "t")
t = a[3]
+ else if(a[2] == "ignore")
+ ignore++
+ else if(a[2] == "resume")
+ ignore--
return 1
}
else if (line ~ /^[[:space:]]*#/) #Ignore comments
return 1
else #The line should not be ignored
- return 0
+ return (ignore != 0)
}
BEGIN{
@@ -38,6 +42,10 @@
#Lines starting with #> are directives and are processed further
#Directives are
# #> t xx Set t to xx
+ # #> ignore Start ignoring text (nestable)
+ # #> resume Stop ignoring text
+
+ ignore=0
if(t == "")
t = 1e-6
Index: test/simplex_view.gnuplot
===================================================================
RCS file: /cvsroot/toon/TooN/test/simplex_view.gnuplot,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- test/simplex_view.gnuplot 27 May 2009 13:17:22 -0000 1.1
+++ test/simplex_view.gnuplot 21 Oct 2009 12:35:07 -0000 1.2
@@ -12,7 +12,7 @@
splot [-2:2] [-2:2] sin(20*sqrt(x**2 + y**2) + atan(y/x)*2) + 1*(x**2 + y**2)
unset pm3d
set surface
-splot [-2:2] [-2:2] '< ./simplex_test' using 1:2:3 with linespoints title
'Conjugate Gradient path'
+splot [-2:2] [-2:2] '< regressions/simplex.test' using 1:2:3 with linespoints
title 'Simplex path'
unset multiplot
Index: regressions/simplex.cc
===================================================================
RCS file: regressions/simplex.cc
diff -N regressions/simplex.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regressions/simplex.cc 21 Oct 2009 12:35:07 -0000 1.1
@@ -0,0 +1,55 @@
+#include <TooN/optimization/downhill_simplex.h>
+#include <iomanip>
+using namespace std;
+using namespace TooN;
+
+
+double sq(double x)
+{
+ return x*x;
+}
+
+double Rosenbrock(const Vector<2>& v)
+{
+ return sq(1 - v[0]) + 100 * sq(v[1] - sq(v[0]));
+}
+
+double Spiral(const Vector<2>& v)
+{
+ double x = v[0];
+ double y = v[1];
+ return sin(20.0*sqrt(x*x+y*y)+2.0*atan(y/x))+2.0*x*x+2.0*y*y;
+}
+
+
+int main()
+{
+ cout << setprecision(16);
+ Vector<2> starting_point = makeVector(1.5, 1.5);
+
+ DownhillSimplex<2> dh_fixed(Spiral, starting_point, .001);
+
+ cout << "#> ignore" << endl;
+
+ while(dh_fixed.iterate(Spiral))
+ {
+ cout << dh_fixed.get_simplex()[0] << dh_fixed.get_values()[0]
<< endl;
+ cout << dh_fixed.get_simplex()[1] << dh_fixed.get_values()[1]
<< endl;
+ cout << dh_fixed.get_simplex()[2] << dh_fixed.get_values()[2]
<< endl;
+ cout << endl;
+ }
+
+ cout << "#> resume" << endl;
+
+ cout << dh_fixed.get_simplex()[dh_fixed.get_best()] << endl
+ << dh_fixed.get_values()[dh_fixed.get_best()] << endl;
+
+ DownhillSimplex<> dh_variable(Spiral, starting_point, .001);
+
+ while(dh_variable.iterate(Spiral))
+
+ cout << dh_variable.get_simplex()[dh_variable.get_best()] << endl
+ << dh_variable.get_values()[dh_variable.get_best()] << endl;
+}
+
+
Index: regressions/simplex.txt
===================================================================
RCS file: regressions/simplex.txt
diff -N regressions/simplex.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ regressions/simplex.txt 21 Oct 2009 12:35:07 -0000 1.1
@@ -0,0 +1,10 @@
+#The minimm is at f(0, 0) = -1
+#> t 1e-7
+
+#Fixed sized solver
+0 0
+-1
+
+#Variable sized solver
+0 0
+-1
Index: test/gauss_jordan.cc
===================================================================
RCS file: test/gauss_jordan.cc
diff -N test/gauss_jordan.cc
--- test/gauss_jordan.cc 20 Mar 2009 18:24:29 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,34 +0,0 @@
-#include <TooN/gauss_jordan.h>
-#include <TooN/helpers.h>
-#include <tr1/random>
-#include <fstream>
-
-using namespace TooN;
-using namespace std;
-using namespace tr1;
-
-int main()
-{
- unsigned int s;
- ifstream("/dev/urandom").read((char*)&s, 4);
-
- std::tr1::mt19937 eng;
- std::tr1::uniform_real<double> rnd;
- eng.seed(s);
- Matrix<5,10> m, reduced;
-
- for(int i=0; i< m.num_rows(); i++)
- for(int j=0; j< m.num_rows(); j++)
- m[i][j] = rnd(eng);
-
- m.slice<0, 5, 5, 5>() = Identity;
-
- cout << m << endl;
-
-
- reduced = m;
- gauss_jordan(reduced);
-
- cout << reduced.slice<0,5,5,5>() * m.slice<0,0,5,5>() << endl;
-
-}
Index: test/resize_test.cc
===================================================================
RCS file: test/resize_test.cc
diff -N test/resize_test.cc
--- test/resize_test.cc 28 Sep 2009 08:31:58 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-#include <TooN/TooN.h>
-using namespace std;
-using namespace TooN;
-
-int main()
-{
- Vector<Resizable> r = makeVector(4);
- Vector<> v1(makeVector(1, 2));
-
- cout << r << endl;
-
- r.resize(v1.size());
- r = v1;
- cout << r << endl;
- Vector<3> v2 = makeVector(2, 3, 4);
- r.resize(3);
- r = v2;
- cout << r << endl;
-
- r.resize(10);
- r = Ones;
-
- cout << r << endl;
-
- r.resize(5);
- r = makeVector(6, 7, 8, 9, 0);
- cout << r << endl;
-
- r.resize(2);
- r[0]= 5;
- r[1] = 6;
-
- cout << r << endl;
-
-
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN Makefile.in numdiff.awk test/simplex_view....,
Edward Rosten <=