-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_experiments.m
97 lines (72 loc) · 2.99 KB
/
run_experiments.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
%% MATLAB script for testing the performance of HIPNEX and NPE
% This script tests the performance of HIPNEX and NPE on a cubic
% minimax problem. The problem is defined as follows:
%
% min_x max_y \|x\|^3 + y'*(A*x - b)
%
% where A is a square invertible matrix and b is a vector. The script compares the
% performance of HIPNEX and NPE using an iterative method for solving the intermediate
% problems, versus solving these exactly, using a LU decomposition.
clc
clearvars
% increase verbosity for more info
verbosity = 1;
% Setting random seed for reproducibility
seed = 3;
rng(seed)
% Problem setup
L = 1e-3; % Lipschitz constant of the Hessian
kappa = 20; % Condition number of A
nvals = [1000, 2000, 5000]; % Dimensions (of A) to test
nn = length(nvals);
tol = 1e-6; % Stopping Tolerance
n_iters = int32(1e4);
% Common hyperparameters
hyperparameters.L = L; % Lipschitz constant of the Hessian
hyperparameters.tol = tol; % Tolerance for the stopping criterion
hyperparameters.maxiter = n_iters; % Maximum number of iterations
hyperparameters.verbosity = 0; % Verbosity level
% Only hat_sigma changes for iterative vs exact
% hat_sigma control the error in solving the inner problems.
% This error is 0 when the inner problems are solved exactly,
% for instance using an LU decomposition. Nevertheless, both
% HIPNEX and NPE allow for an error in solving the inner problems
hyperparameters_exact = hyperparameters;
hyperparameters_exact.hat_sigma = 1e-12;
hyperparameters_iterative = hyperparameters;
hyperparameters_iterative.hat_sigma = .15;
Algs = {'HIPNEX (iterative)', @(hF, x0, hJ, hJp, hsolver) ...
hipnex(hF, x0, hJp, hsolver, hyperparameters_iterative);
'NPE (iterative)', @(hF, x0, hJ, hJp, hsolver) ...
plain_npe(hF, x0, hJp, hsolver, hyperparameters_iterative);
'HIPNEX (exact)', @(hF, x0, hJ, hJp, hsolver) ...
hipnex(hF, x0, hJ, 'solve', hyperparameters_exact);
'NPE (exact)', @(hF, x0, hJ, hJp, hsolver) ...
plain_npe(hF, x0, hJ, 'solve', hyperparameters_exact);
'GO-2', @(hF, x0, hJ, hJp, hsolver) ...
ORN_ls_simple(hF, hJ, 1, 0, .5, .5, x0, n_iters, tol)
};
nalgs = size(Algs, 1);
stats = cell(nalgs, nn);
fprintf('\n Numerical experiments for cubic min-max example\n')
for n_ind=1:nn
n = nvals(n_ind);
fprintf('\nn=%d\n', n)
% Setup the cubic min-max problem
[hF, hJ, hJp, hsolver] = cubic_min_max_setup(n, L, kappa);
% Initial point initialization
x0 = randn(2 * n, 1) / sqrt(n);
for alg_ind = 1:nalgs
fprintf(':: %s ::\n', Algs{alg_ind, 1});
alg = Algs{alg_ind, 2};
start = tic;
[x, stats_it] = alg(hF, x0, hJ, hJp, hsolver);
stats_it.total_time = toc(start);
fprintf('Total Time: %f\n', stats_it.total_time);
stats{alg_ind, n_ind} = stats_it;
end
end
if ~exist('results', 'dir')
mkdir('results')
end
save results/cubic_min_max_experiment.mat