Knitro and AMPL Installation (1)

advertisement
Knitro and AMPL Installation (1)
Install Knitro and AMPL:
1. Go to
http://www.artelys.com/secured-area/knitro/home.html
to download software.
2. To login, enter the following username and password:
Username : ICE
Password : QX5NNm*ka6
3. Download the following from the links on the right hand side
of the page:
�
�
Knitro_8.0 (for Full Knitro and academic licenses)
AMPL 8.0
Choose the link which is appropriate for your computer and
OS. The other links are subsets of Knitro 8.0 distribution so
do not use them unless you want reduced functionality.
Knitro and AMPL Installation (2)
3. To unpack these files:
Linux & OS/X Extract these files by double clicking on them
in the Finder or Browser window. If that fails,
open a Terminal window and use tar:
$ cd /my/install/dir.
$ tar xzf ampl-z-MacOSX64.tar.gz
$ tar xzf knitro-8.0.0-z-MacOSX-64.tar.gz
Windows Unzip the files where you want them by double
clicking on them in the Windows Explorer.
�
�
Install the files somewhere sensible – i.e., add a level of
indirection by creating a directory to contain Tools and a
subdirectory for everything from Ziena., e.g., I install Knitro in
OS/X: /Users/bss/Tools/Ziena/knitro-8.0.0.
Linux: /home/bss/Tools/Ziena/knitro-8.0.0.
Windows: c:\Tools\Ziena\knitro-8.0.0 or equivalent.
Warning: on Windows, you should avoid avoid file and
directory names with spaces in them.
Knitro and AMPL Installation (3)
4. Next, get your machine ID, which will uniquely identify your
machine unless you are running certain VPN software:
�
�
�
Click on ‘get your machine ID’ link on the license key
request page
Extract the files as discussed on the previous slide
Run get_machine_ID by double-clicking on it or running it in
a Terminal or xterm window (OS/X or Linux):
$ ./get_machine_ID
---- Your Ziena machine ID is 8b-0f-51-87-5a ---Use this machine ID to obtain a Ziena license.
NOTE: this is a Stand Alone license. Ignore the stuff in the
documentation about floating licenses.
5. Click ‘GENERATE KEY’ and store the license in the file
ziena_license.txt in your Knitro 8.0.0 directory.
Warning!
Please do not distribute these software licenses to anyone:
�
We depend on vendors’ goodwill to provide you with free
licenses.
�
If you give others access to this software, we will lose the
ability to provide software to future generations at ICE and you
will destroy relationships that we have spent years cultivating.
Environment Variables
Now you need to set environment variables to configure your
operating system to use Knitro and AMPL. Environment variables
provide state information to the operating system:
�
Specify configuration information:
�
�
�
Environment variables are set differently on different
operations systems but they work by associating a variable
name with value:
�
�
�
Location of key resources such as libraries or license files
Tell the OS where to find executables (i.e. programs to run)
using a special variable names PATH
Linux & OS/X: set environment variables in a special file
named .bashrc (or sometimes .profile)
Windows: set via control panel
The gory details will be explained below
Overview of Software Environment
Setup environment variables for your installation:
�
ampl and knitroampl must be in your PATH
�
Set ZIENA_LICENSE environment variable to the full path to
license.txt
�
Specify the full path to the Knitro lib directory so that
MATLAB can use Knitro:
Linux: Set LD_LIBRARY_PATH accordingly
Mac OS/X: Set DYLD_LIBRARY_PATH
Windows: Set PATH
�
See OS-specific examples below
�
If all else fails, RTFM (Read The F****** Manual) which is
available in the ${KNITRO_DIR}/knitro-8.0.0-z/doc/
Knitro80_UserManual.pdf, where ${KNITRO_DIR) is the
directory where you installed Knitro 8.0. Read the section on
Stand-Alone Licenses.
Windows Vista and Windows 7 Setup
On Windows, you need to add the locations for ampl, knitroampl,
and the Knitro lib directory via the PATH environment variable:
1. At Windows Desktop, right-click My Computer
2. Select Properties
3. Click the Advanced System Settings in left pane.
4. In the System Properties window select the Advanced tab
5. Then click on Environment Variables
6. Under System Variables modify Path to include the FULL path
to the Knitro lib and knitroampl folders.
Reminder: You need double quotes around Windows paths which
have spaces in them (except on Windows 7), e.g.:
...;"c:\Program Files\...";....
Warning: make sure you separate folders by a semicolon
Warning: Make sure you set these as System and not User
environment variables
Windows XP Setup
On Windows, you need to add the locations for ampl, knitroampl,
and the Knitro lib directory via the PATH environment variable:
1. At Windows Desktop, right-click My Computer
2. Select Properties
3. Click the Advanced tab.
4. Then click on Environment Variables
5. Under System Variables modify Path to include the FULL path
to the Knitro lib and knitroampl folders.
Reminder: You need double quotes around Windows paths which
have spaces in them (except on Windows 7), e.g.:
...;"c:\Program Files\...";....
Warning: make sure you separate folders by a semicolon
Warning: Make sure you set these as System and not User
environment variables
Linux Setup
To set environment variables:
�
Edit ~/.bashrc and ~/.profile: I have not tested that both
are required, but this is the case on Mac OS/X.
�
The ‘\’ is just to escape the new line so the text will fit on the
screen. Each export statement should be an entire line.
Example
# License file for AMPL and KNITRO
export ZIENA_DIR=/opt/ziena
export ZIENA_LICENSE=${ZIENA_DIR}/knitro-8.0.0-z/\
ziena_license.txt
export PATH=${ZIENA_DIR}/ampl-z:${ZIENA_DIR}\
knitro-8.0.0-z/knitroampl:$PATH
# KNITRO for MATLAB
export LD_LIBRARY_PATH=${ZIENA_DIR}knitro-8.0.0-z/\
lib:$LD_LIBRARY_PATH
Mac OS/X Setup
To set environment variables:
� Edit ~/.bashrc and ~/.profile.
� On Mac OS/X, xterm will only recognize the settings in
.bashrc but MATLAB/Knitro requires them in .profile.
� The ‘\’ is just to escape the new line so the text will fit on the
screen. Each export statement should be an entire line.
Example
# License file for AMPL and KNITRO
export ZIENA_DIR=/Users/bss/Tools/ziena
export ZIENA_LICENSE=${ZIENA_DIR}/knitro-8.0.0-z/\
ziena_license.txt
export PATH=${ZIENA_DIR}/ampl-z:${ZIENA_DIR}\
knitro-8.0.0-z/knitroampl:$PATH
# KNITRO for MATLAB
export DYLD_LIBRARY_PATH=${ZIENA_DIR}/knitro-8.0.0-z/\
lib:$DYLD_LIBRARY_PATH
MATLAB + Knitro Setup
To use Knitro from MATLAB:
�
Specify path to knitro library, which is in the lib directory of
the knitro installation, via File>Set Path in MATLAB
�
On Windows, make sure the knitro DLL is in your path
�
See following slides for workarounds for known problems on
Windows and OS/X
�
On OS/X you must start MATLAB from the Terminal, e.g.
use open /Applications/MATLAB_R2011a.app/ to launch
MATLAB. Update with the path to your MATLAB installation.
�
Test by running the following in the MATLAB command
window:
ktrlink( @(x)cos(x), 1 )
MATLAB Bug on OS/X
NOTE: there is a bug in some versions of MATLAB under OS/X
�
MATLAB ignores environment variables when you launch it by
clicking on the icon in the dock
�
Workaround:
�
�
Start Terminal
Then invoke MATLAB from the Terminal command prompt
$ open /Applications/MATLAB_R2011b.app/
$ matlab &
# Sometimes this works
Knitro Bug on Windows
If MATLAB under Windows cannot find Knitro:
�
Copy knitro800.dll to knitro520.dll
�
The name knitro520.dll will depend on the version of
MATLAB you are using. See
${KNITRO_DIR}/examples/Matlab/README for details.
�
Try running the function ktrlink() from the MATLAB
prompt to verify everything is setup
�
Only applies to older versions of MATLAB and Knitro
�
This occurs for MATLAB R2009 and earlier
Knitro Bug on Linux
If MATLAB under Linux cannot find Knitro:
�
See the README file in ${KNITRO_DIR}/examples/Matlab
�
You need to copy libknitro.so.8.0.0 to the filename MATLAB
expects. The name of the file depends on your version of
MATLAB:
�
R2008a, R2008b, and R2009a:
cd ${KNITRO_DIR}/lib
ln -s libknitro.so.8.0.0 libknitro.so.5
�
R2009b, R2010a, or R2010b:
cd ${KNITRO_DIR}/lib
ln -s libknitro.so.8.0.0 libknitro.so.6
Test the Installation
To make sure your installation works:
1. Open a Terminal (Linux/Mac) or command console (Windows:
i.e., execute cmd in Start>Run)
2. cd to the root of your installation
3. Run the example program for knitroampl
cd your/path/to/knitro-7.0.0-z/knitroampl
knitroampl testproblem
4. Test ampl:
cd /your/path/to/ampl-z
./ampl
ampl: model testproblemLP.mod;
ampl: display XB;
ampl: solve;
ampl: display XB, XC;
ampl: quit;
NOTE: make sure you use ‘\’ instead of ‘/’ on Windows. . .
Download