<p>(key: Y = Yes, N = No, E = Experimental, P = CVX Professional license required, * = Mosek 7 or later is required.)</p>
<p>Each solver has different capabilities and different levels of performance. For instance,
SeDuMi <aclass="reference internal"href="credits.html#stu99"id="id3">[Stu99]</a>, SDPT3 <aclass="reference internal"href="credits.html#ttt03"id="id4">[TTT03]</a>, and MOSEK 7 support all of the continuous (non-integer) models
that CVX itself supports, while Gurobi is more limited, in that it does not support semidefinite
constraints; and GLPK is limited even further. On the other hand, Gurobi, GLPK, and
MOSEK support integer consraints, while SeDuMi and SDPT3 do not.</p>
<p>SeDuMi and SDPT3 are included with the standard CVX distribution, so you do not need
to download an additional solver to start using CVX. We have also entered into contractual
arrangements with the developers of Gurobi and MOSEK that allow us to ship their binaries
with CVX as well, but using those solvers requires a CVX Professional license. Due to
license differences, we are <em>not</em> able to supply GLPK with CVX. However,</p>
<p>If you are having difficulty with one solver, <em>please try another</em>. No one solver performs
better than the others on <em>every</em> model CVX can generate—including commercial solvers.
That said, if you encounter a problem that one solver can handle well and another
cannot, please send us a bug report (see <aclass="reference internal"href="support.html#support"><em>Support</em></a>) and we will forward the
results to the solver’s authors.</p>
<p>We have created special sections in this user guide for using Gurobi and MOSEK with CVX:</p>
<ulclass="simple">
<li>Gurobi: <aclass="reference internal"href="gurobi.html#gurobi"><em>Using Gurobi with CVX</em></a></li>
<li>Mosek: <aclass="reference internal"href="mosek.html#mosek"><em>Using MOSEK with CVX</em></a></li>
</ul>
<p>Support for GLPK should be considered experimental, and has been provided primarly to support
upcoming Octave capability (that is <em>not</em> ready yet.)</p>
</div>
<divclass="section"id="selecting-a-solver">
<spanid="solver-selection"></span><h2>Selecting a solver<aclass="headerlink"href="#selecting-a-solver"title="Permalink to this headline">¶</a></h2>
<p>The default solver is currently SDPT3. We have found that SeDuMi is faster for most
problems, but unfortunately not as reliable. None of the solvers are perfect, however,
and you may find for your application that another solver is preferred.</p>
<p>To see which solver is currently selected, simply type</p>
<p>The <ttclass="docutils literal"><spanclass="pre">cvx_solver</span></tt> command is case insensitive, so <ttclass="docutils literal"><spanclass="pre">cvx_solver</span><spanclass="pre">SeDuMi</span></tt>
will work just fine as well.</p>
<p>If you issue this command inside a model—that is, between <ttclass="docutils literal"><spanclass="pre">cvx_begin</span></tt> and
<ttclass="docutils literal"><spanclass="pre">cvx_end</span></tt> it will change the solver <em>only</em> for that model; the next model will
use the previous choice. If, only the other hand, you issue a <ttclass="docutils literal"><spanclass="pre">cvx_solver</span></tt> command
<em>outside</em> of a model, it will change the solver used for the remainder of your Matlab
session (or until you change it again).</p>
<p>If you would like to change the default solver <em>permanently</em>—that is, so that it remains
the default even if you quit and re-start Matlab—then make sure it is set properly,
<p>This command saves not only your solver choice, but also your settings for <ttclass="docutils literal"><spanclass="pre">cvx_expert</span></tt>,
<ttclass="docutils literal"><spanclass="pre">cvx_power_warning</span></tt>, and <ttclass="docutils literal"><spanclass="pre">cvx_precision</span></tt> as well.</p>
<spanid="solver-output"></span><h2>Controlling screen output<aclass="headerlink"href="#controlling-screen-output"title="Permalink to this headline">¶</a></h2>
<p>Once you gain confidence in using CVX and start incorporating it
into your larger algorithms and programs, you are likely going to want
to silence the messages it delivers to the screen. To do so, simply add
the <ttclass="docutils literal"><spanclass="pre">quiet</span></tt> keyword to the <ttclass="docutils literal"><spanclass="pre">cvx_begin</span></tt> command; that is,</p>
<p>Previous versions of CVX utilized a separate <ttclass="docutils literal"><spanclass="pre">cvx_quiet</span></tt> command
and that command is still available in this version as well, if you
prefer it. Entering <ttclass="docutils literal"><spanclass="pre">cvx_quiet</span><spanclass="pre">true</span></tt> suppresses screen output from the
solver, while entering <ttclass="docutils literal"><spanclass="pre">cvx_quiet</span><spanclass="pre">false</span></tt> restores the screen output.
If you enter these commands within a model—that is, between
<ttclass="docutils literal"><spanclass="pre">cvx_begin</span></tt> and <ttclass="docutils literal"><spanclass="pre">cvx_end</span></tt>—it will affect only that model. If you
enter it <em>outside</em> of a model, it will affect all subsequent models.
Entering cvx_quiet with no arguments returns the current setting.</p>
</div>
<divclass="section"id="interpreting-the-results">
<spanid="interpreting"></span><h2>Interpreting the results<aclass="headerlink"href="#interpreting-the-results"title="Permalink to this headline">¶</a></h2>
<p>After a complete CVX specification has been entered and the
cvx_end command issued, the solver is called to generate a numerical
result. It proceeds to replace the variables in your model with the
computed numerical values, and creates the variable cvx_optval
containing the value of the objective function. It also summarizes the
result of its efforts in the form of a string named <ttclass="docutils literal"><spanclass="pre">cvx_status</span></tt>. The
possible values of <ttclass="docutils literal"><spanclass="pre">cvx_status</span></tt> are as follows:</p>
<dd><pclass="first">The solver has determined that the problem is unbounded. The value
of <ttclass="docutils literal"><spanclass="pre">cvx_optval</span></tt> is set to <ttclass="docutils literal"><spanclass="pre">-Inf</span></tt> for minimizations, and <ttclass="docutils literal"><spanclass="pre">+Inf</span></tt>
for maximizations. (Feasibility problems, by construction, never
produce an <ttclass="docutils literal"><spanclass="pre">Unbounded</span></tt> status.) The values of any dual variables
are replaced with <ttclass="docutils literal"><spanclass="pre">NaN</span></tt>, as the dual problem is in fact
infeasible.</p>
<pclass="last">For unbounded problems, CVX stores an <em>unbounded direction</em> into
the problem variables. This is is a <em>direction</em> along which the
feasible set is unbounded, and the optimal value approaches
<spanclass="math">\(\pm\infty\)</span>. It is important to understand that this value is
very likely <em>not</em> a feasible point. If a feasible point is required,
the problem should be re-solved as a feasibility problem by omitting
the objective. Mathematically speaking, given an unbounded direction
<spanclass="math">\(v\)</span> and a feasible point <spanclass="math">\(x\)</span>, <spanclass="math">\(x+tv\)</span> is feasible
for all <spanclass="math">\(t\geq0\)</span>, and the objective tends to <spanclass="math">\(-\infty\)</span>
(for minimizations; <spanclass="math">\(+\infty\)</span> for maximizations) as
<dd><pclass="first">The problem has been proven to be infeasible through the discovery
of an unbounded direction. The values of the variables are filled
with <ttclass="docutils literal"><spanclass="pre">NaN</span></tt>, and the value of <ttclass="docutils literal"><spanclass="pre">cvx_optval</span></tt> is set to <ttclass="docutils literal"><spanclass="pre">+Inf</span></tt>
for minimizations and feasibility problems, and <ttclass="docutils literal"><spanclass="pre">-Inf</span></tt> for
maximizations.</p>
<pclass="last">Associated with a provably infeasible problem is an <em>unbounded dual
direction</em>. Appropriate components of this direction are stored in
the dual variables. Similarly to the <ttclass="docutils literal"><spanclass="pre">Unbounded</span></tt> case, it is
important to understand that the unbounded dual direction is very
<dd>The presolver has determined that the problem has more equality
constraints than variables, which means that the coefficient matrix
of the equality constraints is singular. In practice, such problems
are often, but not always, infeasible. Unfortunately, solvers
typically cannot handle such problems, so a precise conclusion
cannot be reached. The situations that most commonly produce an
Overdetermined result are discussed in <aclass="reference internal"href="advanced.html#overdetermined"><em>Overdetermined problems</em></a>.</dd>
</dl>
</div>
<divclass="section"id="controlling-precision">
<spanid="solver-precision"></span><h2>Controlling precision<aclass="headerlink"href="#controlling-precision"title="Permalink to this headline">¶</a></h2>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">We consider the modification of solver precision to be an advanced feature, to be
used sparingly, if at all—and only after you have become
comfortable building models in CVX.</p>
</div>
<p>Numerical methods for convex optimization are not exact; they compute
their results to within a predefined numerical precision or tolerance.
Upon solution of your model, the tolerance level the solver has achieved
is returned in the <ttclass="docutils literal"><spanclass="pre">cvx_slvtol</span></tt> variable. Attempts to interpret this
tolerance level in any absolute sense are not recommended. For one
thing, each solver computes it differently. For another, it depends
heavily on the considerable transformations that CVX applies to your
model before delivering it to the solver. So while you may find its
value interesting we strongly discourage dependence upon it within your
applications.</p>
<p>The tolerance levels that CVX selects by default have been inherited
from some of the underlying solvers being used, with minor modifications.
CVX actually considers <em>three</em> different tolerance levels
<li>The <em>solver tolerance</em><spanclass="math">\(\epsilon_{\text{solver}}\)</span> is the level
requested of the solver. The solver will stop as soon as it achieves
this level, or until no further progress is possible.</li>
<li>The <em>standard tolerance</em><spanclass="math">\(\epsilon_{\text{standard}}\)</span> is the
level at which CVX considers the model solved to full precision.</li>
<li>The <em>reduced tolerance</em><spanclass="math">\(\epsilon_{\text{reduced}}\)</span> is the
level at which CVX considers the model “inaccurately” sovled,
returning a status with the <ttclass="docutils literal"><spanclass="pre">Inaccurate/</span></tt> prefix. If this tolerance
cannot be achieved, CVX returns a status of <ttclass="docutils literal"><spanclass="pre">Failed</span></tt>, and the
values of the variables should not be considered reliable.</li>
</ul>
<p>(See <aclass="reference internal"href="#interpreting"><em>Interpreting the results</em></a> for more information about the
status messages.) Typically,
<spanclass="math">\(\epsilon_{\text{solver}}=\epsilon_{\text{standard}}\)</span>, but setting
<spanclass="math">\(\epsilon_{\text{standard}}<\epsilon_{\text{solver}}\)</span> has a useful
interpretation: it allows the solver to search for more accurate
solutions without causing an <ttclass="docutils literal"><spanclass="pre">Inaccurate/</span></tt> or <ttclass="docutils literal"><spanclass="pre">Failed</span></tt> condition if
<p>This is considered good coding etiquette in a larger application where
multiple CVX models at multiple precision levels may be employed. Of
course, a simpler but equally courteous approach is to call
<ttclass="docutils literal"><spanclass="pre">cvx_precision</span></tt> within the CVX model, as described above, so that
its effect lasts only for that model.</p>
</div>
<divclass="section"id="advanced-solver-settings">
<spanid="solver-settings"></span><h2>Advanced solver settings<aclass="headerlink"href="#advanced-solver-settings"title="Permalink to this headline">¶</a></h2>
<divclass="admonition warning">
<pclass="first admonition-title">Warning</p>
<pclass="last">This is an <strong>advanced topic</strong> for users who have a deep understanding of the
underlying solver they are using, or who have received specific advice from
the solver’s developer for improving performance. Improper use of the
<ttclass="docutils literal"><spanclass="pre">cvx_solver_settings</span></tt> command can cause unpredictable results.</p>
</div>
<p>Solvers can be tuned and adjusted in a variety of ways. Solver vendors attempt to select
default settings that will provide good performance across a broad range of
problems. But no solver, and no choice of settings, will perform well for every
possible model. On occasion, it may be worthwhile to give a particular special instructions
to improve its performance for a specific application. Unfortunately, such settings differ
from solver to solver, so there is no way for CVX to provide this ability in a verifiable,
reliable, global fashion.</p>
<p>Nevertheless, using the new <ttclass="docutils literal"><spanclass="pre">cvx_solver_settings</span></tt> command, you can customize a solver’s
settings when a specific model demands it. We cannot emphasize enough that this is an
<em>expert</em> feature to be employed by experienced modelers only. Indeed, if you are an
expert, you understand that these warnings are essential:</p>
<ulclass="simple">
<li>CVX does not check the correctness of the settings you supply. If the solver rejects the
settings, CVX will fail until you change or remove those settings.</li>
<li>There is no guarantee that altering the settings will improve performance in any
way; indeed, it can make the performance worse.</li>
<li>CVX Research provides <em>no</em> documentation on the specific settings available for each
solver; you will have to consult the solver’s own documentation for this.</li>
<li>The settings set here <em>override</em> any default values CVX may have chosen for each solver.
Thus in certain cases, using this feature this may actually confuse CVX and cause it to
misinterpret the results. For this reason, we cannot support all possible
combinations of custom settings.</li>
<li>Unless you have turned off solver output completely, CVX will warn you if any custom
settings are in effect every time you solve model.</li>
</ul>
<p>With this warning out of the way, let us introduce <ttclass="docutils literal"><spanclass="pre">cvx_solver_settings</span></tt>. Typing</p>
<p><ttclass="docutils literal"><spanclass="pre">{name}</span></tt> must be a valid MATLAB variable/field name. <ttclass="docutils literal"><spanclass="pre">{value}</span></tt> can be <em>any</em> valid Matlab
object; CVX does not check its value in any way.</p>
<p>To clear all custom settings for the active solver, type</p>
<p>The settings created by the <ttclass="docutils literal"><spanclass="pre">cvx_solver_settings</span></tt> command enjoy the same scope as
<ttclass="docutils literal"><spanclass="pre">cvx_solver</span></tt>, <ttclass="docutils literal"><spanclass="pre">cvx_precision</span></tt>, and so forth. For instance, if you use this command
<em>within</em> a model—between <ttclass="docutils literal"><spanclass="pre">cvx_begin</span></tt> and <ttclass="docutils literal"><spanclass="pre">cvx_end</span></tt>—the changes will apply only
to that particular model. If you issue the command <em>outside</em> of a particular model, the
change will persist through the end of the MATLAB session (or until you change it again).
Finally, if you use the <ttclass="docutils literal"><spanclass="pre">cvx_save_prefs</span></tt> command, any custom settings you have added
will be saved and restored the next time you start Matlab.</p>