8.4.3. Environment¶
Represents the runtime environment of a model, including License and Configuration. When creating a model, An environment associated with model must be provided.
Functions
Create an environment
Create an empty environment
Start an empty environment
Free an environment that was previously created
Append a message to environment log
Explain a specified error code
Retrieve the most recent error message associated with environment
Retrieve version numbers
Redirect output log to a user-defined callback function
- int MDOloadenv(MDOenv **envP, const char *logfilename)¶
Create an environment. This routine is typically the first call in an application. This routine will also attempt to find a license file (mindopt.lic for fixed license or fl_client.ini for floating license) and do license checking. This routine will also check the current working directory for a file named mindopt.env and it will attempt to read parameter settings from this file, this file should be in PRM format.
- Parameters
envP (MDOenv**) – [out] The location in which the pointer to the newly created environment should be placed.
logfilename (const char*) – [in] The log file name, can be NULL or an empty string, in which case no log file is created.
- Returns
A response code that specifies the status of the function.
- int MDOemptyenv(MDOenv **envP)¶
Create an empty environment.
- Parameters
envP (MDOenv**) – [out] The location in which the pointer to the newly created environment should be placed.
- Returns
A response code that specifies the status of the function.
Note
You will need to call MDOstartenv before you can use this environment.
- int MDOstartenv(MDOenv *env)¶
Start an empty environment. This routine starts an empty environment created by MDOemptyenv. This routine will also attempt to find a license file (mindopt.lic for fixed license or fl_client.ini for floating license) and do license checking. This routine will also check the current working directory for a file named mindopt.env and it will attempt to read parameter settings from this file, this file should be in PRM format.
- Parameters
env (MDOenv*) – [in] The empty environment pointer.
- Returns
A response code that specifies the status of the function.
- void MDOfreeenv(MDOenv *env)¶
Free an environment that was previously created. This routine should be called when an environment is no longer needed.
- Parameters
env (MDOenv*) – [in] The environment to be freed.
- void MDOmsg(MDOenv *env, const char *message)¶
Append a message to environment log.
- Parameters
env (MDOenv*) – [in] The environment whose log should receive the message.
message (const char*) – [in] The message to be appended to the log.
- const char *MDOexplainerror(int code)¶
Explain a specified error code.
- Parameters
code (int) – [in] The error code.
- Returns
The explaination corresponding to code . Note that it is a pointer to model internal data structure.
- char *MDOgeterrormsg(MDOenv *env)¶
Retrieve the most recent error message associated with environment.
- Parameters
env (MDOenv*) – [in] The environment pointer.
- Returns
The most recent error message. Note that it is a pointer to model internal data structure.
- void MDOversion(int *majorP, int *minorP, int *technicalP)¶
Retrieve version numbers.
- Parameters
majorP (int*) – [out] The place to hold major version number.
minorP (int*) – [out] The place to hold minor version number.
technicalP (int*) – [out] The place to hold technical version number.
- int MDOsetlogcallback(MDOenv *env, logfn logcb, void *userdata)¶
Redirect output log to a user-defined callback function. This function redirects output log to a user-defined callback function.
- Parameters
env (MDOenv*) – [in] Pointer to the environment.
logcb (logfn) –
[in] User defined log callback function. Type logfn is defined as:
typedef void (*logfn)(const char*, void*);userdata (void*) – [in] User defined data that will be passed into the callback function.
- Returns
A response code that specifies the status of the function.