Skip to content

Instantly share code, notes, and snippets.

@cshjin
Created July 11, 2017 18:34
Show Gist options
  • Save cshjin/0257f0b4f02a2dadd4bd30de851b4ac4 to your computer and use it in GitHub Desktop.
Save cshjin/0257f0b4f02a2dadd4bd30de851b4ac4 to your computer and use it in GitHub Desktop.
CVX test
clear;
has_quadprog = exist( 'quadprog' ) == 2 | exist( 'quadprog' ) == 3;
has_linprog = exist( 'linprog' ) == 2 | exist( 'linprog' ) == 3;
rnstate = randn( 'state' ); randn( 'state', 1 );
s_quiet = cvx_quiet(true);
s_pause = cvx_pause(false);
cvx_clear; echo on
b = [2; 0; 2; 0];
cvx_begin
variable x(2)
variable y(2)
minimize(norm([x;y]-b));
subject to
norm(x) <= 1;
norm(y) <= 1;
cvx_end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment