-
Notifications
You must be signed in to change notification settings - Fork 0
/
testCAQM.m
60 lines (47 loc) · 1.24 KB
/
testCAQM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
clear all;
%% This file
% 1) loads a map
% 2) generates a vector c_+
% 3) cuts convex subpart via z(c) minimization
%% changing cwd to project folder (with README.md)
cd(strcat(fileparts(which(mfilename)),'/../'));
addpath('library');
%% using saved map
try
% Real case R4->R4
load('examples/maps/article_example05_R4_R4.mat');
% Complex case C2->R4, pre-defined c_plus
%load('examples/maps/article_example03_C2_R4.mat')
fprintf('Map load OK\n\n');
catch
disp('Change current folder to folder with README.md');
error('Map load failed');
end
%% obtaining c_plus
try
if ~exist('c_plus')
c_plus = get_max_c_plus(A);
end
fprintf('c_+ search OK: ');
for val=c_plus
fprintf('%.4f ', val);
end
fprintf('\n\n');
catch
error('c_+ search failed');
end
%% setting the random seed
rng(11);
%% cutting the convex part
try
z_max = get_z_max(A, b, c_plus, 0.01, 20, 2);
fprintf('Optimization finished\n\n');
if z_max >= Inf
fprintf('Result: no C_- found\n');
else
fprintf('Result: convex subpart, z_max = %f\n', z_max);
end
disp('TEST PASSED');
catch
error('TEST FAILED');
end