coin-or / SHOT

A solver for mixed-integer nonlinear optimization problems
https://shotsolver.dev
Eclipse Public License 2.0
119 stars 25 forks source link

Make error with cplex as subsolver #164

Closed RuifMaxx closed 1 year ago

RuifMaxx commented 1 year ago

image I install cplex with cos_installer_preview-22.1.1.0.R0-M08SWML-linux-x86-64 and Ipopt 3.12.7. I get error as below.

However, I can successfully build shot with cbc as subsolver. But, the solver acts strangely when it solve MINLP problem.

RuifMaxx commented 1 year ago
**[ 91%] Linking CXX static library libSHOTTasks.a
[ 91%] Built target SHOTTasks
[ 92%] Building CXX object CMakeFiles/SHOTSolutionStrategies.dir/src/SolutionStrategy/SolutionStrategyMIQCQP.cpp.o
[ 93%] Building CXX object CMakeFiles/SHOTSolutionStrategies.dir/src/SolutionStrategy/SolutionStrategyMultiTree.cpp.o
[ 94%] Building CXX object CMakeFiles/SHOTSolutionStrategies.dir/src/SolutionStrategy/SolutionStrategyNLP.cpp.o
[ 95%] Building CXX object CMakeFiles/SHOTSolutionStrategies.dir/src/SolutionStrategy/SolutionStrategySingleTree.cpp.o
[ 95%] Linking CXX static library libSHOTSolutionStrategies.a
[ 95%] Built target SHOTSolutionStrategies
[ 96%] Building CXX object CMakeFiles/SHOTSolver.dir/src/Report.cpp.o
[ 97%] Building CXX object CMakeFiles/SHOTSolver.dir/src/RootsearchMethod/RootsearchMethodBoost.cpp.o
[ 98%] Building CXX object CMakeFiles/SHOTSolver.dir/src/Solver.cpp.o
[ 99%] Linking CXX shared library libSHOTSolver.so
[ 99%] Built target SHOTSolver
[ 99%] Building CXX object CMakeFiles/SHOT.dir/src/SHOT.cpp.o
[100%] Linking CXX executable SHOT
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_getspecific'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_create'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutexattr_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_tryrdlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_setaffinity_np'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_key_delete'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_key_create'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutexattr_init'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_once'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_rdlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_join'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlockattr_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_init'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_unlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_trywrlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutexattr_settype'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlockattr_init'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_init'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_unlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_lock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_wrlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_getaffinity_np'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_setspecific'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlockattr_setkind_np'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/SHOT.dir/build.make:97: SHOT] Error 1
make[1]: *** [CMakeFiles/Makefile2:461: CMakeFiles/SHOT.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
**
svigerske commented 1 year ago

-lpthread seems to be missing in the linker flags. Maybe set LDFLAGS=-lpthread before calling cmake.

RuifMaxx commented 1 year ago

I am sorry for not being familiar with CMake. Could you tell me how to set LDFLAGS=-lpthread?After I set it. it does not work. May I set it in the wrong way? Thank you very much. image image

svigerske commented 1 year ago

Maybe LDFLAGS=-lpthread cmake ..... Should be easy to find out with some internet search.

RuifMaxx commented 1 year ago

I appreciate you for open-sourcing SHOT and I am looking forward to applying it to my project. However, when SHOT uses CBC as a sub-solver, it often cannot find the optimal solution and returns integer solutions for continuous variables. I tried using CPLEX as a sub-solver, but it did not compile successfully. I appreciate your help.

This error still exists with calling LDFLAGS=-lpthread cmake -DCMAKE_BUILD_TYPE=Release -DHAS_CPLEX=on -DCPLEX_DIR=/opt/ibm/IL0G/CPLEX_Studio_Community2211 -DHAS_IPOPT=on -DIPOPT_DIR=/root/Ipopt-3.12.7 ..

The output info is below:

root@chttFfj7:~/SHOT/build# LDFLAGS=-lpthread cmake -DCMAKE_BUILD_TYPE=Release -DHAS_CPLEX=on -DCPLEX_DIR=/opt/ibm/IL0G/CPLEX_Studio_Community2211 -DHAS_IPOPT=on -DIPOPT_DIR=/root/Ipopt-3.12.7 ..
-- The CXX compiler identification is GNU 9.4.0
-- The C compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - found
-- Performing Test CAN_COMPILE_FS_WITHOUT_LINK
-- Performing Test CAN_COMPILE_FS_WITHOUT_LINK - Success
-- Git hash: 3557f60e-dirty
-- Found CPLEX Studio: /opt/ibm/ILOG/CPLEX_Studio_Community2211
-- Found CPLEX: /opt/ibm/ILOG/CPLEX_Studio_Community2211/cplex/lib/x86-64_linux/static_pic/libcplex.a  
-- Found CPLEX_CONCERT: /opt/ibm/ILOG/CPLEX_Studio_Community2211/concert/lib/x86-64_linux/static_pic/libconcert.a  
-- Performing Test HAVE_WNO_LONG_LONG_FLAG
-- Performing Test HAVE_WNO_LONG_LONG_FLAG - Success
-- Found CPLEX_ILOCPLEX: /opt/ibm/ILOG/CPLEX_Studio_Community2211/cplex/lib/x86-64_linux/static_pic/libilocplex.a  
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for one of the modules 'ipopt'
-- CPLEX include files will be used from:
   /opt/ibm/ILOG/CPLEX_Studio_Community2211/cplex/include
   /opt/ibm/ILOG/CPLEX_Studio_Community2211/concert/include
   /opt/ibm/ILOG/CPLEX_Studio_Community2211/cplex/include
-- The following CPLEX libraries will be used:
   /opt/ibm/ILOG/CPLEX_Studio_Community2211/cplex/lib/x86-64_linux/static_pic/libcplex.a
   /opt/ibm/ILOG/CPLEX_Studio_Community2211/concert/lib/x86-64_linux/static_pic/libconcert.a
   /opt/ibm/ILOG/CPLEX_Studio_Community2211/cplex/lib/x86-64_linux/static_pic/libilocplex.a
-- Ipopt include files will be used from: /root/Ipopt-3.12.7/include/coin
-- The following Ipopt libraries will be used from: /root/Ipopt-3.12.7/lib;/usr/lib/gcc/x86_64-linux-gnu/9;/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu;/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib;/lib/../lib;/usr/lib/../lib;/usr/lib/gcc/x86_64-linux-gnu/9/../../..
   ipopt;lapack;blas;m;dl;coinhsl;gfortran;m;quadmath
-- Configuring done
-- Generating done
-- Build files have been written to: /root/SHOT/build

some make install result

[  6%] Performing configure step for 'spdlog'
-- The CXX compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build spdlog: 1.8.2
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Build type: Release
-- Generating example(s)
-- Generating install
-- Configuring done
-- Generating done
-- Build files have been written to: /root/SHOT/build/spdlog/src/spdlog-build
[100%] Linking CXX executable SHOT
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_getspecific'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_create'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutexattr_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_tryrdlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_setaffinity_np'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_key_delete'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_key_create'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutexattr_init'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_once'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_rdlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_join'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlockattr_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_init'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_unlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_rwlock_trywrlock'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_spin_destroy'
/usr/bin/ld: libSHOTSolver.so: undefined reference to `pthread_mutexattr_settype'
andreaslundell commented 1 year ago

Hi,

Did you get SHOT to finally compile with CPLEX?

I am aware that there are issues with using Cbc as the subsolver. But could you please specify more in which cases it returns the wrong solution for discrete values? If you do not want to share your models here, you can also send them to me at andreas.lundell@abo.fi.

andreaslundell commented 1 year ago

I will close this now, please reopen if needed.