%% include all path
addpath('./solver')
task='2 classification';
dataname='./data/rcv11';
load(sprintf('%s.mat',dataname));

%% prepare data
data.x_train=heart_scale_inst';
data.y_train=heart_scale_label';
data.num_class=2;
data.x_test=data.x_train;
data.y_test=data.y_train;


%% define problem definitions
options.w_init = rand(size(data.x_train,1),1);
problem = logistic_regression(data.x_train, data.y_train, data.x_test, data.y_test);


%% using GD to compute the solution first
options.max_epoch=500;
options.tol_optgap = 10^-36;
options.step_init = 1;
options.k = 200;%% sparsity
[w_opt, infos] = gd_solver(problem, options);
f_opt= problem.cost(w_opt);


%% parameter setting for one pass
options.w_opt=w_opt;
options.f_opt = f_opt;
options.batch_size=10;
options.max_epoch=1;
options.tol_optgap = 10^-36;
options.verbose = true;
options.lambda = 0.1;
options.permute_on = 1;
options.step_init = 0.001 * options.batch_size;
options.store_w=0;
options.max_epoch=1;


%% run our method
options.tau=1;
options.zeta=1.033;
options.step_init=3;
tic;
[w_persgd, info_persgd] = HSGHT(problem, options);
info_persgd.tt=toc;



%% run GD
options.step_init = 2;
options.max_epoch=1;
[w_gd, info_gd] = hgd(problem, options);


%% run SGD
options.step_init = 0.08;
options.step_alg = 'decay';
options.max_epoch=1;
options.batch_size=50;
[w_sgd, info_sgd] = sgd(problem, options);

%% plot
plot_rcv;