PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::ConjRosenbrock Class Reference

Exercises the Conjugate Gradient optimizer through the Rosenbrock Function. More...

#include <ConjRosenbrock.h>

Inheritance diagram for PLearn::ConjRosenbrock:
Inheritance graph
[legend]
Collaboration diagram for PLearn::ConjRosenbrock:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ConjRosenbrock ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ConjRosenbrockdeepCopy (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 PPathdeclaringFile ()

Public Attributes

PP< Optimizeropt
 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.

Detailed Description

Exercises the Conjugate Gradient optimizer through the Rosenbrock Function.

Definition at line 50 of file ConjRosenbrock.h.


Member Typedef Documentation

Reimplemented from PLearn::PTest.

Definition at line 52 of file ConjRosenbrock.h.


Constructor & Destructor Documentation

PLearn::ConjRosenbrock::ConjRosenbrock ( )

Default constructor.

Definition at line 88 of file ConjRosenbrock.cc.

    : D(2)
{ }

Member Function Documentation

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.

bool PLearn::ConjRosenbrock::_isa_ ( const Object o) [static]

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_().

Here is the call graph for this function:

void PLearn::ConjRosenbrock::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::PTest.

Definition at line 136 of file ConjRosenbrock.cc.

References opt, and PLERROR.

Referenced by build().

{
    if (! opt)
        PLERROR("%s: the 'opt' option must be specified", __FUNCTION__);
}

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

static const PPath& PLearn::ConjRosenbrock::declaringFile ( ) [inline, static]

Reimplemented from PLearn::PTest.

Definition at line 73 of file ConjRosenbrock.h.

:
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!");
}

Here is the call graph for this function:

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;
    
}

Here is the call graph for this function:


Member Data Documentation

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines