![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
00001 /* 00002 * The GURLS Package in C++ 00003 * 00004 * Copyright (C) 2011-1013, IIT@MIT Lab 00005 * All rights reserved. 00006 * 00007 * author: 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_PARAMSEL_H_ 00044 #define _GURLS_PARAMSEL_H_ 00045 00046 #include <cstdio> 00047 #include <cstring> 00048 #include <iostream> 00049 #include <cmath> 00050 #include <algorithm> 00051 00052 00053 #include "gurls++/options.h" 00054 #include "gurls++/optlist.h" 00055 #include "gurls++/gmat2d.h" 00056 #include "gurls++/gvec.h" 00057 #include "gurls++/gmath.h" 00058 #include "gurls++/exceptions.h" 00059 00060 namespace gurls 00061 { 00062 00063 template <typename T> 00064 class ParamSelLoocvPrimal; 00065 00066 template <typename T> 00067 class ParamSelLoocvDual; 00068 00069 template <typename T> 00070 class ParamSelFixLambda; 00071 00072 template <typename T> 00073 class ParamSelFixSigLam; 00074 00075 template <typename T> 00076 class ParamSelCalibrateSGD; 00077 00078 template <typename T> 00079 class ParamSelSiglam; 00080 00081 template <typename T> 00082 class ParamSelSiglamHo; 00083 00084 template <typename T> 00085 class ParamSelHoPrimal; 00086 00087 template <typename T> 00088 class ParamSelHoPrimalr; 00089 00090 template <typename T> 00091 class ParamSelHoDual; 00092 00093 template <typename T> 00094 class ParamSelHoDualr; 00095 00096 template <typename T> 00097 class ParamSelLooGPRegr; 00098 00099 template <typename T> 00100 class ParamSelHoGPRegr; 00101 00102 template <typename T> 00103 class ParamSelSiglamLooGPRegr; 00104 00105 template <typename T> 00106 class ParamSelSiglamHoGPRegr; 00107 00113 class BadParamSelectionCreation : public gException 00114 { 00115 public: 00119 BadParamSelectionCreation(std::string type): gException("Cannot create type " + type) {} 00120 }; 00121 00126 template <typename T> 00127 class ParamSelection 00128 { 00129 public: 00130 00138 virtual GurlsOptionsList* execute(const gMat2D<T>& X, const gMat2D<T>& Y, const GurlsOptionsList& opt) = 0; 00139 00146 static ParamSelection<T>* factory(const std::string& id) throw(BadParamSelectionCreation) 00147 { 00148 if(id == "loocvprimal") 00149 return new ParamSelLoocvPrimal<T>; 00150 if(id == "loocvdual") 00151 return new ParamSelLoocvDual<T>; 00152 if(id == "fixlambda") 00153 return new ParamSelFixLambda<T>; 00154 if(id == "calibratesgd") 00155 return new ParamSelCalibrateSGD<T>; 00156 if(id == "siglam") 00157 return new ParamSelSiglam<T>; 00158 if(id == "siglamho") 00159 return new ParamSelSiglamHo<T>; 00160 if(id == "hodual") 00161 return new ParamSelHoDual<T>; 00162 if(id == "hodualr") 00163 return new ParamSelHoDualr<T>; 00164 if(id == "hoprimal") 00165 return new ParamSelHoPrimal<T>; 00166 if(id == "hoprimalr") 00167 return new ParamSelHoPrimalr<T>; 00168 if(id == "fixsiglam") 00169 return new ParamSelFixSigLam<T>; 00170 if(id == "loogpregr") 00171 return new ParamSelLooGPRegr<T>; 00172 if(id == "hogpregr") 00173 return new ParamSelHoGPRegr<T>; 00174 if(id == "siglamloogpregr") 00175 return new ParamSelSiglamLooGPRegr<T>; 00176 if(id == "siglamhogpregr") 00177 return new ParamSelSiglamHoGPRegr<T>; 00178 00179 throw BadParamSelectionCreation(id); 00180 } 00181 }; 00182 00183 } 00184 00185 #endif // _GURLS_PARAMSEL_H_