CVX: quickstart 1 Least squares

CVX: quickstart1 Least squares
単純なLeast squares.これならx=A\b;と解いてもいけちゃう.
minimize ||Ax-b||2

  1. m = 16; n = 8;
  2. A = randn(m,n);
  3. b = randn(m,1);
  4. cvx_begin
  5. variable x(n);
  6. minimize( norm(A*x-b) );
  7. cvx_end

cvx_beginとcvx_endの間にConvex optimizationの定義や宣言をする.
全ての変数はobjective functionやconstraintsを定義する前に宣言しなければならない.

  • cvx_optval: Objective functionの値
  • cvx_status: 計算結果の状態(Solved, Unbounded, Infeasible).
  • cvx_slvtol: solverによって得られた許容値.
  • cvx_slvitr: 解くのにかかったiterationの回数.

まー初回はこんなもん.単なるHello Worldみたいなもん.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s