CVX Installation Instruction

CVX is Matlab-based modelling language, primarily for constructing and solving convex optimization problems. (See http://cvxr.com/cvx/ for more details.) Although installing CVX is fairly straightforward, this page summarizes the key steps. If you come across any problems or issues, please see

Installing Matlab

Matlab is available for free for current students at MIT from IS&T.  Please follow the installation instructions from IS&T that can be found  here .  If you've never used MATLAB before, there are some beginner tutorials and other info .

Installing CVX

After installing Matlab and testing your installation, you are ready to install CVX. Follow the instructions available from CVX Research. Some notes:

addpath <path to MATLAB folder>/MATLAB/cvx
addpath <path to MATLAB folder>/MATLAB/cvx/structures
addpath <path to MATLAB folder>/MATLAB/cvx/lib
addpath <path to MATLAB folder>/MATLAB/cvx/functions
addpath <path to MATLAB folder>/MATLAB/cvx/commands
addpath <path to MATLAB folder>/MATLAB/cvx/builtins

replacing < path to MATLAB folder > as appopriate.

Testing your CVX Installation

You should test your installation after installing to confirm everything works. The easiest way to do this is to navigate to:
_ /Users/VGupta/Documents/MATLAB/cvx/examples _
and run the file simple_LP.m.

The file creates a small linear program (with random coefficients) and solves it. (Look through the code. It is very readable.) If all goes well, it should produce some output like this:

Calling sedumi: 100 variables, 50 equality constraints
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 50, order n = 101, dim = 101, blocks = 1
nnz(A) = 5000 + 0, nnz(ADA) = 2500, nnz(L) = 1275
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 2.15E+00 0.000
1 : -1.79E-01 8.07E-01 0.000 0.3755 0.9000 0.9000 -0.34 1 1 2.0E+01
2 : 5.26E-01 2.55E-01 0.000 0.3164 0.9000 0.9000 0.86 1 1 5.8E+00
3 : 6.06E-01 8.08E-02 0.000 0.3166 0.9000 0.9000 1.34 1 1 1.5E+00
4 : 1.17E+00 3.08E-02 0.000 0.3810 0.9000 0.9000 1.48 1 1 4.7E-01
5 : 1.71E+00 1.55E-02 0.000 0.5046 0.9000 0.9000 1.35 1 1 2.1E-01
6 : 1.93E+00 6.81E-03 0.000 0.4385 0.9000 0.9000 1.21 1 1 8.7E-02
7 : 2.10E+00 2.89E-03 0.000 0.4236 0.9000 0.9000 0.91 1 1 4.1E-02
8 : 2.24E+00 9.22E-04 0.000 0.3193 0.9000 0.9000 0.73 1 1 1.4E-02
9 : 2.29E+00 1.97E-04 0.000 0.2140 0.9000 0.9000 1.05 1 1 2.9E-03
10 : 2.29E+00 5.97E-05 0.000 0.3027 0.9000 0.9000 0.98 1 1 8.8E-04
11 : 2.30E+00 2.34E-06 0.000 0.0392 0.9900 0.9602 1.01 1 1
iter seconds digits c*x b*y
11 0.1 13.2 2.2983746112e+00 2.2983746112e+00

Ax-b

= 8.8e-13, Ay-c_+ = 1.5E-12,

x

= 7.3e+00,

y

= 5.6e+00

Detailed timing (sec)
Pre IPM Post
2.000E-02 9.000E-02 0.000E+00
Max-norms: ||b||=2.043044e+00, ||c|| = 2.290580e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 3.33535.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0.714152

The precise optimal value may be different in your run since the coefficients used are random.

Connecting CVX to Gurobi

To be added.

Questions, Comments and Common Problems

If you come across an error in these installation instructions, please

  1. Email the session leader
  2. If you are certain about the correction, please edit this Wiki document appropriately. Remember to include all pertinent details including any OS or version info.
  3. If you are not certain about the correction, start a comment thread on this page to discuss.