0001 0002 function [C] = optimal_control(P0,pid); 0003 0004 N = size(P0,1); 0005 OneVec = ones(N,1); 0006 0007 %% Optimization problem using CVX package 0008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0009 0010 cvx_solver sdpt3 0011 cvx_begin 0012 variable C(N,N); 0013 minimize(norm(C, 'fro')); 0014 subject to 0015 pid'*(P0+C) == pid'; % equality constraint: pid is the stationary distribution of (P+C) 0016 C*OneVec == 0; %ZeroVec; % equality constraint: C is a zero-row sum matrix 0017 vec(P0+C) >= 0; %vec(ZeroMat); %inequality constraint: P+C is elementwise positive 0018 cvx_end 0019 0020 0021 0022 0023