diff --git a/DistributedMinimaxAdaptiveControl.m b/DistributedMinimaxAdaptiveControl.m index 3086f171e0e8f25f625ed18fafb251c84558b289..a0d2cd3c472c48e8be5509189782b32e621fa67f 100644 --- a/DistributedMinimaxAdaptiveControl.m +++ b/DistributedMinimaxAdaptiveControl.m @@ -358,42 +358,34 @@ hold on; tvec = 0:T; % Prepare the legend text for plotting i = 1; -text_1 = '$\left \Vert x^{\dagger}_{'; -text_2 = num2str(i); -text_3 = '}'; -text1 = strcat(text_1, strcat(text_2, text_3)); -text_1 = ' - x^{\star}_{'; -text_2 = num2str(i); +text_1 = '$x^{\dagger} - x^{\star}$'; if(disturbFlag == 1) - text_3 = '} \right \|_{1}$: white noise $w$'; + text_3 = ': white noise $w$'; elseif(disturbFlag == 2) - text_3 = '} \right \|_{1}$: sinusoidal $w$'; + text_3 = ': sinusoidal $w$'; elseif(disturbFlag == 3) - text_3 = '} \right \|_{1}$: step $w$'; + + text_3 = ': step $w$'; end -text2 = strcat(text1, strcat(text_1, strcat(text_2, text_3))); +text2 = strcat(text_1, text_3); legendInfos{i} = [text2]; -plot(tvec, abs(x_minmax(1,:) - x_hinfty(1,:))', 'o-'); +shadedErrorBar(tvec,x_minmax - x_hinfty,{@mean,@std}, 'lineprops','-b','patchSaturation',0.33) tvec = 0:T-1; % Prepare the legend text for plotting i = 1; -text_1 = '$\left \Vert u^{\dagger}_{'; -text_2 = num2str(i); -text_3 = '}'; -text1 = strcat(text_1, strcat(text_2, text_3)); -text_1 = ' - u^{\star}_{'; -text_2 = num2str(i); +text_1 = '$u^{\dagger} - u^{\star}$'; if(disturbFlag == 1) - text_3 = '} \right \|_{1}$: white noise $w$'; + text_3 = ': white noise $w$'; elseif(disturbFlag == 2) - text_3 = '} \right \|_{1}$: sinusoidal $w$'; + text_3 = ': sinusoidal $w$'; elseif(disturbFlag == 3) - text_3 = '} \right \|_{1}$: step $w$'; + text_3 = ': step $w$'; end -text2 = strcat(text1, strcat(text_1, strcat(text_2, text_3))); +text2 = strcat(text_1, text_3); legendInfos{i+1} = [text2]; -plot(tvec, abs(U_minmax(1,:) - u_hinfty(1,:))', 'o-'); +shadedErrorBar(tvec,U_minmax-u_hinfty,{@mean,@std},'lineprops','-r','patchSaturation',0.33) + xlabel('Time'); legend(legendInfos, 'interpreter', 'latex'); @@ -406,45 +398,3 @@ set(a, 'FontSize', 50); % Convert matlab figs to tikz for pgfplots in latex document. matlab2tikz('figurehandle',figure1,'filename','statesControlsDiff.tex' ,'standalone', true, 'showInfo', false); -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % %% Compute the cumulative regret -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% % Define design parameters. -% Q = eye(n); % State penalty matrix -% R = eye(m); % Input penalty matrix -% -% % Initiate model based regret to zero for each model -% cumulativeRegret = zeros(T+1,1); -% -% % Loop through all finite set of linear system models -% inputSum = 0; -% stateSum = 0; -% % Loop through the entire time horizon -% for t = 1:T+1 -% % compute u'Ru and add it to control sum -% if(t < T+1) -% inputSum = inputSum + (U_minmax(:,t) - u_hinfty(:,t))'*R*(U_minmax(:,t) - u_hinfty(:,t)); -% end -% % compute x'Qx and add it to state sum -% stateSum = stateSum + (x_minmax(:,t) - x_hinfty(:,t))'*Q*(x_minmax(:,t) - x_hinfty(:,t)); -% -% % Record the regret incurred upto that time -% cumulativeRegret(t, 1) = stateSum + inputSum; -% end -% -% %% Plot the regret vs time -% Tvec = 0:T; -% figure3 = figure('Color',[1 1 1]); -% plot(Tvec, cumulativeRegret, '-ob'); -% xlabel('Time'); -% ylabel('Regret'); -% hold off; -% a = findobj(gcf, 'type', 'axes'); -% h = findobj(gcf, 'type', 'line'); -% set(h, 'linewidth', 4); -% set(a, 'linewidth', 4); -% set(a, 'FontSize', 40); -% -% %% Convert matlab figs to tikz for pgfplots in latex document. -% matlab2tikz('figurehandle',figure3,'filename','CumRegret.tex' ,'standalone', true, 'showInfo', false); \ No newline at end of file