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

The first sentence should be a BRIEF DESCRIPTION of what the class does. More...

#include <RunICPVariable.h>

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

List of all members.

Public Member Functions

 RunICPVariable ()
 ### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!
 RunICPVariable (Variable *input)
 Constructor initializing from input variable.
void setScoreLayer (ScoreLayerVariable *the_score_layer)
 Set this variable's score layer.
void addTemplate (PP< ChemicalICP > icp_aligner, PP< Molecule > mol_template, Var mol_coordinates)
 Declare a new template.
VarArraygetPathsToResize (int i)
 Accessor to 'paths_to_resize[i]'.
virtual void recomputeSize (int &l, int &w) const
 Recomputes the length l and width w that this variable should have, according to its parent variables.
virtual void fprop ()
 Nothing to do by default.
virtual void bprop ()
 Nothing to do by default.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual RunICPVariabledeepCopy (CopiesMap &copies) const
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

Static Public Member Functions

static string _classname_ ()
 RunICPVariable.
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

TVec< PP< ChemicalICP > > icp_aligners
 The ICP aligners.

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares the class options.

Protected Attributes

TVec< PP< Molecule > > templates
 The molecule templates.
VarArray molecule_coordinates
 The i-th element is the variable that must contain the coordinates of the nearest points of the aligned molecule, after the i-th ICP alignement.
TVec< VarArraypaths_to_resize
 The i-th element is the propagation path from ICP variables to the score output for the i-th ICP.
ScoreLayerVariablescore_layer
 A ScoreLayerVariable that can give us a Molecule from an input id.

Private Types

typedef UnaryVariable inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

The first sentence should be a BRIEF DESCRIPTION of what the class does.

* RunICPVariable * Place the rest of the class programmer documentation here. Doxygen supports Javadoc-style comments. See http://www.doxygen.org/manual.html

Todo:
Write class to-do's here if there are any.
Deprecated:
Write deprecated stuff here if there is any. Indicate what else should be used instead.

Definition at line 65 of file RunICPVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 67 of file RunICPVariable.h.


Constructor & Destructor Documentation

PLearn::RunICPVariable::RunICPVariable ( )

### declare public option fields (such as build options) here Start your comments with Doxygen-compatible comments such as //!

Default constructor.

Definition at line 57 of file RunICPVariable.cc.

                              :
    score_layer(0)
{
}
PLearn::RunICPVariable::RunICPVariable ( Variable input)

Constructor initializing from input variable.

Definition at line 62 of file RunICPVariable.cc.

                                             :
    inherited(input, 0, 3),
    score_layer(0)
{}

Member Function Documentation

string PLearn::RunICPVariable::_classname_ ( ) [static]

RunICPVariable.

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

OptionList & PLearn::RunICPVariable::_getOptionList_ ( ) [static]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

RemoteMethodMap & PLearn::RunICPVariable::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

Object * PLearn::RunICPVariable::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

StaticInitializer RunICPVariable::_static_initializer_ & PLearn::RunICPVariable::_static_initialize_ ( ) [static]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

void PLearn::RunICPVariable::addTemplate ( PP< ChemicalICP icp_aligner,
PP< Molecule mol_template,
Var  mol_coordinates 
)

Declare a new template.

The 'mol_template' argument is a pointer to the template. The 'mol_coordinates' argument is a pointer to the variable that will be used to store the coordinates of the nearest points in the molecule, after ICP has been run.

Definition at line 70 of file RunICPVariable.cc.

References PLearn::TVec< T >::append(), icp_aligners, molecule_coordinates, PLearn::Variable::sizeprop(), and templates.

{
    icp_aligners.append(icp_aligner);
    templates.append(mol_template);
    molecule_coordinates.append(mol_coordinates);
    this->sizeprop(); // Resize this variable.
}

Here is the call graph for this function:

void PLearn::RunICPVariable::bprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 147 of file RunICPVariable.cc.

{
    // We do not backprop anything in this Variable.
}
void PLearn::RunICPVariable::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::UnaryVariable.

Definition at line 161 of file RunICPVariable.cc.

References PLearn::UnaryVariable::build(), and build_().

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::UnaryVariable.

Definition at line 211 of file RunICPVariable.cc.

Referenced by build().

{
    // ### This method should do the real building of the object,
    // ### according to set 'options', in *any* situation.
    // ### Typical situations include:
    // ###  - Initial building of an object from a few user-specified options
    // ###  - Building of a "reloaded" object: i.e. from the complete set of
    // ###    all serialised options.
    // ###  - Updating or "re-building" of an object after a few "tuning"
    // ###    options have been modified.
    // ### You should assume that the parent class' build_() has already been
    // ### called.
}

Here is the caller graph for this function:

string PLearn::RunICPVariable::classname ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

void PLearn::RunICPVariable::declareOptions ( OptionList ol) [static, protected]

Declares the class options.

Reimplemented from PLearn::UnaryVariable.

Definition at line 191 of file RunICPVariable.cc.

References PLearn::UnaryVariable::declareOptions().

{
    // ### Declare all of this object's options here.
    // ### For the "flags" of each option, you should typically specify
    // ### one of OptionBase::buildoption, OptionBase::learntoption or
    // ### OptionBase::tuningoption. If you don't provide one of these three,
    // ### this option will be ignored when loading values from a script.
    // ### You can also combine flags, for example with OptionBase::nosave:
    // ### (OptionBase::buildoption | OptionBase::nosave)

    // ### ex:
    // declareOption(ol, "myoption", &RunICPVariable::myoption,
    //               OptionBase::buildoption,
    //               "Help text describing this option");
    // ...

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

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

Reimplemented from PLearn::UnaryVariable.

Definition at line 124 of file RunICPVariable.h.

:

RunICPVariable * PLearn::RunICPVariable::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

void PLearn::RunICPVariable::fprop ( ) [virtual]

Nothing to do by default.

Reimplemented from PLearn::UnaryVariable.

Definition at line 105 of file RunICPVariable.cc.

References PLearn::ScoreLayerVariable::getMolecule(), i, icp_aligners, PLearn::UnaryVariable::input, PLearn::TMat< T >::length(), PLearn::TVec< T >::length(), PLearn::Variable::matValue, molecule_coordinates, PLearn::ScoreLayerVariable::normalize_by_n_features, paths_to_resize, PLASSERT, PLearn::productTranspose(), score_layer, PLearn::ScoreLayerVariable::setScalingCoefficient(), PLearn::TMat< T >::subMat(), and templates.

{
    PLASSERT( score_layer );
    // We obtain the molecule from the input variable.
    PP<Molecule> molecule = score_layer->getMolecule(input->value[0]);
    // Launch all ICPs.
    int index_coord = 0;
    for (int i = 0; i < icp_aligners.length(); i++) {
        // Run ICP.
        PP<ChemicalICP> icp = icp_aligners[i];
        PP<Molecule> template_mol = templates[i];
        icp->setMolecule(molecule);
        icp->run();
        // Modify score normalization coefficient if needed.
        if (score_layer->normalize_by_n_features)
            score_layer->setScalingCoefficient(i,
                real(1.0 / (template_mol->n_points() *
                            (3 + icp->used_template_features.width()))));
        // Some variables will need to be resized after ICP has been run.
        paths_to_resize[i].sizeprop();
        // Compute the aligned coordinates of the template and store them in
        // this variable.
        Mat template_coords =
            this->matValue.subMat(index_coord, 0, template_mol->n_points(), 3);
        index_coord += template_mol->n_points();
        productTranspose(template_coords, template_mol->coordinates,
                         icp->rotation);
        template_coords += icp->translation;
        // Obtain the coordinates of the nearest neighbors in the aligned
        // molecule.
        Mat molecule_coords = molecule_coordinates[i]->matValue;
        PLASSERT( molecule_coords.length() == template_mol->n_points() );
        for (int k = 0; k < template_mol->n_points(); k++) {
            int neighbor = icp->matching[k];
            molecule_coords(k) << molecule->coordinates(neighbor);
        }
    }
}

Here is the call graph for this function:

OptionList & PLearn::RunICPVariable::getOptionList ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

OptionMap & PLearn::RunICPVariable::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

VarArray & PLearn::RunICPVariable::getPathsToResize ( int  i)

Accessor to 'paths_to_resize[i]'.

Definition at line 228 of file RunICPVariable.cc.

References i, PLearn::TVec< T >::length(), paths_to_resize, and PLearn::TVec< T >::resize().

Referenced by PLearn::ScoreLayerVariable::build_().

{
    if (i >= paths_to_resize.length())
        paths_to_resize.resize(i + 1);
    return paths_to_resize[i];
}

Here is the call graph for this function:

Here is the caller graph for this function:

RemoteMethodMap & PLearn::RunICPVariable::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::UnaryVariable.

Definition at line 52 of file RunICPVariable.cc.

void PLearn::RunICPVariable::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::UnaryVariable.

Definition at line 167 of file RunICPVariable.cc.

References PLearn::deepCopyField(), icp_aligners, PLearn::UnaryVariable::makeDeepCopyFromShallowCopy(), molecule_coordinates, paths_to_resize, score_layer, and templates.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### Call deepCopyField on all "pointer-like" fields
    // ### that you wish to be deepCopied rather than
    // ### shallow-copied.
    // ### ex:
    // deepCopyField(trainvec, copies);
// To be deeped copied
    deepCopyField(icp_aligners, copies);
    deepCopyField(templates,copies);
    deepCopyField(molecule_coordinates,copies);
    deepCopyField(paths_to_resize, copies);
    deepCopyField(score_layer, copies);

    // ### If you want to deepCopy a Var field:
    // varDeepCopyField(somevariable, copies);


    // ### Remove this line when you have fully implemented this method.
        // PLERROR("RunICPVariable::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

void PLearn::RunICPVariable::recomputeSize ( int l,
int w 
) const [virtual]

Recomputes the length l and width w that this variable should have, according to its parent variables.

This is used for ex. by sizeprop() The default version stupidly returns the current dimensions, so make sure to overload it in subclasses if this is not appropriate.

Reimplemented from PLearn::Variable.

Definition at line 94 of file RunICPVariable.cc.

References i, PLearn::TVec< T >::length(), and templates.

{
    l = 0;
    for (int i = 0; i < templates.length(); i++)
        l += templates[i]->n_points();
    w = 3;
}

Here is the call graph for this function:

void PLearn::RunICPVariable::setScoreLayer ( ScoreLayerVariable the_score_layer)

Set this variable's score layer.

Definition at line 238 of file RunICPVariable.cc.

References score_layer.

{
    score_layer = the_score_layer;
}

Member Data Documentation

Reimplemented from PLearn::UnaryVariable.

Definition at line 124 of file RunICPVariable.h.

The ICP aligners.

Definition at line 72 of file RunICPVariable.h.

Referenced by addTemplate(), fprop(), and makeDeepCopyFromShallowCopy().

The i-th element is the variable that must contain the coordinates of the nearest points of the aligned molecule, after the i-th ICP alignement.

This variable is updated during fprop().

Definition at line 142 of file RunICPVariable.h.

Referenced by addTemplate(), fprop(), and makeDeepCopyFromShallowCopy().

The i-th element is the propagation path from ICP variables to the score output for the i-th ICP.

All variables in this propagation path are resized after the ICP has been run, in order to ensure the correctness of all sizes.

Definition at line 148 of file RunICPVariable.h.

Referenced by fprop(), getPathsToResize(), and makeDeepCopyFromShallowCopy().

A ScoreLayerVariable that can give us a Molecule from an input id.

This is a raw C++ pointer to avoid PP cycles.

Definition at line 159 of file RunICPVariable.h.

Referenced by fprop(), makeDeepCopyFromShallowCopy(), and setScoreLayer().

The molecule templates.

Definition at line 136 of file RunICPVariable.h.

Referenced by addTemplate(), fprop(), makeDeepCopyFromShallowCopy(), and recomputeSize().


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