test_lbfgs.cc

00001 /* MLPACK 0.2
00002  *
00003  * Copyright (c) 2008, 2009 Alexander Gray,
00004  *                          Garry Boyer,
00005  *                          Ryan Riegel,
00006  *                          Nikolaos Vasiloglou,
00007  *                          Dongryeol Lee,
00008  *                          Chip Mappus, 
00009  *                          Nishant Mehta,
00010  *                          Hua Ouyang,
00011  *                          Parikshit Ram,
00012  *                          Long Tran,
00013  *                          Wee Chin Wong
00014  *
00015  * Copyright (c) 2008, 2009 Georgia Institute of Technology
00016  *
00017  * This program is free software; you can redistribute it and/or
00018  * modify it under the terms of the GNU General Public License as
00019  * published by the Free Software Foundation; either version 2 of the
00020  * License, or (at your option) any later version.
00021  *
00022  * This program is distributed in the hope that it will be useful, but
00023  * WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  * General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU General Public License
00028  * along with this program; if not, write to the Free Software
00029  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00030  * 02110-1301, USA.
00031  */
00032 /*
00033  * =====================================================================================
00034  *
00035  *       Filename:  test_lbfgs.cc
00036  *
00037  *    Description:  
00038  *
00039  *        Version:  1.0
00040  *        Created:  03/12/2008 01:27:16 PM EDT
00041  *       Revision:  none
00042  *       Compiler:  gcc
00043  *
00044  *         Author:  Nikolaos Vasiloglou (NV), nvasil@ieee.org
00045  *        Company:  Georgia Tech Fastlab-ESP Lab
00046  *
00047  * =====================================================================================
00048  */
00049 #include "lbfgs.h"
00050 #include "mlpack/mvu/mvu_objectives.h"
00051 #include <string>
00052 
00053 class LbfgsTest {
00054  public:
00055   LbfgsTest(){
00056     data_file_="swiss_roll_1000.csv";
00057   }
00058   void TestMaxVar1() {
00059     Matrix test_data;
00060     data::Load(data_file_.c_str(), &test_data);
00061     Lbfgs<MaxVariance> engine;
00062     MaxVariance opt_object;
00063     opt_object.Init(NULL, test_data);
00064     engine.Init(&opt_object, NULL);
00065     engine.ComputeLocalOptimumBFGS();
00066     Matrix results;
00067     engine.CopyCoordinates(&results);
00068     data::Save("max_var", results);
00069     engine.Destruct();
00070   }
00071   void TestMaxVar2() {
00072     /*
00073     Matrix test_data;
00074     data::Load(data_file_.c_str(), &test_data);
00075     Lbfgs<MaxVarianceInequalityOnFurthest> engine;
00076     MaxVarianceInequalityOnFurthest opt_object;
00077     opt_object.Init(NULL, test_data);
00078     engine.Init(&opt_object, NULL);
00079     engine.ComputeLocalOptimumBFGS();
00080     Matrix results;
00081     engine.CopyCoordinates(&results);
00082     data::Save("max_var_ineq", results);
00083     engine.Destruct();
00084     */
00085   }
00086   void TestMaxVar3() {
00087     Matrix test_data;
00088     data::Load(data_file_.c_str(), &test_data);
00089     Lbfgs<MaxFurthestNeighbors> engine;
00090     MaxFurthestNeighbors  opt_object;
00091     opt_object.Init(NULL, test_data);
00092     engine.Init(&opt_object, NULL);
00093     engine.ComputeLocalOptimumBFGS();
00094     Matrix results;
00095     engine.CopyCoordinates(&results);
00096     data::Save("max_furth", results);
00097     engine.Destruct();
00098   }
00099   void TestAll() {
00100    // TestMaxVar1();
00101    // TestMaxVar2();
00102     TestMaxVar3();
00103   }
00104    
00105  private:
00106   std::string data_file_;
00107 };
00108 
00109 int main(int argc, char *argv[]) {
00110   fx_init(argc, argv, NULL);
00111   LbfgsTest test;
00112   test.TestAll();
00113   fx_done(NULL);
00114 }
00115 
Generated on Mon Jan 24 12:04:37 2011 for FASTlib by  doxygen 1.6.3