-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharticle_example09.m
70 lines (58 loc) · 1.42 KB
/
article_example09.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
61
62
63
64
65
66
67
68
69
70
clear all;
% changing cwd to directory of .m file
cd(fileparts(which(mfilename)));
% loading map
load('./maps/article_example09_C3_R6.mat');
% fixing the random seed
rng(42, 'twister');
%% showing c_plus
disp('=== c_plus:');
disp(c_plus');
%% infeasibility for random pt
r = [];
for j = 1 : 10
r(end + 1) = infeasibility_oracle(A, b, randn(m, 1));
end
disp('Random points inside ' + string(round(mean(r * 100), 1)) + '%')
%% infeasibility for point in F
rng(10);
fprintf('Infeasibility test: ');
for i = 1 : 10
res = infeasibility_oracle(A, b, quadratic_map(A, b, randn(n, 1)));
if res == 1
error('Infeasibility oracle error');
else
fprintf('.');
end
end
disp('OK');
%% boundary oracle
d = -[1,2,3,4,5,6]';
y = quadratic_map(A, b, [1, 2, 3]');
disp('=== Boundary oracle');
t = boundary_oracle(A, b, y, d);
fprintf('t = %.5f\n\n', t);
%% c from d
disp('=== Get c from d');
c_d = get_c_from_d(A, b, y, d);
disp('c_d = ');
disp(c_d');
%% c minus
rng(10);
disp('=== c_minus');
c_minus = get_c_minus(A, b);
disp(c_minus');
%% certificate
rng(10);
disp('=== Non-convexity certificate');
result = nonconvexity_certificate(A, b);
if result == 1
disp('Search finished. The image is non-convex.');
else
disp('Search finished. Cannot certify non-convexity.');
end
%% zmax
disp('=== z_max');
z_max_guess = 0.1;
z_max = get_z_max(A, b, c_plus, z_max_guess, 100, 1);
fprintf('Search finished. z_max=%.15f\n', z_max);