Antares Xpansion
Investment simulations for Antares studies
|
This document explains how to install the Xpress solver in both default and non-default locations, as well as how Antares-Xpansion dynamically loads the Xpress library and license.
By default, the Xpress solver will be installed in system-wide directories depending on your operating system. The default installation paths are:
C:\xpressmp\bin\xprs.dll
or C:\Program Files\xpressmp\bin\xprs.dll
/Library/xpressmp/lib/libxprs.dylib
/opt/xpressmp/lib/libxprs.so
After installing the Xpress solver, the environment variable XPRESSDIR
should point to the installation directory. This will help the system locate the required libraries.
For non-default installations, you need to manually configure the XPRESSDIR
environment variable to point to the custom installation path. For example:
Make sure that the dynamic libraries (e.g., xprs.dll, libxprs.dylib, or libxprs.so) are located in the appropriate subdirectories (bin or lib) under the directory specified by XPRESSDIR.
The C++ code dynamically loads the Xpress solver library and configures the licensing environment at runtime. Here's a step-by-step explanation of how it works:
XPRESSDIR
: XPRESSDIR
environment variable is defined. This variable should point to the directory where the Xpress solver is installed.XPRESSDIR
path:\bin
(e.g., C:\xpressmp\bin\xprs.dll
)./lib
(e.g., /opt/xpressmp/lib/libxprs.so
).LoadLibrary()
to load xprs.dll
.dlopen()
to load libxprs.dylib
.dlopen()
to load libxprs.so
.XPRESSDIR
or ensuring the file is in the correct path).license
subdirectory inside the XPRESSDIR
path. This folder typically contains the necessary license files for the Xpress solver.Set Environment Variables for License:
To ensure Xpress can authenticate properly, the code sets the following environment variables:
XPRESSDIR
: Points to the root installation directory of the Xpress solver.XPAUTH
: If this environment variable is set, it points directly to the license file (e.g., xpauth.xpr
). This provides a more explicit way to define the path to the license file rather than relying on the default license
subdirectory.This approach allows greater flexibility when managing license files, especially in environments where the XPRESSDIR/license/
directory may not be the default location for license files.
XPRESSDIR
and ensuring the license file exists in the default license
subdirectory.XPAUTH
environment variable to the correct license file path in case the file is stored in a custom location.Using XPAUTH
allows for better flexibility in license management, particularly in cloud or containerized environments, where environment variables are commonly used to configure paths dynamically.
To ensure cross-platform compatibility, the code contains specific logic to handle each operating system:
LoadLibrary()
function to load the xprs.dll
file. After loading, it retrieves function pointers from the library using GetProcAddress()
.dlopen()
to load shared libraries (libxprs.so
for Linux and libxprs.dylib
for macOS). Function pointers are retrieved using dlsym()
.The dynamic loading process ensures that the program does not need to be recompiled when the library is installed in different locations or on different platforms.