PLearn 0.1
ExplicitListOracle.cc
Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 
00004 // ExplicitListOracle.cc
00005 //
00006 // Copyright (C) 2003-2004 ApSTAT Technologies Inc.
00007 //
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions are met:
00010 //
00011 //  1. Redistributions of source code must retain the above copyright
00012 //     notice, this list of conditions and the following disclaimer.
00013 //
00014 //  2. Redistributions in binary form must reproduce the above copyright
00015 //     notice, this list of conditions and the following disclaimer in the
00016 //     documentation and/or other materials provided with the distribution.
00017 //
00018 //  3. The name of the authors may not be used to endorse or promote
00019 //     products derived from this software without specific prior written
00020 //     permission.
00021 //
00022 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00023 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00024 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00025 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00026 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00027 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00028 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00029 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00030 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00031 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 //
00033 // This file is part of the PLearn library. For more information on the PLearn
00034 // library, go to the PLearn Web site at www.plearn.org
00035 
00036 // Author: Pascal Vincent
00037 
00038 /* *******************************************************
00039  * $Id: ExplicitListOracle.cc 8896 2008-04-25 17:58:29Z nouiz $
00040  ******************************************************* */
00041 
00043 #include "ExplicitListOracle.h"
00044 
00045 namespace PLearn {
00046 using namespace std;
00047 
00048 ExplicitListOracle::ExplicitListOracle()
00049     :OptionsOracle(),
00050      nreturned(0)
00051 /* ### Initialise all fields to their default value */
00052 {
00053     // ...
00054 
00055     // ### You may or may not want to call build_() to finish building the object
00056     // build_();
00057 }
00058 
00059 PLEARN_IMPLEMENT_OBJECT(ExplicitListOracle, "ONE LINE DESCR", "NO HELP");
00060 
00061 void ExplicitListOracle::declareOptions(OptionList& ol)
00062 {
00063     declareOption(ol, "option_names", &ExplicitListOracle::option_names, OptionBase::buildoption,
00064                   "name of options");
00065 
00066     declareOption(ol, "option_values", &ExplicitListOracle::option_values, OptionBase::buildoption,
00067                   "A matrix with as many columns as there are options, giving their values");
00068 
00069     declareOption(ol, "nreturned", &ExplicitListOracle::nreturned,
00070                   OptionBase::learntoption,
00071                   "The number of returned option");
00072 
00073     // Now call the parent class' declareOptions
00074     inherited::declareOptions(ol);
00075 }
00076 
00077 TVec<string>  ExplicitListOracle::getOptionNames() const
00078 { return option_names; }
00079 
00080 TVec<string> ExplicitListOracle::generateNextTrial(const TVec<string>& older_trial, real obtained_objective)
00081 {
00082     if(nreturned < option_values.length())
00083         return option_values(nreturned++);
00084     else
00085         return TVec<string>();
00086 }
00087 
00088 void ExplicitListOracle::forget()
00089 {
00090     nreturned = 0;
00091 }
00092 
00093 
00094 
00095 void ExplicitListOracle::build_()
00096 {
00097     // ### This method should do the real building of the object,
00098     // ### according to set 'options', in *any* situation.
00099     // ### Typical situations include:
00100     // ###  - Initial building of an object from a few user-specified options
00101     // ###  - Building of a "reloaded" object: i.e. from the complete set of all serialised options.
00102     // ###  - Updating or "re-building" of an object after a few "tuning" options have been modified.
00103     // ### You should assume that the parent class' build_() has already been called.
00104 }
00105 
00106 // ### Nothing to add here, simply calls build_
00107 void ExplicitListOracle::build()
00108 {
00109     inherited::build();
00110     build_();
00111 }
00112 
00113 
00114 void ExplicitListOracle::makeDeepCopyFromShallowCopy(CopiesMap& copies)
00115 {
00116     inherited::makeDeepCopyFromShallowCopy(copies);
00117     deepCopyField(option_names, copies);
00118     deepCopyField(option_values, copies);
00119 }
00120 
00121 } // end of namespace PLearn
00122 
00123 
00124 /*
00125   Local Variables:
00126   mode:c++
00127   c-basic-offset:4
00128   c-file-style:"stroustrup"
00129   c-file-offsets:((innamespace . 0)(inline-open . 0))
00130   indent-tabs-mode:nil
00131   fill-column:79
00132   End:
00133 */
00134 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines