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

#include <ArgminOfVariable.h>

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

List of all members.

Public Member Functions

 ArgminOfVariable (Variable *the_v, Variable *the_expression, Variable *the_values_of_v, const VarArray &the_inputs)
 ArgminOfVariable.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual ArgminOfVariabledeepCopy (CopiesMap &copies) const
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 makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
virtual void fprop ()
 compute output given input
virtual void bprop ()

Static Public Member Functions

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

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

 ArgminOfVariable ()
 protected default constructor for persistence

Protected Attributes

VarArray inputs
Var expression
Var values_of_v
Var v
int index_of_argmin
VarArray vv_path
 values_of_v(inputs)
VarArray e_path
 expression(v&inputs)
VarArray v_path
 expression(v)

Private Types

typedef NaryVariable inherited

Detailed Description

returns the value of v within the_values_of_v that gives the lowest value of expression (which may depend on inputs).

Definition at line 54 of file ArgminOfVariable.h.


Member Typedef Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 57 of file ArgminOfVariable.h.


Constructor & Destructor Documentation

PLearn::ArgminOfVariable::ArgminOfVariable ( ) [inline, protected]

protected default constructor for persistence

Definition at line 61 of file ArgminOfVariable.h.

PLearn::ArgminOfVariable::ArgminOfVariable ( Variable the_v,
Variable the_expression,
Variable the_values_of_v,
const VarArray the_inputs 
)

ArgminOfVariable.

Definition at line 52 of file ArgminOfVariable.cc.

References e_path, expression, inputs, PLERROR, PLearn::propagationPath(), v, v_path, values_of_v, and vv_path.

    :NaryVariable(the_inputs,1,1), inputs(the_inputs), expression(the_expression),
     values_of_v(the_values_of_v), v(the_v)
{
    if (!v->isScalar() || !values_of_v->isVec())
        PLERROR("ArgminOfVariable currently implemented only for a scalar v and a vector values_of_v");
    vv_path = propagationPath(inputs,values_of_v);
    e_path = propagationPath(inputs& (VarArray)v, expression);
    v_path = propagationPath(v, expression);
}

Here is the call graph for this function:


Member Function Documentation

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

NaryVariable.

Reimplemented from PLearn::NaryVariable.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 67 of file ArgminOfVariable.cc.

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

Implements PLearn::Variable.

Definition at line 111 of file ArgminOfVariable.cc.

References PLearn::VarArray::bprop(), PLearn::VarArray::clearGradient(), PLearn::Variable::gradientdata, index_of_argmin, values_of_v, and vv_path.

{
    vv_path.clearGradient();
    values_of_v->gradientdata[index_of_argmin] = gradientdata[0];
    vv_path.bprop();
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 80 of file ArgminOfVariable.h.

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

Reimplemented from PLearn::NaryVariable.

Definition at line 67 of file ArgminOfVariable.cc.

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

compute output given input

Implements PLearn::Variable.

Definition at line 87 of file ArgminOfVariable.cc.

References e_path, expression, PLearn::VarArray::fprop(), i, index_of_argmin, v, v_path, PLearn::Variable::value, values_of_v, and vv_path.

{
    vv_path.fprop(); // compute influence of inputs on values_of_v
    real min_value_of_expression = FLT_MAX;
    real argmin_value_of_v = values_of_v->value[0];
    for (int i=0;i<values_of_v->nelems();i++)
    {
        v->value[0] = values_of_v->value[i];
        if (i==0)
            e_path.fprop(); // compute influence of v and inputs on expression
        else
            v_path.fprop(); // otherwise, keep influence of inputs fixed
        real e = expression->value[0];
        if (e<min_value_of_expression)
        {
            min_value_of_expression = e;
            argmin_value_of_v = v->value[0];
            index_of_argmin = i;
        }
    }
    value[0] = argmin_value_of_v;
}

Here is the call graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 67 of file ArgminOfVariable.cc.

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

Reimplemented from PLearn::Object.

Definition at line 67 of file ArgminOfVariable.cc.

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

Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.

This needs to be overridden by every class that adds "complex" data members to the class, such as Vec, Mat, PP<Something>, etc. Typical implementation:

  void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies)
  {
      inherited::makeDeepCopyFromShallowCopy(copies);
      deepCopyField(complex_data_member1, copies);
      deepCopyField(complex_data_member2, copies);
      ...
  }
Parameters:
copiesA map used by the deep-copy mechanism to keep track of already-copied objects.

Reimplemented from PLearn::NaryVariable.

Definition at line 73 of file ArgminOfVariable.cc.

References PLearn::deepCopyField(), e_path, expression, inputs, PLearn::NaryVariable::makeDeepCopyFromShallowCopy(), v, v_path, values_of_v, and vv_path.

Here is the call graph for this function:

void PLearn::ArgminOfVariable::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 69 of file ArgminOfVariable.cc.

{ l=1; w=1; }

Member Data Documentation

Reimplemented from PLearn::NaryVariable.

Definition at line 80 of file ArgminOfVariable.h.

expression(v&inputs)

Definition at line 72 of file ArgminOfVariable.h.

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

Definition at line 66 of file ArgminOfVariable.h.

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

Definition at line 69 of file ArgminOfVariable.h.

Referenced by bprop(), and fprop().

Definition at line 65 of file ArgminOfVariable.h.

Referenced by ArgminOfVariable(), and makeDeepCopyFromShallowCopy().

Definition at line 68 of file ArgminOfVariable.h.

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

expression(v)

Definition at line 73 of file ArgminOfVariable.h.

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

Definition at line 67 of file ArgminOfVariable.h.

Referenced by ArgminOfVariable(), bprop(), fprop(), and makeDeepCopyFromShallowCopy().

values_of_v(inputs)

Definition at line 71 of file ArgminOfVariable.h.

Referenced by ArgminOfVariable(), bprop(), fprop(), and makeDeepCopyFromShallowCopy().


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