How to Use KNITRO with MATLAB

Overview

KNITRO® is a solver for nonlinear optimization from Ziena Optimization Inc. It is a library of routines that can be called from the MATLAB® Optimization Toolbox using the ktrlink external interface function.

Beginning with MATLAB R2008a, the SSCC configured MATLAB to use KNITRO when it starts up. Do not set the system path to include the KNITRO libraries. That is done for you.

Getting Started

Now you're ready to run an example that's designed to be modified for your own use.

Example

Ziena provides example code that illustrates one way to call KNITRO from a MATLAB application. Copy three small files from /opt/knitro/examples/Matlab/ into your home directory. The following command copies those files into an already-existing subdirectory named Optimization:

 $ cp /opt/knitro/examples/Matlab/* Optimization/

The file mydriver.m is a simple example that calls KNITRO's MEX interface. It demonstrates how to formulate a model in MATLAB and call ktrlink to solve the model.

The file knitro.opt is a sample KNITRO input file of user options. Contents can be modified using any text editor. The file is read by mydriver.m.

The file README.txt contains descriptions of the files in this example.

Change your directory to Optimization and start up matlab. Then simply run the MATLAB command mydriver; and you'll see KNITRO output.

Now you can modify the driver and user option files to fit your own models.

Last Updated: 20 November 2008

Information Technology 1800 Sherman Avenue Evanston, Illinois 60201 | Contact Us

Northwestern Home | Calendar: Plan-It Purple | Online Directory | Search

World Wide Web Disclaimer and University Policy Statements

© 2009 Northwestern University