지식저장소

[세팅 기록소] Casadi 빌드

Magin 2024. 3. 6. 16:59
728x90

*연구실 세팅하면서 기록하기 위해 작성

Casadi 활용하기 위해 빌드

 

CasaDi 설치에 필요한 라이브러리는 다음과 같다.

  • IPOPT
  • HSL
  • MUMPS

1. IPOPT 설치 가이드 [링크]

*ASL, MUMPS의 경우 IPOPT 설치 가이드와 동일하게 진행

 

Ipopt: Installing Ipopt

The following sections describe the installation procedures on UNIX/Linux, macOS, and Windows systems. The configuration script and Makefiles in the Ipopt distribution have been created using GNU's autoconf and automake. In general, you can see the list of

coin-or.github.io

#패키지 설치
sudo apt-get install gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev

#작성장 기준(폴더명은 사용자가 원하는대로)
#이후 "cd MPC"는 모두 이 폴더 위치로 이동을 뜻함
mkdir MPC

#ASL 설치(해당 설치 과정의 패키지들은 한 곳에 모아두기를 추천)
cd MPC
git clone https://github.com/coin-or-tools/ThirdParty-ASL.git
cd ThirdParty-ASL
./get.ASL
./configure
sudo make
sudo make install

2. MUMPS 설치

cd MPC
git clone https://github.com/coin-or-tools/ThirdParty-Mumps.git
cd ThirdParty-Mumps
./get.Mumps
./configure
sudo make
sudo make install

 

2. HSL

* HSL의 경우 라이선스가 유료이기 때문에 학생임을 증명하여 무료 라이센스를 받아야함

HSL 라이센스 신청 사이트 [링크]

HSL github [링크]

#위에 과정이 모두 완료 후
cd MPC
git clone https://github.com/coin-or-tools/ThirdParty-HSL.git

#위 링크를 확인
#학생신분을 확인 후, 라이센스 발급
tar xfz coinhsl-x.y.z.tar.gz

#Rename the directory
#압축 해제한 파일의 이름을 coinhsl 변경

#이름 바꾼 coinhsl 폴더를 ThirdParty-HSL 안에 이동 후
./configure
sudo make
sudo make install

 

3. Ipopt

cd MPC
git clone https://github.com/coin-or/Ipopt.git
cd Ipopt
./configure
sudo make

sudo make test
#여기서 실패시 Ipopt 삭제 후 재시도(다시 git clone)

#문제 없다면
sudo make install

 

 

4. CasADi 설치

#향후 설치 확인을 위해 설치
sudo apt install gcc g++ gfortran git cmake liblapack-dev pkg-config
sudo apt install ipython3 python3-dev python3-numpy python3-scipy python3-matplotlib
sudo apt install swig
pip3 install casadi
pip3 install ipopt

#CasADi 설치
git clone https://github.com/casadi/casadi.git -b main casadi
cd casadi
mkdir build
cd build
cmake -DWITH_PYTHON3=ON -DWITH_IPOPT=ON -DWITH_OPENMP=ON -DWITH_THREAD=ON -WITH_BUILD_IPOPT=ON -WITH_BUILD_MUMPS=ON ..
sudo make
sudo make install

#위 make install 중 ipopt 관련 못 찾는 경우
export LD_LIBRARY_PATH="/usr/local/lib"

 

위 사진의 파일이 안보인다면 다시 빌드!!! 

 

CasADi 설치 끝

728x90