PLearn 0.1
|
Exercises the Conjugate Gradient optimizer through the Rosenbrock Function. More...
#include <ConjRosenbrock.h>
Public Member Functions | |
ConjRosenbrock () | |
Default constructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual ConjRosenbrock * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual void | perform () |
The method performing the test. | |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
PP< Optimizer > | opt |
Optimizer to use, with options. | |
int | D |
Dimensionality of the Rosenbrock problem to solve. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares the class options. | |
Private Types | |
typedef PTest | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Exercises the Conjugate Gradient optimizer through the Rosenbrock Function.
Definition at line 50 of file ConjRosenbrock.h.
typedef PTest PLearn::ConjRosenbrock::inherited [private] |
Reimplemented from PLearn::PTest.
Definition at line 52 of file ConjRosenbrock.h.
PLearn::ConjRosenbrock::ConjRosenbrock | ( | ) |
string PLearn::ConjRosenbrock::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
OptionList & PLearn::ConjRosenbrock::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
RemoteMethodMap & PLearn::ConjRosenbrock::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
Object * PLearn::ConjRosenbrock::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
StaticInitializer ConjRosenbrock::_static_initializer_ & PLearn::ConjRosenbrock::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
void PLearn::ConjRosenbrock::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::PTest.
Definition at line 95 of file ConjRosenbrock.cc.
References PLearn::PTest::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::ConjRosenbrock::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::PTest.
Definition at line 136 of file ConjRosenbrock.cc.
Referenced by build().
string PLearn::ConjRosenbrock::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
void PLearn::ConjRosenbrock::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares the class options.
Reimplemented from PLearn::PTest.
Definition at line 121 of file ConjRosenbrock.cc.
References PLearn::OptionBase::buildoption, D, PLearn::declareOption(), PLearn::PTest::declareOptions(), and opt.
{ declareOption(ol, "opt", &ConjRosenbrock::opt, OptionBase::buildoption, "Optimizer to use, with options."); declareOption(ol, "D", &ConjRosenbrock::D, OptionBase::buildoption, "Dimensionality of the Rosenbrock problem to solve"); // Now call the parent class' declareOptions inherited::declareOptions(ol); }
static const PPath& PLearn::ConjRosenbrock::declaringFile | ( | ) | [inline, static] |
ConjRosenbrock * PLearn::ConjRosenbrock::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
OptionList & PLearn::ConjRosenbrock::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
OptionMap & PLearn::ConjRosenbrock::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
RemoteMethodMap & PLearn::ConjRosenbrock::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::PTest.
Definition at line 83 of file ConjRosenbrock.cc.
void PLearn::ConjRosenbrock::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::PTest.
Definition at line 104 of file ConjRosenbrock.cc.
References PLearn::PTest::makeDeepCopyFromShallowCopy(), and PLERROR.
{ inherited::makeDeepCopyFromShallowCopy(copies); // ### Call deepCopyField on all "pointer-like" fields // ### that you wish to be deepCopied rather than // ### shallow-copied. // ### ex: // deepCopyField(trainvec, copies); // ### Remove this line when you have fully implemented this method. PLERROR("ConjRosenbrock::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!"); }
void PLearn::ConjRosenbrock::perform | ( | ) | [virtual] |
The method performing the test.
A typical test consists in some output (to pout and / or perr), and updates of this object's options.
Reimplemented from PLearn::PTest.
Definition at line 145 of file ConjRosenbrock.cc.
References D, PLearn::PL_Log::enableNamedLogging(), PLearn::endl(), PLearn::TVec< T >::fill(), PLearn::PL_Log::instance(), opt, PLearn::pout, PLearn::rosenbrock(), PLearn::PL_Log::verbosity(), and PLearn::VLEVEL_DBG.
{ // Change verbosity PL_Log::instance().verbosity(VLEVEL_DBG); PL_Log::instance().enableNamedLogging( "Optimizer,GradientOptimizer,ConjGradientOptimizer"); // Set up the Rosenbrock problem Func r = rosenbrock(D); Vec input(D); // Initialized to 0.0 pout << "rosenbrock(" << input << ") = " << r(input) << endl; r->verifyGradient(input,1e-6); // Check gradient at 0^D input.fill(1.0); r->verifyGradient(input,1e-6); // Check gradient at 1^D // r->verifyGradient(-1,1,1e-6); // Check gradient at random point // Set up the optimizer and go r->inputs[0]->value.fill(0.0); opt->reset(); opt->setToOptimize(r->inputs, r->outputs); opt->build(); VecStatsCollector vsc; opt->optimizeN(vsc); // Print information pout << "\nAfter optimization:" << "\ninputs = " << r->inputs[0]->value << "\noutput = " << r->outputs[0]->value << "\n\nOptimization stats collector: " << vsc; }
Reimplemented from PLearn::PTest.
Definition at line 73 of file ConjRosenbrock.h.
Dimensionality of the Rosenbrock problem to solve.
Definition at line 61 of file ConjRosenbrock.h.
Referenced by declareOptions(), and perform().
Optimizer to use, with options.
Definition at line 58 of file ConjRosenbrock.h.
Referenced by build_(), declareOptions(), and perform().