PLearn 0.1
|
#include <OracleObjectGenerator.h>
Public Member Functions | |
OracleObjectGenerator () | |
Default constructor. | |
virtual PP< Object > | generateNextObject () |
This will generate the next object in the list of all options MUST be define by a subclass. | |
virtual void | build () |
This will generate a list of all possible Objects. | |
virtual void | forget () |
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 string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual OracleObjectGenerator * | deepCopy (CopiesMap &copies) const |
Static Public Member Functions | |
static string | _classname_ () |
Declares name and deepCopy methods. | |
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< OptionsOracle > | oracle |
The template Object from which we will generate other Objects. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declare options (data fields) for the class. | |
Protected Attributes | |
TVec< string > | last_params |
The last parameters returned by the oracle. | |
Private Types | |
typedef ObjectGenerator | inherited |
Private Member Functions | |
void | build_ () |
Object-specific post-constructor. |
Definition at line 51 of file OracleObjectGenerator.h.
typedef ObjectGenerator PLearn::OracleObjectGenerator::inherited [private] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 54 of file OracleObjectGenerator.h.
PLearn::OracleObjectGenerator::OracleObjectGenerator | ( | ) |
string PLearn::OracleObjectGenerator::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::ObjectGenerator.
Definition at line 47 of file OracleObjectGenerator.cc.
OptionList & PLearn::OracleObjectGenerator::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 47 of file OracleObjectGenerator.cc.
RemoteMethodMap & PLearn::OracleObjectGenerator::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 47 of file OracleObjectGenerator.cc.
Reimplemented from PLearn::ObjectGenerator.
Definition at line 47 of file OracleObjectGenerator.cc.
Object * PLearn::OracleObjectGenerator::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 47 of file OracleObjectGenerator.cc.
StaticInitializer OracleObjectGenerator::_static_initializer_ & PLearn::OracleObjectGenerator::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 47 of file OracleObjectGenerator.cc.
void PLearn::OracleObjectGenerator::build | ( | ) | [virtual] |
This will generate a list of all possible Objects.
By default, just loop over generateNextObject() simply calls inherited::build() then build_()
Reimplemented from PLearn::ObjectGenerator.
Definition at line 62 of file OracleObjectGenerator.cc.
{ inherited::build(); build_(); }
void PLearn::OracleObjectGenerator::build_ | ( | ) | [private] |
Object-specific post-constructor.
This method should be redefined in subclasses and do the actual building of the object according to previously set option fields. Constructors can just set option fields, and then call build_. This method is NOT virtual, and will typically be called only from three places: a constructor, the public virtual build()
method, and possibly the public virtual read method (which calls its parent's read). build_()
can assume that its parent's build_()
has already been called.
Reimplemented from PLearn::ObjectGenerator.
Definition at line 53 of file OracleObjectGenerator.cc.
References PLERROR.
{ if (oracle.isNull()) PLERROR("An OracleObjectGenerator MUST contain an oracle (an OptionsOracle)."); oracle->build(); last_params.resize(0); }
string PLearn::OracleObjectGenerator::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 47 of file OracleObjectGenerator.cc.
void PLearn::OracleObjectGenerator::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption
(...) for each option, and then call inherited::declareOptions(options)
. Please call the inherited
method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
ol | List of options that is progressively being constructed for the current class. |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 75 of file OracleObjectGenerator.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), last_params, PLearn::OptionBase::learntoption, and oracle.
{ declareOption(ol, "oracle", &OracleObjectGenerator::oracle, OptionBase::buildoption, "The OptionsOracle used to generate the new Object parameters. \n"); declareOption(ol,"last_params", &OracleObjectGenerator::last_params, OptionBase::learntoption, "The last parameter returned by the oracle. \n"); inherited::declareOptions(ol); }
static const PPath& PLearn::OracleObjectGenerator::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 98 of file OracleObjectGenerator.h.
OracleObjectGenerator * PLearn::OracleObjectGenerator::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 47 of file OracleObjectGenerator.cc.
void PLearn::OracleObjectGenerator::forget | ( | ) | [virtual] |
Reimplemented from PLearn::ObjectGenerator.
Definition at line 68 of file OracleObjectGenerator.cc.
{ inherited::forget(); oracle->forget(); last_params.resize(0); }
This will generate the next object in the list of all options MUST be define by a subclass.
Implements PLearn::ObjectGenerator.
Definition at line 87 of file OracleObjectGenerator.cc.
References i, and PLearn::TVec< T >::size().
{ PP<Object> next_obj; TVec<string> new_params = generation_began ? oracle->generateNextTrial(last_params, FLT_MAX) : oracle->generateFirstTrial(); if (new_params.size() > 0) { CopiesMap copies; next_obj = template_object->deepCopy(copies); TVec<string> option_names = oracle->getOptionNames(); for (int i=0; i<option_names.size(); i++) { next_obj->setOption(option_names[i], new_params[i]); } next_obj->build(); } last_params = new_params; generation_began = true; return next_obj; }
OptionList & PLearn::OracleObjectGenerator::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 47 of file OracleObjectGenerator.cc.
OptionMap & PLearn::OracleObjectGenerator::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 47 of file OracleObjectGenerator.cc.
RemoteMethodMap & PLearn::OracleObjectGenerator::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 47 of file OracleObjectGenerator.cc.
void PLearn::OracleObjectGenerator::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); ... }
copies | A map used by the deep-copy mechanism to keep track of already-copied objects. |
Reimplemented from PLearn::Object.
Definition at line 111 of file OracleObjectGenerator.cc.
References PLearn::deepCopyField().
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(last_params, copies); }
Reimplemented from PLearn::ObjectGenerator.
Definition at line 98 of file OracleObjectGenerator.h.
TVec<string> PLearn::OracleObjectGenerator::last_params [protected] |
The last parameters returned by the oracle.
Definition at line 59 of file OracleObjectGenerator.h.
Referenced by declareOptions().
The template Object from which we will generate other Objects.
Definition at line 64 of file OracleObjectGenerator.h.
Referenced by declareOptions().