Each of the examples listed in the tree below links to a dedicated page that includes the full source code, followed by a listing of the output generated by MATLAB when that code is run. Entries listed as “utilities” are functions used to support the examples that precede them, and are not given dedicated pages. Clicking on the corresponding “(.m)” link after each title retrieves just the source code itself.
Of course, to run any examples yourself, you will need to have CVX installed; so if necessary, please proceed to the CVX download page to get it. The package includes a complete copy of these examples—including this web page, which can then be browsed off-line.
These examples are public domain. You are free to use them in any way you wish; but when you do, we request that you give appropriate credit to the authors. A number of people have contributed to the examples in this library, including Lieven Vandenberghe, Joƫlle Skaf, Argyris Zymnis, Almir Mutapcic, Michael Grant, and Stephen Boyd.
The list below is dynamic.
Clicking on the
icons will expand/collapse directories to reveal/hide their contents.
Expand all
Collapse all
Antenna array design
Reference: Antenna Array Pattern Synthesis via Convex Optimization
Reference: FIR Filter Design via Spectral Factorization and Convex Optimization
Minimize beamwidth of an array with arbitrary 2-D geometry (ant_array_min_beamwidth.m)
Minimize sidelobe level of a uniform linear array via spectral factorization (line_array_spec_fact.m)
Minimize sidelobe level of an FIR broadband far-field antenna array (broadband_array_min_sidelobe.m)
Minimize sidelobe level of an array with arbitrary 2-D geometry (ant_array_min_sidelobe.m)
Minimize thermal noise power of an array with arbitrary 2-D geometry (ant_array_min_therm_noise.m)
Utility: Plot a polar plot of an antenna array sensitivity (polar_plot_ant.m)
Utility: Spectral factorization using Kolmogorov 1939 approach (spectral_fact.m)
Circuit design
Reference: Optimal Wire and Transistor Sizing for Circuits with Non-Tree Topology
Reference: Geometric Programming and its Applications to EDA Problems
Reference: Digital Circuit Optimization via Geometric Programming
Combined sizing of drivers, repeaters, and wire (wire_driver_sizing.m)
Digital circuit sizing for an inverter chain (GP) (inverter_chain_sizing.m)
Elmore delay sizing for a straight wire (GP) (elmore_straight_wire.m)
Tri-state bus sizing and topology design (tristate_bus_sizing.m)
Two-input NAND gate sizing (GP) (simple_NAND2_gate_design.m)
Utility: Computes the step response of a linear system (simple_step.m)
Utility: Plots four different taper desings on a single graph. (plot_four_tapers.m)
Figures, examples, and exercises from the book Convex Optimization
Chapter 4: Convex optimization problems
Section 4.3.1: Compute and display the Chebyshev center of a 2D polyhedron (chebyshev_center_2D.m)
Section 4.3.1: Compute the Chebyshev center of a polyhedron (chebyshev_center.m)
Section 4.5.4: Design of a cantilever beam: recursive formulation (GP) (cantilever_beam_rec.m)
Section 4.5.4: Frobenius norm diagonal scaling (GP) (frob_norm_diag_scaling.m)
Section 4.5.4: Minimum spectral radius via Peron-Frobenius theory (GP) (min_spec_rad_ppl_dynamics.m)
Section 4.6.3: Find the fastest mixing Markov chain on a graph (fastest_mixing_MC.m)
Exercise 4.27: Matrix fractional minimization using second-order cone programming (ex_4_27.m)
Exercise 4.31: Design of a cantilever beam (GP) (cantilever_beam.m)
Exercise 4.38(b): Linear matrix inequalities with one variable (ex_4_38.m)
Exercise 4.3: Solve a simple QP with inequality constraints (ex_4_3.m)
Exercise 4.47: Maximum determinant PSD matrix completion (max_det_psd_completion.m)
Exercise 4.57: Capacity of a communication channel (channel_capacity.m)
Exercise 4.5: Show the equivalence of 3 convex problem formations (ex_4_5.m)
Exercise 4.60: Log-optimal investment strategy (logopt_investment.m)
Utility: Plots a cantilever beam as a 3D figure. (cantilever_beam_plot.m)
Chapter 5: Duality
Section 5.2.5: Mixed strategies for matrix games (matrix_games.m)
Section 5.2.5: Mixed strategies for matrix games (LP formulation) (matrix_games_LP.m)
Examples 5.6,5.8: An l_p norm approximation problem (norm_approx.m)
Exercise 5.19c: Markovitz portfolio optimization w/ diversification constraint (ex_5_19.m)
Exercise 5.1d: Sensitivity analysis for a simple QCQP (ex_5_1.m)
Exercise 5.33: Parametrized l1-norm approximation (ex_5_33.m)
Exercise 5.39: SDP relaxations of the two-way partitioning problem (ex_5_39.m)
Chapter 6: Approximation and fitting
Section 6.1.2: Residual minimization with deadzone penalty (deadzone.m)
Figure 6.15: A comparison of stochastic and worst-case robust approximation (fig6_15.m)
Figure 6.24: Fitting a convex function to given data (convex_interpolation.m)
Figure 6.2: Penalty function approximation (penalty_comp_cvx.m)
Figures 6.11-6.14: Total variation reconstruction (tv_cvx.m)
Figures 6.21-6.23: Basis pursuit using Gabor functions (basispursuit.m)
Example 6.2: Robust regression using the Huber penalty (fig6_5.m)
Example 6.6: Comparison of worst-case robust, Tikhonov, and nominal least squares (wcrobls.m)
Example 6.9: Bounding consumer preference (preference_regions.m)
Chapter 7: Statistical estimation
Section 7.1.1: Counting problems with Poisson distribution (counting_problem_poisson.m)
Section 7.1.1: Covariance estimation for Gaussian variables (ML_covariance_est.m)
Section 7.4.3: Probability bounds example with Voronoi diagram (probbounds.m)
Figure 7.1: Logistic regression (GP version) (logistics_gp.m)
Utility: Computes Chebyshev lower bounds on probability vectors (cheb.m)
Utility: Computes Chernoff upper bounds on probability (cher.m)
Utility: estimates probability than random vector x in R2 (montecarlo.m)
Chapter 8: Geometric problems
Section 8.1.1: Separating a point from a polyhedron (separate_pt_poly.m)
Section 8.2.2: Separating polyhedra in 2D (separate_poly_2D.m)
Section 8.5.3: Analytic center of a set of linear inequalities (analytic_center.m)
Figure 8.10: Approximate linear discrimination via linear programming (svm_1.m)
Figure 8.11: Approximate linear discrimination via support vector classifier (svm_2.m)
Figure 8.17: Fourth-order placement problem (placement_quar.m)
Figure 8.9: Robust linear discrimination problem (robust_lin_discr.m)
Example 8.7: Floorplan generation test script (test_floorplan.m)
Euclidean distance between polyhedra in 2D (eucl_dist_poly_2D.m)
Euclidean projection on the nonnegative orthant (eucl_proj_cone1.m)
Euclidean projection on the semidefinite cone (eucl_proj_cone2.m)
Maximum volume inscribed ellipsoid in a polyhedron (max_vol_ellip_in_polyhedra.m)
Minimum volume ellipsoid covering a finite set (min_vol_elp_finite_set.m)
Minimum volume ellipsoid covering union of ellipsoids (min_vol_union_ellip.m)
Quadratic discrimination (separating ellipsoid) (quad_discr.m)
Solve a floor planning problem given graphs H & V (floor_plan_graphs.m)
Utility: Computes a minimum-perimeter bounding box subject to positioning constraints (floorplan.m)
Data: data_floorplan_32.mat
Data: data_floorplan_60.mat
Chapter 11: Interior-point methods
Filter design
Reference: FIR Filter Design via Spectral Factorization and Convex Optimization
Reference: EE364 lecture, Filter design and equalization
Chebychev design of an FIR filter given a desired H(w) (fir_chebychev_design.m)
Design a 1/f spectrum shaping (pink-noise) filter (one_over_f_filter.m)
Maximize stopband attenuation of a bandpass IIR filter (iir_mag_design_bandpass_max_atten.m)
Maximize stopband attenuation of a linear phase lowpass FIR filter (fir_lin_phase_lowpass_max_atten.m)
Maximize stopband attenuation of a lowpass FIR filter (magnitude design) (fir_mag_design_lowpass_max_atten.m)
Maximize stopband attenuation of a lowpass IIR filter (iir_mag_design_lowpass_max_atten.m)
Minimize order of a linear phase lowpass FIR filter (fir_lin_phase_lowpass_min_order.m)
Minimize order of a lowpass FIR filter (magnitude design) (fir_mag_design_lowpass_min_order.m)
Minimize stopband ripple of a linear phase lowpass FIR filter (fir_lin_phase_lowpass_min_ripple.m)
Minimize transition bandwidth of a linear phase lowpass FIR filter (fir_lin_phase_lowpass_min_trans.m)
Utility: Spectral factorization using Kolmogorov 1939 approach. (spectral_fact.m)
Examples from A Tutorial on Geometric Programming
Digital circuit sizing (vectorized) (simple_dig_ckt_sizing_vect.m)
Elmore delay sizing for an interconnect network. (elmore_interconnect.m)
Floor planning with an optimal trade-off curve. (floor_planning.m)
Optimal doping profile optimization with current gain constraint. (beta_min_odp.m)
Simple power control in communication systems via GP. (power_control.m)
Graph Laplacian eigenvalue optimization
Reference: Convex Optimization of Graph Laplacian Eigenvalues
FDLA and FMMC solutions for a 50-node, 200-edge graph (larger_example.m)
FDLA and FMMC solutions for a 64-node, 95-edge cut-grid graph (cut_grid_example.m)
FDLA and FMMC solutions for an 8-node, 13-edge graph (small_example.m)
Utility: Computes fastest mixing Markov chain (FMMC) edge weights (fmmc.m)
Utility: Computes the Metropolis-Hastings heuristic edge weights (mh.m)
Utility: Computes the constant edge weight that yields fastest averaging. (best_const.m)
Utility: Computes the fastest distributed linear averaging (FDLA) edge weights (fdla.m)
Utility: Computes the maximum-degree heuristic edge weights (max_deg.m)
Utility: Generate a cut-grid graph for the ICM 2006 talk example (cut_grid_data.m)
Utility: Plots a graph with each edge width proportional to its weight. (plotgraph.m)
Examples employing logarithms, exponentials, and entropy functions
Sparse solution heuristics
Example from Trend Filtering
Miscellaneous examples
Builds a norm minimization tradeoff curve (regularized_norm_tradeoff.m)
Builds and solves a simple inequality-constrained linear program (simple_LP2.m)
Builds and solves a simple least-squares problem using cvx (simple_LS.m)
Equality constrained norm minimization. (equality_constr_norm_min.m)
Minimal phase spectral factorization (min_phase_spectral_fact.m)