8.9.3. MDOEnv¶
- MDOEnv¶
Represent a MindOpt runtime environment.
Methods
Use the associated log file to construct an environment
Construct an environment
Release resources corresponding to the environment
Retrieve the value of an int parameter
Retrieve the value of the double parameter
Retrieve the value of a string parameter
Retrieve the latest error message
Retrieve information about the int parameter by its name
Retrieve information about the double parameter by its name
Retrieve information about String parameters by its name
Append a message to environment logs
Read parameter settings from a file
Reset all parameters to their default values
Set a new value for the int parameter
Set a new value for the double parameter
Set a new value for the String parameter
Set a new value for the parameter
This function redirects output logs to user-defined callback functions
Start the current environment
Write parameter settings to a file
- MDOEnv(String logFileName)¶
Use the associated log file to construct an environment
- Parameters
String logFileName – The log file name associated with the environment.
- MDOEnv(boolean empty)¶
Construct an environment
- Parameters
boolean empty – Whether to construct an empty environment
- void dispose()¶
Release resources corresponding to the environment
- int get(MDO.IntParam param)¶
Retrieve the value of an int parameter
- Parameters
MDO.IntParam param – Parameter
- Returns
The current value of the parameter.
- double get(MDO.DoubleParam param)¶
Retrieve the value of the double parameter
- Parameters
MDO.DoubleParam param – Parameter
- Returns
The current value of the parameter.
- String get(MDO.StringParam param)¶
Retrieve the value of a string parameter
- Parameters
MDO.StringParam param – Parameter name
- Returns
The current value of the parameter
- String getErrorMsg()¶
Retrieve the latest error message
- Returns
Latest error message
- void getParamInfo(MDO.IntParam param, int[] info)¶
Retrieve information about the int parameter by its name
- Parameters
MDO.IntParam param – Parameter name
int[] info – The info array contains four entries: the current value of the parameter, the minimum allowable value, the maximum allowable value, and the default value.
- void getParamInfo(MDO.DoubleParam param, double[] info)¶
Retrieve information about the double parameter by its name
- Parameters
MDO.DoubleParam param – Parameter name
double[] info – The info array contains four entries: the current value of the parameter, the minimum allowable value, the maximum allowable value, and the default value.
- void getParamInfo(MDO.StringParam param, String[] info)¶
Retrieve information about String parameters by its name
- Parameters
MDO.StringParam param – Parameter
String[] info – The info array contains two entries: the current value of the parameter and the default value.
- void message(String message)¶
Append a message to environment logs
- Parameters
String message – The message to be appended.
- void readParams(String paramfile)¶
Read parameter settings from a file
- Parameters
String paramfile – The file name. Note that the file format and compression type should be encoded as a suffix in the file name. The 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 value)¶
Set a new value for the int parameter
- Parameters
MDO.IntParam param – Parameter
int value – The new value to be set.
- void set(MDO.DoubleParam param, double value)¶
Set a new value for the double parameter
- Parameters
MDO.DoubleParam param – Parameter
double value – The new value to be set.
- void set(MDO.StringParam param, String value)¶
Set a new value for the String parameter
- Parameters
MDO.StringParam param – Parameter
String value – The new value to be set.
- void set(String param, String value)¶
Set a new value for the parameter
- Parameters
String param – Parameter
String value – The string representation of the new value to be set. The actual value depends on the parameter type specified by name.
- void setLogCallback(Consumer<String> logCallback)¶
This function redirects output logs to user-defined callback functions.
- Parameters
Consumer<String> logCallback – User-defined callback functions
- void start()¶
Start the current environment
- void writeParams(String paramFile)¶
Write parameter settings to a file
- Parameters
String paramFile – The name of the file to be written. Note that the file format and compression type should be encoded as a suffix in the file name. The valid file format is .prm. Supported compression types include .gz and .Bz2.