8.5.15. MDOEnv¶
-
class MDOEnv¶
Represent a MindOpt runtime environment.
Methods
Construct an environment
Construct an environment with associated log file name
Construct an environment with associated log file name
Retrieve the value of an int parameter
Retrieve the value of a double parameter
Retrieve the value of a string parameter
Retrieve the message of the most recent occurred error
Retrieve the information about a double parameter by its name
Retrieve the information about an int parameter by its name
Retrieve the information about a string parameter by its name
Append a message to environment log
Read parameter settings from a file
Reset all parameters to their default values
Set a new value for an int parameter
Set a new value for a double parameter
Set a new value for a string parameter
Set a new value for a parameter
Start this environment if this environment is “empty”, else do nothing
Write parameter settings to file
-
MDOEnv(const bool empty = false)¶
Construct an environment.
- Parameters
const bool empty=false – Whether to construct an empty environment
-
MDOEnv(const char *logfilename)¶
Construct an environment with associated log file name.
- Parameters
const char* logfilename – The log file name associated to environment. Can be NULL or empty string, in which case no log file will be created.
-
MDOEnv(const std::string &logfilename)¶
Construct an environment with associated log file name.
- Parameters
const std::string& logfilename – The log file name associated to environment. Can be empty string, in which case no log file will be created.
-
int get(MDO_IntParam param)¶
Retrieve the value of an int parameter.
- Parameters
MDO_IntParam param – The parameter name.
- Returns
The current value of parameter.
-
double get(MDO_DoubleParam param)¶
Retrieve the value of a double parameter.
- Parameters
MDO_DoubleParam param – The parameter name.
- Returns
The current value of parameter.
-
std::string get(MDO_StringParam param)¶
Retrieve the value of a string parameter.
- Parameters
MDO_StringParam param – The parameter name.
- Returns
The current value of parameter.
-
const std::string getErrorMsg()¶
Retrieve the message of the most recent occurred error.
- Returns
The message of the most recent occurred error.
-
void getParamInfo(MDO_DoubleParam param, double *valP, double *minP, double *maxP, double *defP)¶
Retrieve the information about a double parameter by its name.
- Parameters
MDO_DoubleParam param – The parameter name
double* valP – The place to hold the current value of parameter.
double* minP – The place to hold the minimum allowed value of parameter.
double* maxP – The place to hold the maximum allowed value of parameter.
double* defP – The place to hold the default value of parameter.
-
void getParamInfo(MDO_IntParam param, int *valP, int *minP, int *maxP, int *defP)¶
Retrieve the information about an int parameter by its name.
- Parameters
MDO_IntParam param – The parameter name
int* valP – The place to hold the current value of parameter.
int* minP – The place to hold the minimum allowed value of parameter.
int* maxP – The place to hold the maximum allowed value of parameter.
int* defP – The place to hold the default value of parameter.
-
void getParamInfo(MDO_StringParam param, std::string &value, std::string &defvalue)¶
Retrieve the information about a string parameter by its name.
- Parameters
MDO_StringParam param – The parameter name
std::string& value – The place to hold the current value of parameter.
std::string& defvalue – The place to hold the default value of parameter.
-
void message(const std::string &msg)¶
Append a message to environment log.
- Parameters
const std::string& msg – The message to be appended.
-
void readParams(const std::string ¶mfile)¶
Read parameter settings from a file.
- Parameters
const std::string& paramfile – The file name. Note that file format and compression type should be encoded as a suffix in file name. Valid file format is .prm, supported compression types include .gz and .bz2.
-
void resetParams()¶
Reset all parameters to their default values.
-
void set(MDO_IntParam param, int newvalue)¶
Set a new value for an int parameter.
- Parameters
MDO_IntParam param – The parameter name.
int newvalue – The new value to be set.
-
void set(MDO_DoubleParam param, double newvalue)¶
Set a new value for a double parameter.
- Parameters
MDO_DoubleParam param – The parameter name.
double newvalue – The new value to be set.
-
void set(MDO_StringParam param, const std::string &newvalue)¶
Set a new value for a string parameter.
- Parameters
MDO_StringParam param – The parameter name.
const std::string& newvalue – The new value to be set.
-
void set(const std::string ¶mname, const std::string &newvalue)¶
Set a new value for a parameter.
- Parameters
const std::string& paramname – The parameter name.
const std::string& newvalue – The string representation of new value to be set, its actual value depends on the type of parameter specified by name.
-
void start()¶
Start this environment if this environment is “empty”, else do nothing.
-
void writeParams(const std::string ¶mfile)¶
Write parameter settings to file.
- Parameters
const std::string& paramfile – The file name. Note that file format and compression type should be encoded as a suffix in file name. Valid file format is .prm, supported compression types include .gz and .bz2.
-
MDOEnv(const bool empty = false)¶