<spanid="gurobi"></span><h1>Using Gurobi with CVX<aclass="headerlink"href="#using-gurobi-with-cvx"title="Permalink to this headline">¶</a></h1>
<divclass="section"id="about-gurobi">
<h2>About Gurobi<aclass="headerlink"href="#about-gurobi"title="Permalink to this headline">¶</a></h2>
<p><aclass="reference external"href="http://www.gurobi.com">Gurobi Optimization</a> was founded in 2008 by some of the most
experienced and respected members of the optimization community. The Gurobi solver quickly became an industry performance leader in linear, quadratic, and mixed-integer programming. Gurobi is a fantastic solver for use with CVX, particularly with the new integer and binary variable capability added in CVX 2.0.</p>
<p>Using CVX with Gurobi requires both a CVX Professional license and a
Gurobi license. Please visit <aclass="reference external"href="http://cvxr.com/cvx/licensing">Licensing</a> for information about
CVX licensing, and Gurobi’s <aclass="reference external"href="http://www.gurobi.com/products/licensing-and-pricing/licensing-overview">Licensing Overview</a>
page for information about Gurobi licenses.</p>
<p>Academic users can obtain both licenses at no charge. An academic
CVX Professional license is obtained by submitting an <aclass="reference external"href="http://cvxr.com/cvx/academic">Academic License Request</a>.
For instructions on obtaining an academic license for Gurobi, please see
<spanid="gurobilic"></span><h2>Using the bundled version of Gurobi<aclass="headerlink"href="#using-the-bundled-version-of-gurobi"title="Permalink to this headline">¶</a></h2>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">The bundled version of Gurobi can only be used within CVX. If you wish to use Gurobi
outside of CVX as well, you will need a standalone Gurobi installation.</p>
</div>
<p>If you wish to use CVX with the bundled version of Gurobi, you will need three things:</p>
<ulclass="simple">
<li>A CVX Professional Solver Bundle, available <aclass="reference external"href="http://cvxr.com/cvx/download">here</a>.</li>
<li>A Gurobi license code, which is composed of 32 hexidecimal digits in the format
<ttclass="docutils literal"><spanclass="pre">xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</span></tt>. If you purchase a commercial CVX+Gurobi
package, you will receive this code in an email from CVX Research. If you are an
academic user, you will receive it directly from Gurobi.</li>
<li>A CVX Professional license, saved to a convenient location on your local disk.</li>
</ul>
<p>Installation proceeds as follows:</p>
<ul>
<li><pclass="first">First, install CVX in the standard manner according to the directions found in
<aclass="reference internal"href="install.html#install"><em>Installation</em></a>. Do not attempt to install either license at this stage.</p>
</li>
<li><pclass="first">Next, retrieve your Gurobi license key by running the command <ttclass="docutils literal"><spanclass="pre">cvx_grbgetkey</span></tt><em>{code}</em>,
where <em>{code}</em> is the 32-digit Gurobi key. The command will look something like this:</p>
<spanid="gurobistandalone"></span><h2>Using CVX with a standalone Gurobi installation<aclass="headerlink"href="#using-cvx-with-a-standalone-gurobi-installation"title="Permalink to this headline">¶</a></h2>
<p>If you wish to use CVX with a standalone installation of Gurobi, you will
need the following four things:</p>
<ulclass="simple">
<li>A Gurobi installation package, or a pre-existing Gurobi installation.
CVX works with Gurobi 5.0 or later, but use
of the latest version is always recommended.</li>
<li>A Gurobi license code or key file, if you are installing Gurobi for the first time.</li>
<li>A standard CVX package, available <aclass="reference external"href="http://cvxr.com/cvx/download">here</a>.
You do not need the Professional Solver bundle.</li>
<li>A CVX Professional license, saved to a convenient location on your local disk.</li>
</ul>
<p>Installation proceeds as follows:</p>
<ulclass="simple">
<li><em>Install Gurobi</em>. See <aclass="reference external"href="http://www.gurobi.com/documentation/5.5/quick-start-guide/node1">Downloading and Installation</a>
from the Gurobi Quick Start Guide.</li>
<li><em>Install the Gurobi license.</em> See <aclass="reference external"href="http://www.gurobi.com/documentation/5.5/quick-start-guide/node5">How to Obtain and Install a Gurobi License</a>.</li>
<li><em>Connect your Gurobi installation to MATLAB.</em> See <aclass="reference external"href="http://www.gurobi.com/documentation/5.5/quick-start-guide/node120">Setting up Gurobi for MATLAB</a>.</li>
<li><em>Install CVX and/or the CVX Professional license</em>. See <aclass="reference internal"href="install.html#install"><em>Installation</em></a> and <aclass="reference internal"href="install.html#licinstall"><em>Installing a CVX Professional license</em></a>.
Even if these have already been installed, you <em>must</em> at least re-run <ttclass="docutils literal"><spanclass="pre">cvx_setup</span></tt>
so that CVX can locate Gurobi and add it to your solver list.</li>
</ul>
<p>If you complete these steps successfully, <ttclass="docutils literal"><spanclass="pre">cvx_setup</span></tt> will show that Gurobi has been
recognized and added to the solver list. If for some reason installation fails, the
output of <ttclass="docutils literal"><spanclass="pre">cvx_setup</span></tt> will provide diagnostic information that you can use to rectify
the problem. If you are still unable to complete the installation, feel free to contact
<h2>Selecting Gurobi as your default solver<aclass="headerlink"href="#selecting-gurobi-as-your-default-solver"title="Permalink to this headline">¶</a></h2>
<p>Even if Gurobi is successfully added to your solver list, it will not automatically
be selected as your default solver. To change this, type the following two commands