Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OR-Tools Integration & C++17 upgrade #1035

Open
wants to merge 148 commits into
base: develop
Choose a base branch
from
Open

OR-Tools Integration & C++17 upgrade #1035

wants to merge 148 commits into from

Conversation

dguittet
Copy link
Collaborator

@dguittet dguittet commented Jun 13, 2023

To use:

Download OR-Tools version 9.8 source separately in the same directory as sam, ssc, etc. https://github.com/google/or-tools/releases/tag/v9.8

Set the directory via export ORTOOLSDIR=$HOME/.../sam-dev/or-tools/install (for Windows, set the environment variable)

Then build and install it with CMake.

If using XPRESS, add -DUSE_XPRESS=ON -DXPRESS_ROOT=${XPRESS_ROOT} to the cmake config commands below. If XPRESS_ROOT is defined as an environment variable, you don't need to add -DXPRESS_ROOT=${XPRESS_ROOT} to the CMake command.

Unix

Environment variable: ORTOOLSDIR = /path/to/or-tools/install/install_release

cd or-tools

# without XPRESS
cmake -S . -B build -DBUILD_DEPS=ON -DUSE_COINOR=OFF -DUSE_HIGHS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DBUILD_DOC=OFF -DINSTALL_DOC=OFF -DUSE_XPRESS=OFF -DCMAKE_INSTALL_PREFIX=${ORTOOLSDIR}

cmake --build build --config Release --target install -v -j 4

# with XPRESS
cmake -S . -B build -DBUILD_DEPS=ON -DUSE_COINOR=OFF -DUSE_HIGHS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DBUILD_DOC=OFF -DINSTALL_DOC=OFF -DCMAKE_INSTALL_PREFIX=${ORTOOLSDIR} -DUSE_XPRESS=ON -DXPRESS_ROOT=${XPRESS_ROOT}

cmake --build build --config Release --target install -v -j 4

# Build SSC

cd ssc
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSAM_SKIP_TOOLS=1 -DCMAKE_PREFIX_PATH=${ORTOOLSDIR}

Windows

Use x64 Native Tools Command Prompt for VS 2022 and note VS 2022 is required. If XPRESS_ROOT is defined as an environment variable, you don't need to add it to the CMake command. Windows requires building both Debug and Release. In addition, these are built in separate directories named install_release and install_debug. The "release" and "debug" text is needed in the names for the CMake to switch between the configurations.

Environment variables:
ORTOOLSDIR = /path/to/or-tools/install_release
ORTOOLSDBDIR = /path/to/or-tools/install_debug

cd or-tools

# Release, without XPRESS
cmake -S . -B build_release -DBUILD_DEPS=ON -DUSE_COINOR=OFF -DUSE_HIGHS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DBUILD_DOC=OFF -DINSTALL_DOC=OFF -DUSE_XPRESS=OFF  -DCMAKE_INSTALL_PREFIX=%ORTOOLSDIR%

mkdir install_release
cmake --build build_release --config Release --target ALL_BUILD -v -j 4
# if there is an error about zlib, then make zlib first
cmake --build build_release --config Release --target ZLIB -v -j 4
cmake --build build_release --config Release --target ALL_BUILD -v -j 4
# if the install directory is still empty, then call the INSTALL explicitly
cmake --build build_release --config Release --target INSTALL -v -j 4

# Debug, without XPRESS
cmake -S . -B build_debug -DBUILD_DEPS=ON -DUSE_COINOR=OFF -DUSE_HIGHS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SAMPLES=OFF -DBUILD_DOC=OFF -DINSTALL_DOC=OFF -DUSE_XPRESS=OFF  -DCMAKE_INSTALL_PREFIX=%ORTOOLSDBDIR%

mkdir install_debug
cmake --build build_debug --config Debug --target ALL_BUILD -v -j 4
# see notes above in release build

# Build SSC
cd ssc
cmake -S . -B build -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DSAM_SKIP_TOOLS=1

Then the .sln file can be used in Visual Studio

Test OR-tools in the Test via the lib_ptes_chp_dispatch_test test.

If downloading OR-Tools binary from their website https://developers.google.com/optimization/install/cpp, then set ORTOOLSDIR to the extracted folder. ORTOOLSDIR should contain the 'lib', 'cmake', 'bin', etc folders.

@qualand
Copy link
Collaborator

qualand commented Oct 3, 2023

@dguittet

We now have or-tools fork which lives here: https://github.com/NREL/or-tools

When using this fork, I was unable to build or-tools using x64 Native Tools Command Prompt for VS 2022 due to a known issue: google/or-tools#3807

Instead I built or-tools with x64 Native Tools Command Prompt for VS 2019 then built SSC using x64 Native Tools Command Prompt for VS 2022. When building SSC, I did NOT need to add -DUSE_XPRESS=ON -DXPRESS_ROOT=${XPRESS_ROOT} to the command; however, I do have XPRESS_ROOT defined as a environment variable.

I was able to run the test using SCIP and Xpress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants