-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunme.m
159 lines (150 loc) · 9.15 KB
/
runme.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
function [cpx,central_soln] = runme(solver, admm_option, num_threads)
% This is the function that needs to be run by the user, for running the
% ADMM routines.
% Three input arguments are necessary:
%
% solver (int): the ADMM approach that is employed
% 1: regular ADMM
% 2: ADMM with bin packing
% 3: asynchronous ADMM,
%
% admm_option (int): the update method used in ADMM
% 1: Gabay (constant rho)
% 2: Boyd (adaptive rho)
% 3: Song (local rho)
% 4: Goldstein (restart method)
% 5: Wohlberg (relative residuals)
%
% num_threads (int): the number of CPUs allowed by the process
% 1: sequential run (only applicable to regular ADMM)
% 2: parallel runs
% The user has to set the problem matrices inside the define_input function
[A, lhs, rhs, lb, ub, f, cluster_id_from,cluster_id_to] = define_input();
select = struct();
% Manual input of ADMM parameters
select.opt.decomposition.maxiter = 2000; %default: 2000
select.opt.decomposition.mu = 10; %default: 40
select.opt.decomposition.tau = 0.1; %default: 0.05
select.opt.decomposition.Plink_init = 0e0; %default: 0e0
select.opt.decomposition.lambdas_init = 0e0; %default: 0e0
select.opt.decomposition.rhos_init = 1e2; %default: 1e2
select.opt.decomposition.convergence_tolerance = 1e-4; %default: 1e-4
select.opt.decomposition.Ccg = 10^10; %default: 10^10
select.opt.decomposition.Tf = 2; %default: 2
select.opt.decomposition.eta = 1; %default: 1
select.opt.decomposition.mu_sc = 0.999; %default: 0.999
select.opt.decomposition.iter_rho_adapt = 50; %default: 50
select.opt.decomposition.tau_max = 1; %default: 1
select.opt.decomposition.convergence_type = 1; %default: 1 (1: residuals, 2: relative cost difference)
select.opt.solver = solver;
select.opt.decomposition.admm_option = admm_option;
select.opt.num_threads=num_threads;
switch select.opt.solver
case 1
% Regular ADMM
switch select.opt.decomposition.admm_option
case 1
if select.opt.num_threads > 1
disp('Solve with regular ADMM (parallel), Gabay (constant rho)')
[cpx,central_soln] = solve_with_ADMM_parallel_Gabay_constant_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
disp('Solve with regular ADMM (sequential), Gabay (constant rho)')
[cpx,central_soln] = solve_with_ADMM_sequential_Gabay_constant_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
end
case 2
if select.opt.num_threads > 1
disp('Solve with regular ADMM (parallel), Boyd (adaptive rho)')
[cpx,central_soln] = solve_with_ADMM_parallel_Boyd_adaptive_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
disp('Solve with regular ADMM (sequential), Boyd (adaptive rho)')
[cpx,central_soln] = solve_with_ADMM_sequential_Boyd_adaptive_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
end
case 3
if select.opt.num_threads > 1
disp('Solve with regular ADMM (parallel), Song (local rho)')
[cpx,central_soln] = solve_with_ADMM_parallel_Song_local_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
disp('Solve with regular ADMM (sequential), Song (local rho)')
[cpx,central_soln] = solve_with_ADMM_sequential_Song_local_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
end
case 4
if select.opt.num_threads > 1
disp('Solve with regular ADMM (parallel), Goldstein (restart method)')
[cpx,central_soln] = solve_with_ADMM_parallel_Goldstein_restart_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
disp('Solve with regular ADMM (sequential), Goldstein (restart method)')
[cpx,central_soln] = solve_with_ADMM_sequential_Goldstein_restart_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
end
case 5
if select.opt.num_threads > 1
disp('Solve with regular ADMM (parallel), Wohlberg (relative residuals)')
[cpx,central_soln] = solve_with_ADMM_parallel_Wohlberg_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
disp('Solve with regular ADMM (sequential), Wohlberg (relative residuals)')
[cpx,central_soln] = solve_with_ADMM_sequential_Wohlberg_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
end
end
case 2
select.opt.bin_size = input('Please enter the number of CPUs allocated for each bin: (minimum: 1, maximum: available CPUs in your machine) ');
%ADMM + Bin Packing
switch select.opt.decomposition.admm_option
case 1
if select.opt.num_threads > 1
disp('Solve with ADMM + Bin packing (parallel), Gabay (constant rho)')
[cpx,central_soln] = g_solve_with_ADMM_parallel_Gabay_constant_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
%nicht definiert f�r Bin Packing
error('ADMM with bin packing algorithm cannot be solved sequentially, please allow parallelism by allowing a higher number of threads (larger than 1)!')
end
case 2
if select.opt.num_threads > 1
disp('Solve with ADMM + Bin packing (parallel), Boyd (adaptive rho)')
[cpx,central_soln] = g_solve_with_ADMM_parallel_Boyd_adaptive_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
%nicht definiert f�r Bin Packing
error('ADMM with bin packing algorithm cannot be solved sequentially, please allow parallelism by allowing a higher number of threads (larger than 1)!')
end
case 3
if select.opt.num_threads > 1
disp('Solve with ADMM + Bin packing (parallel), Song (local rho)')
[cpx,central_soln] = g_solve_with_ADMM_parallel_Song_local_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
%nicht definiert f�r Bin Packing
error('ADMM with bin packing algorithm cannot be solved sequentially, please allow parallelism by allowing a higher number of threads (larger than 1)!')
end
case 4
if select.opt.num_threads > 1
disp('Solve with ADMM + Bin packing (parallel), Goldstein (restart method)')
[cpx,central_soln] = g_solve_with_ADMM_parallel_Goldstein_restart_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
%nicht definiert f�r Bin Packing
error('ADMM with bin packing algorithm cannot be solved sequentially, please allow parallelism by allowing a higher number of threads (larger than 1)!')
end
case 5
if select.opt.num_threads > 1
disp('Solve with ADMM + Bin packing (parallel), Wohlberg (relative residuals)')
[cpx,central_soln] = g_solve_with_ADMM_parallel_Wohlberg_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
%nicht definiert f�r Bin Packing
error('ADMM with bin packing algorithm cannot be solved sequentially, please allow parallelism by allowing a higher number of threads (larger than 1)!')
end
otherwise
error('Not implemented. Please use the allowed arguments for the runme function!')
end
case 3
%ADMM + Bin Packing + asynch
switch select.opt.decomposition.admm_option
case 1
if select.opt.num_threads > 1
disp('Solve with asynchronous ADMM, Gabay (constant rho)')
[cpx,central_soln] = async_solve_with_ADMM_parallel_Boyd_constant_rho_release(select, A, lhs, rhs, ub, lb, f, cluster_id_from, cluster_id_to);
else
%nicht definiert f�r Bin Packing
error('Asynchronous ADMM algorithm cannot be solved sequentially, please allow parallelism by allowing a higher number of threads (larger than 1)!')
end
otherwise
error('Asynchronous ADMM algorithm only supports the constant rho, please set the second argument of the runme function to 1!')
end
otherwise
error('Not implemented. Please use the allowed arguments for the runme function!')
end