Warning: this documentation for the development version is under construction.
00001 // Copyright (C) 2011 INRIA 00002 // Author(s): Marc Fragu 00003 // 00004 // This file is part of the linear-algebra library Seldon, 00005 // http://seldon.sourceforge.net/. 00006 // 00007 // Seldon is free software; you can redistribute it and/or modify it under the 00008 // terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 2.1 of the License, or (at your option) 00010 // any later version. 00011 // 00012 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY 00013 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00015 // more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with Seldon. If not, see http://www.gnu.org/licenses/. 00019 00020 00021 #ifndef SELDON_COMPUTATION_OPTIMIZATION_NLOPTSOLVER_HXX 00022 #define SELDON_COMPUTATION_OPTIMIZATION_NLOPTSOLVER_HXX 00023 00024 00025 #include "NLopt.hxx" 00026 00027 00028 namespace Seldon 00029 { 00030 00031 00033 // NLOPTSOLVER // 00035 00036 00038 class NLoptSolver 00039 { 00040 00041 protected: 00042 00043 typedef double (*cost_ptr)(const Vector<double>&, 00044 Vector<double>&, void*); 00045 00047 nlopt::SeldonOpt opt_; 00049 nlopt::algorithm algorithm_; 00051 double parameter_tolerance_; 00053 double cost_function_tolerance_; 00056 int Niteration_max_; 00060 Vector<double> parameter_; 00064 Vector<double> gradient_; 00066 double cost_; 00067 00068 public: 00069 // Constructor and destructor. 00070 NLoptSolver(); 00071 ~NLoptSolver(); 00072 00073 void Initialize(int Nparameter, string algorithm, 00074 double parameter_tolerance = 1.e-6, 00075 double cost_function_tolerance = 1.e-6, 00076 int Niteration_max = -1); 00077 void SetLowerBound(const Vector<double>&); 00078 void SetUpperBound(const Vector<double>&); 00079 void SetParameterTolerance(double); 00080 void SetCostFunctionTolerance(double); 00081 void SetNiterationMax(int); 00082 void GetParameterTolerance(double&) const; 00083 void GetCostFunctionTolerance(double&) const; 00084 void GetNiterationMax(int&) const; 00085 void SetParameter(const Vector<double>& parameter); 00086 void GetParameter(Vector<double>& parameter) const; 00087 void Optimize(cost_ptr cost, void* argument); 00088 double GetCost() const; 00089 00090 }; 00091 00092 00093 } // namespace Seldon. 00094 00095 00096 #endif