1. 程式人生 > >Ipopt使用筆記:windows下的安裝

Ipopt使用筆記:windows下的安裝

需要安裝的軟體:

1. MSVC

2. Intel fortran 

在windows7系統安裝Ipopt

1. 下載原始碼。

在目標資料夾右鍵,選擇tortoiseSVN/checkout。網址為:https://projects.coin-or.org/svn/Ipopt/stable/3.12

該網址會進行更新,可參考IPOPT官方網站上的下載說明,進行相應修改。IPOPT程式碼下載官方連結

2. 下載ASL,BLAS,LAPACK.

Note that you only need to obtain the ASL if you intend to use IPOPT from AMPL. It is not required if you want to specify your optimization problem in a programming language (C++, C, or Fortran). Also, currently, Lapack is only required if you intend to use the quasi-Newton options implemented in I

POPT.

當前我藉助linux作業系統下載需要的檔案。可以用VMWare虛擬機器安裝ubuntu系統。

在第一步下載得到的ipopt資料夾下,可以找到 $IPOPTDIR/ThirdParty/Blas 資料夾下的 get.Blas 檔案。將其拷貝到虛擬機器下資料夾中 執行./get.Blas 即開始下載。ASL和LAPACK可以按同樣的方法下載。

3.Download HSL Subroutines

  1. Choose whether to download either the Archive code or the HSL 2011 code. To download, select the relevant ``source'' link.
  2. Follow the instructions on the website, read the license, and submit the registration form.
  3. Wait for an email containing a download link (this should take no more than one working day).
4. 使用HSL(可選)
  • Compile the HSL code as part of IPOPT. See the instructions below.
unpack the archive, then move and rename the resulting directory so that it becomes 
$IPOPTDIR/ThirdParty/HSL/coinhsl. IPOPT may then be configured as normal.
5. Obtaining the MUMPS Linear Solver You can obtain the MUMPS code by running the script $IPOPTDIR/ThirdParty/Mumps/get.Mumps if you have wget (or ftp on Mac OS X) installed in your system. Alternatively, you can get the latest version from the MUMPS home page.
6. 使用MUMPS extract the archive in the directory $IPOPTDIR/ThirdParty/Mumps
Once you put the MUMPS source code into the correct place, the IPOPT configuration scripts will automatically detect it and compile MUMPS together with IPOPTif your Fortran compiler is able to compile Fortran 90 code.
7. 安裝cygwin https://cygwin.com/install.html
7. Installation with Cygwin using the MSVC++ compiler

This section describes how you can compile IPOPT with the Microsoft Visual C++ compiler under Cygwin. Here you have two options for compiling the Fortran code in the third party dependencies:

  • Using a Windows Fortran compiler, e.g., the Intel Fortran compiler, which is also able to compile Fortran 90 code. This would allow you to compile the MUMPS linear solver if you desire to do so.
  • Using the f2c Fortran to C compiler, available for free at Netlib (see ). This can only compile Fortran 77 code (i.e., you won't be able to compile MUMPS). Before doing the following installation steps, you need to follow the instructions in 
    $IPOPTDIR/BuildTools/compile_f2c/INSTALL.

It is possible to build the IPOPT AMPL solver executable in Cygwin for general use in Windows. You can also hook up IPOPT to your own program if you compile it in the Cygwin environment10.

If you want to compile IPOPT under Cygwin, you first have to install Cygwin on your Windows system. This is pretty straight forward; you simply download the ``setup'' program from and start it.

Then you do the following steps (assuming here that you don't have any complications with firewall settings etc - in that case you might have to choose some connection settings differently):

  1. Click next
  2. Select ``install from the internet'' (default) and click next
  3. Select a directory where Cygwin is to be installed (you can leave the default) and choose all other things to your liking, then click next
  4. Select a temp dir for Cygwin setup to store some files (if you put it on your desktop you will later remember to delete it)
  5. Select ``direct connection'' (default) and click next
  6. Select some mirror site that seems close by to you and click next
  7. OK, now comes the complicated part: 
    You need to select the packages that you want to have installed. By default, there are already selections, but the compilers are usually not pre-chosen. You need to make sure that you select the GNU compilers (for Fortran, C, and C++), Subversion, and some additional tools. For this, get the following packages from the associated branches:
    • ``Devel'': gcc4
    • ``Devel'': gcc4-fortran
    • ``Devel'': pkg-config
    • ``Devel'': subversion
    • ``Archive'': unzip
    • ``Utils'': patch
    • ``Web'': wget
    When a Resolving Dependencies window comes up, be sure to ``Select required packages (RECOMMENDED)''. This will automatically also select some other packages.
  8.  Then you click on next, and Cygwin will be installed (follow the rest of the instructions and choose everything else to your liking). At a later point you can easily add/remove packages with the setup program.
  9. The version of the GNU Make utility provided by the Cygwin installer will not work. Therefore, you need to download the fixed version from  and save it to C: $ \backslash$ cygwin $ \backslash$ bin. Double-check this new version by typing make -version in a Cygwin terminal (see next point). If you get an error -bash: /usr/bin/make: Bad address, then try instead, rename it to make.exe and move it to C: $ \backslash$ cygwin $ \backslash$ bin. (Replace C: $ \backslash$ cygwin with your installation location if different.)
  10. Now that you have Cygwin, you can open a Cygwin window, which is like a UNIX shell window.

Once you have settled on this, do the following:

  1. Follow the instructions in Section 2.5.1 until Step 11 and stop after your downloaded the third party code.
  2.  Now you need to make sure that Cygwin knows about the native compilers. For this you need to edit the file cygwin.bat in the Cygwin base directory (usually C: $ \backslash$ cygwin). Here you need to add a line like the following:

    call "C: $ \backslash$ Program Files $ \backslash$ Microsoft Visual Studio 8 $ \backslash$ VC $ \backslash$ vcvarsall.bat"

    On my computer, this sets the environment variables so that I can use the MSVC++ compiler.

    If you want to use also a native Fortran compiler, you need to include something like this

    call "C: $ \backslash$ Program Files $ \backslash$ Intel $ \backslash$ Fortran $ \backslash$ compiler80 $ \backslash$ IA32 $ \backslash$ BIN $ \backslash$ ifortvars.bat"

    You might have to search around a bit. The important thing is that, after your change, you can type ``cl'' in a newly opened Cygwin windows, and it finds the Microsoft C++ compiler (and if you want to use it, the Fortran compiler, such as the Intel's ifort).

  3. Run the configuration script, and tell it that you want to use the native compilers:

    ./configure -enable-doscompile=msvc

    Make sure the last message is

    Main Ipopt configuration successful

  4. Now you can compile the code with

    make,

    test the installation with

    make test,

    and install everything with

    make install