/
main-1a.cpp
58 lines (43 loc) · 1.62 KB
/
main-1a.cpp
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
//Copyright © 2017-2018 Gustavo Thebit Pfeiffer / Y. Sato laboratory
/*
This file is part of PS-MCLS2018.
PS-MCLS2018 is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
PS-MCLS2018 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PS-MCLS2018. If not, see <http://www.gnu.org/licenses/>.
*/
#include "methods.h"
#include "problems.h"
using namespace std;
int main() {
srand(time(NULL));
const unsigned int n = 2;
const unsigned int m = 3;
Probl1 problem;
Vec<n> x0, xstar;
xstar = problem.xstar();
x0[0] = 2;
x0[1] = 1;
DISP(x0.transpose())
Mat<n, n> H = problem.JtJ_block(xstar, 100000).inverse();
Method<n> * f[] = {
new SGD<n,m>(&problem, "SGD (N=3)", H, 0., 3),
new SGD<n,m>(&problem, "SGD (N=5)", H, 0., 5),
new SGD<n,m>(&problem, "SGD (N=10)", H, 0., 10),
new SGD<n,m>(&problem, "SGD (N=100)", H, 0., 100),
new IP<n,m>(&problem, "IP (N_{k}=2k)", H, 1, 0, 2),
new IP<n,m>(&problem, "IP (N_{k}=4k²)", H, 2, 0, 4),
new AvgIP<n,m>(&problem, "aIP (N_{k}=2k, α=.6)", H, 1, .6, 2, 1),
};
const int nf = sizeof(f)/sizeof(f[0]);
compareSeveral<n>(f, nf, 1000, x0, xstar);
for(int i = 0; i < nf; i++)
delete f[i];
return 0;
}