GURLS++  2.0.00
C++ Implementation of GURLS Matlab Toolbox
rlsauto.h
00001 /*
00002   * The GURLS Package in C++
00003   *
00004   * Copyright (C) 2011-1013, IIT@MIT Lab
00005   * All rights reserved.
00006   *
00007   * authors:  M. Santoro
00008   * email:   msantoro@mit.edu
00009   * website: http://cbcl.mit.edu/IIT@MIT/IIT@MIT.html
00010   *
00011   * Redistribution and use in source and binary forms, with or without
00012   * modification, are permitted provided that the following conditions
00013   * are met:
00014   *
00015   *     * Redistributions of source code must retain the above
00016   *       copyright notice, this list of conditions and the following
00017   *       disclaimer.
00018   *     * Redistributions in binary form must reproduce the above
00019   *       copyright notice, this list of conditions and the following
00020   *       disclaimer in the documentation and/or other materials
00021   *       provided with the distribution.
00022   *     * Neither the name(s) of the copyright holders nor the names
00023   *       of its contributors or of the Massacusetts Institute of
00024   *       Technology or of the Italian Institute of Technology may be
00025   *       used to endorse or promote products derived from this software
00026   *       without specific prior written permission.
00027   *
00028   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00031   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00032   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00033   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00034   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00035   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00036   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00037   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00038   * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00039   * POSSIBILITY OF SUCH DAMAGE.
00040   */
00041 
00042 
00043 #ifndef _GURLS_RLSAUTO_H_
00044 #define _GURLS_RLSAUTO_H_
00045 
00046 #include "gurls++/optimization.h"
00047 #include "gurls++/linearkernel.h"
00048 
00049 
00050 namespace gurls {
00051 
00057 template <typename T>
00058 class RLSAuto: public Optimizer<T>{
00059 
00060 public:
00078     GurlsOptionsList *execute(const gMat2D<T>& X, const gMat2D<T>& Y, const GurlsOptionsList &opt);
00079 };
00080 
00081 template <typename T>
00082 GurlsOptionsList* RLSAuto<T>::execute(const gMat2D<T>& X, const gMat2D<T>& Y, const GurlsOptionsList& opt)
00083 {
00084     //[n,d] = size(X);
00085     const unsigned long n = X.rows();
00086     const unsigned long d = X.cols();
00087 
00088 //     if (n > d) % Do primal
00089     if(n > d)
00090     {
00091         //    cfr = rls_primal(X, y, opt);
00092         RLSPrimal<T> rlsprimal;
00093         return rlsprimal.execute(X, Y, opt);
00094     }
00095 //  else % Do dual
00096     else
00097     {
00098         //      cfr = rls_dual(X, y, opt);
00099         RLSDual<T> rlsdual;
00100 
00101         if(!opt.hasOpt("kernel.K"))
00102         {
00103             KernelLinear<T> kernelTask;
00104             GurlsOptionsList* kernel = kernelTask.execute(X, Y, opt);
00105 
00106             GurlsOptionsList tmp_opt("tmp");
00107 
00108             GurlsOptionsList* tmp_paramsel = new GurlsOptionsList("paramsel");
00109             tmp_paramsel->copyOpt("lambas", *(opt.getOptAs<GurlsOptionsList>("paramsel")));
00110             tmp_opt.addOpt("paramsel", tmp_paramsel);
00111 
00112             tmp_opt.copyOpt("singlelambda", opt);
00113 
00114             tmp_opt.addOpt("kernel", kernel);
00115 
00116             return rlsdual.execute(X, Y, tmp_opt);
00117         }
00118 
00119         return rlsdual.execute(X, Y, opt);
00120     }
00121 }
00122 
00123 }
00124 #endif // _GURLS_RLSAUTO_H_
00125 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends