2 from Problems
.synthetic_cosh
import synthetic
3 from analysis
.analysis
import error
4 from graph
.graph
import Random
5 from Optimizers
import DOPTIMIZER
as dopt
6 from utilities
import utilities
as ut
7 from utilities
.plot_utils
import plot_exp4
12 seed
= np
.random
.randint(12345)
16 #### create asynchronous setup
19 comp_time_dist
= 'random_uniform'
21 mincomp
= np
.array([1,1,1,1,1,1,1,1,1,1])
22 maxcomp
= np
.array([5,10,15,20,25,30,35,40,45,50])
24 T_active_exp4
, Tv_nodes_exp4
, node_comp_time_exp4
= \
25 ut
.create_computation_time(num_nodes
, max_iter
=int(1e5
), comp_time_dist
=comp_time_dist
, mean_comp
=None,\
26 min_comp
=mincomp
, max_comp
=maxcomp
, variance_comp
=None, make_integer
=True)
29 #### some parameters of the algorithms
44 #### Problem setup: parameters of the synthetic functions and constraints.
45 prd
= synthetic(seed
, num_nodes
, dim
)
46 error_prd
= error(prd
,np
.zeros(num_nodes
),0)
49 #### Create gossip matrices
50 zero_row_sum
,zero_col_sum
,row_stochastic
,col_stochastic
, N_out
, neighbors
= Random(num_nodes
, prob
=0.8, Laplacian_dividing_factor
= 2).directed()
53 #### Run the optimization algorithms and compute the performance metrics
55 x_asy_dagp1
, _
, _
, _
, _
, Delay_mat_dagp_1
= \
56 dopt
.Asy_DAGP(T_active_exp4
, Tv_nodes_exp4
, prd
, zero_row_sum
, zero_col_sum
, learning_rate
, depoch
, num_nodes
, dim
, rho
, alpha
, gamma
, eta
, neighbors
, \
57 cons
= True, delay_type
='exp', min_delay
=None, max_delay
=None, expScale_delay
=expScale
, \
58 drop_msg
=True, drop_prob
=drop_prob_1
)
60 x_asy_dagp2
, _
, _
, _
, _
, Delay_mat_dagp_2
= \
61 dopt
.Asy_DAGP(T_active_exp4
, Tv_nodes_exp4
, prd
, zero_row_sum
, zero_col_sum
, learning_rate
, depoch
, num_nodes
, dim
, rho
, alpha
, gamma
, eta
, neighbors
, \
62 cons
= True, delay_type
='exp', min_delay
=None, max_delay
=None, expScale_delay
=expScale
, \
63 drop_msg
=True, drop_prob
=drop_prob_2
)
65 x_asy_dagp3
, _
, _
, _
, _
, Delay_mat_dagp_3
= \
66 dopt
.Asy_DAGP(T_active_exp4
, Tv_nodes_exp4
, prd
, zero_row_sum
, zero_col_sum
, learning_rate
, depoch
, num_nodes
, dim
, rho
, alpha
, gamma
, eta
, neighbors
, \
67 cons
= True, delay_type
='exp', min_delay
=None, max_delay
=None, expScale_delay
=expScale
, \
68 drop_msg
=True, drop_prob
=drop_prob_3
)
70 x_asy_dagp0
, _
, _
, _
, _
, Delay_mat_dagp_0
= \
71 dopt
.Asy_DAGP(T_active_exp4
, Tv_nodes_exp4
, prd
, zero_row_sum
, zero_col_sum
, learning_rate
, depoch
, num_nodes
, dim
, rho
, alpha
, gamma
, eta
, neighbors
, \
72 cons
= True, delay_type
='exp', min_delay
=None, max_delay
=None, expScale_delay
=expScale
, \
73 drop_msg
=True, drop_prob
=drop_prob_0
)
76 f_asy_dagp0
= error_prd
.cost_path(np
.sum(x_asy_dagp0
, axis
=1)/num_nodes
)
77 f_asy_dagp1
= error_prd
.cost_path(np
.sum(x_asy_dagp1
, axis
=1)/num_nodes
)
78 f_asy_dagp2
= error_prd
.cost_path(np
.sum(x_asy_dagp2
, axis
=1)/num_nodes
)
79 f_asy_dagp3
= error_prd
.cost_path(np
.sum(x_asy_dagp3
, axis
=1)/num_nodes
)
82 #### save data and plot results
83 plot_exp4(T_active_exp4
, f_asy_dagp0
, f_asy_dagp1
, f_asy_dagp2
, f_asy_dagp3
, current_dir
=os
.path
.dirname(os
.path
.abspath(__file__
)), save_results_folder
='exp4', plot_iter
=depoch
)