This model shows an External element implementation example. In this case, the example GoldSim model includes two External elements which call separate functions in the same DLL. The overall purpose of the External elements/DLL is to provide an estimate of the relative, simulation running time by computer.
The idea is to include this estimate of running time within a parameter estimation tool (in this case PEST) as an error to minimize. Because the actual model, which this DLL was developed for, runs simulations on several machines that have different speeds, the dll first checks the current computer name and uses this value to determine a weight. The model then calculates running time based on system time and uses the running time and the weight to determine a normalized running time (different for each machine). So far, this DLL has been used, along with parameter estimation/optimization, to reduce the average running time from 30 to 24 minutes (or by 20%) without compromising model accuracy. Note that the target model for this DLL is proprietary and only a "generic", example GoldSim model is included for demonstration purposes.
The download link provides a zip file which includes a compiled GetTime.dll file and an example GetTime.gsm GoldSim model. The zip file also includes the DLL, C++ source code in the file GetTime.cpp. To compile this on your own system using Visual Studio:
- Create a new project which is a C++ Win32 Console Application which is set-up to be a library and not an executable.
- This project should be named GetTime so that the file created by default is GetTime.cpp.
- Copy the contents of the GetTime.cpp file from the zip archive to the GetTime.cpp file in the new project.
- You may need to change the "GetComputerName" call in the function "GetPCName" to be a call to "GetComputerNameA" if you are using a recent version of Visual Studio (i.e. Visual Studio 2015).