![]() |
GURLS++
2.0.00
C++ Implementation of GURLS Matlab Toolbox
|
GurlsOptionsList is an option containing a list of options mapped by name.
#include <optlist.h>
Public Types | |
typedef std::map< std::string, GurlsOption * > | ValueType |
Public Member Functions | |
bool | addOpt (std::string key, GurlsOption *value) |
Adds a generic option to the list indexed with a specified key. | |
bool | addOpt (std::string key, std::string value) |
Adds a string option to the list indexed with a specified key. | |
bool | addOpt (std::string key, std::wstring value) |
Adds a string option to the list indexed with a specified key. | |
void | copyOpt (std::string key, const GurlsOptionsList &from) |
virtual const std::type_info & | getDataID () |
Returns the identifier of the option type. | |
std::string | getName () const |
Returns the list name. | |
GurlsOption * | getOpt (std::string key) |
Returns a pointer to a generic option mapped with a key. | |
const GurlsOption * | getOpt (std::string key) const |
Returns a pointer to a generic option mapped with a key. | |
template<class T > | |
T * | getOptAs (std::string key) |
Returns a pointer to a T option mapped with a key. | |
template<class T > | |
const T * | getOptAs (std::string key) const |
Returns a pointer to a T option mapped with a key. | |
double | getOptAsNumber (std::string key) const |
Returns a numeric option mapped with a key. | |
std::string | getOptAsString (std::string key) const |
Returns a string option mapped with a key. | |
template<class T > | |
T::ValueType & | getOptValue (std::string key) |
Returns a reference to the value contained into an option mapped with a key. | |
template<class T > | |
const T::ValueType & | getOptValue (std::string key) const |
Returns a reference to the value contained into an option mapped with a key. | |
OptTypes | getType () const |
Returns the option type. | |
const ValueType & | getValue () const |
Returns the entire map. | |
GurlsOptionsList (std::string ExpName, bool usedefopt=false) | |
Constructor. | |
GurlsOptionsList (const GurlsOptionsList &other) | |
Copy constructor. | |
bool | hasOpt (std::string key) const |
Checks if the list has an option mapped with a specified key. | |
virtual bool | isA (OptTypes id) const |
Checks if the option has the given type. | |
void | load (const std::string &fileName) |
Deserializes the list from file. | |
virtual std::ostream & | operator<< (std::ostream &os) const |
Writes the list to a stream. | |
GurlsOption * | operator[] (int idx) |
Returns a pointer to the idx-th option into the list. | |
void | printAll () |
Prints the options list. | |
void | removeOpt (std::string key, bool deleteMembers=true) |
Removes the option mapped with a specified key. | |
void | save (const std::string &fileName) const |
Serializes the list to file. | |
void | setName (std::string) |
Sets the list name. | |
int | size () const |
Returns the number of options within the list. | |
std::string | toString () |
Writes the list to a string. | |
~GurlsOptionsList () | |
Destructor. | |
Static Public Member Functions | |
static GurlsOptionsList * | dynacast (GurlsOption *opt) |
Tries to cast a pointer to a generic option to a pointer to an GurlsOptionsList. | |
static const GurlsOptionsList * | dynacast (const GurlsOption *opt) |
Tries to cast a pointer to a generic option to a pointer to an GurlsOptionsList. | |
Protected Attributes | |
std::string | name |
Option name. | |
ValueType * | table |
Options list, indexed by name. | |
OptTypes | type |
Option type. | |
Friends | |
GURLS_EXPORT std::ostream & | operator<< (std::ostream &os, const GurlsOption &opt) |
Writes an option to a stream. | |
GURLS_EXPORT std::ostream & | operator<< (std::ostream &os, const GurlsOptionsList &opt) |
Writes a GurlsOptionsList to a stream. |
gurls::GurlsOptionsList::GurlsOptionsList | ( | std::string | ExpName, |
bool | usedefopt = false |
||
) |
Builds an optionlist with a name and optionally a set of default options
ExpName | name of the options list |
usedefopt | if true the list is filled with a set of default options, if false the list is left empty |
Definition at line 71 of file optlist.cpp.
: GurlsOption(OptListOption), name(ExpName) { table = new std::map<std::string, GurlsOption* >(); (*table)["Name"] = new OptString(ExpName); if(usedefopt) { // opt.combineclasses = @mean; % How to combine performance measure per class (mean/median/min/max?) (*table)["combineclasses"] = new OptFunction("mean"); (*table)["name"] = new OptString(ExpName); (*table)["plotstr"] = new OptString(ExpName); #ifdef USE_BINARY_ARCHIVES (*table)["savefile"] = new OptString(ExpName.append(".bin")); #else (*table)["savefile"] = new OptString(ExpName.append(".txt")); #endif // ================================================== Algorithm options // opt.kernel.type = 'rbf'; (*table)["singlelambda"] = new OptFunction("median"); (*table)["predbagmethod"] = new OptString("vote"); // NOTE: lambda is searched between // [min(eig_r, opt.smallnumber), eig_1], // where r = rank, eig_1 = max eig val. (*table)["smallnumber"] = new OptNumber(1e-8); // ================================================== Directory options (*table)["tmpdir"] = new OptString(ExpName); // ===================================================== Output options (*table)["savekernel"] = new OptNumber(1); (*table)["saveanalysis"] = new OptNumber(1); // opt.hoperf = @perf_precrec; (*table)["ploteval"] = new OptString("acc"); // WARNING: this should be an array of strings... (*table)["perfeval"] = new OptString("acc"); // ======================================================== Data option (*table)["nholdouts"] = new OptNumber(1); (*table)["hoproportion"] = new OptNumber(0.2); (*table)["hoperf"] = new OptString("macroavg"); // (*table)["nlambda"] = new OptNumber(100); (*table)["nsigma"] = new OptNumber(25); (*table)["nlambda"] = new OptNumber(20); // (*table)["nsigma"] = new OptNumber(10); (*table)["eig_percentage"] = new OptNumber(5); // ======================================================== Pegasos option (*table)["subsize"] = new OptNumber(50); (*table)["calibfile"] = new OptString("foo"); (*table)["epochs"] = new OptNumber(4); // ============================================================== Quiet // Currenty either 0 or 1; levels of verbosity may be implemented later; (*table)["verbose"] = new OptNumber(1); // ======================================================= Version info (*table)["version"] = new OptString("2.0"); GurlsOptionsList * randfeats = new GurlsOptionsList("randfeats"); randfeats->table->insert(pair<std::string,GurlsOption*>("D", new OptNumber(500))); randfeats->table->insert(pair<std::string,GurlsOption*>("samplesize", new OptNumber(100))); (*table)["randfeats"] = randfeats; } }
void gurls::GurlsOptionsList::removeOpt | ( | std::string | key, |
bool | deleteMembers = true |
||
) |
key | string key |
deleteMembers | If true deallocates the removed option, if false option will be only detached |
Definition at line 190 of file optlist.cpp.