📄 sim_obstacle.m
字号:
function sim_obstacle%DEPRECATED. DONT USEfn='sim_ob3.mat';%fn='obstacle/sim_obstaclep-all.mat';%get_raw_data(fn)process_data(fn)function generatereturntopology_generator('topo-obstacle-10-1.25.mat',3200, 5.12, 10, 10/8,0);topology_generator('topo-obstacle-20-1.25.mat',3200, 5.12, 20, 10/8,0);topology_generator('topo-obstacle-50-1.25.mat',3200, 5.12, 50, 10/8,0);topology_generator('topo-obstacle-10-2.50.mat',3200, 5.12, 10, 20/8,0);topology_generator('topo-obstacle-20-2.50.mat',3200, 5.12, 20, 20/8,0);topology_generator('topo-obstacle-50-2.50.mat',3200, 5.12, 50, 20/8,0);function get_raw_data(fn)n_obstacles = [10, 20, 50];l_obstacles = [1.25, 2.5];repeat = 10;%optimal_dist = cell(length(n_obstacles), length(l_obstacles), repeat);%load_optimal = cell(length(n_obstacles), length(l_obstacles), repeat);for i=1:repeat for n=1:length(n_obstacles) for l=1:length(l_obstacles) topo=sprintf('topo-obstacle-%d-%1.2f.mat',n_obstacles(n),l_obstacles(l)); topology_generator(topo,3200, 5.12, n_obstacles(n), l_obstacles(l),0); fprintf('****sim_obstacle test %s, repeat=%d\n', topo, i); res(n,l,i) = simulation(topo, 56); optimal(n,l,i) = sim_optimal(topo); save(fn, 'res' ,'n_obstacles','l_obstacles', 'repeat', ... 'optimal'); end endendfunction get_optimal_dist(fn)returnload(fn);optimal_dist = cell(length(n_obstacles), length(l_obstacles));load_optimal = cell(length(n_obstacles), length(l_obstacles));for n=1:length(n_obstacles) for l=1:length(l_obstacles) topo=sprintf('topo-obstacle-%d-%1.2f.mat',n_obstacles(n),l_obstacles(l)); fprintf('****sim_obstacle optimaldist %s\n', topo); S = load(topo); [o_dist o_nexthop] = ... allpair_dijkstra(S.D, 1:S.n_nodes, 1, 'obs-tmp.mat'); load_optimal{n,l} = get_nexthop_load(o_nexthop, S.random_pairs); pair_indices = S.random_pairs(:,1)+(S.random_pairs(:,2)-1)*S.n_nodes; optimal_dist{n,l} = o_dist(pair_indices); save(fn, 'res' ,'n_obstacles','l_obstacles', 'optimal_dist','load_optimal'); endendfunction process_data(fn)load(fn);for n=1:length(n_obstacles) for l=1:length(l_obstacles) clear stretch_bvr_sf_mean for i=1:repeat stretch_bvr_sf_mean(i)=plot_routing_stretch( ... res(n,l,i).routing_dist_bvr_sf, optimal(n,l,i).optimal_dist, 'k',[-1],0); if stretch_bvr_sf_mean(i)>100 %[res(n,l,i).routing_dist_bvr_sf optimal(n,l, ... % i).optimal_dist] n, l ,i end stretch_bvr_2h_mean=plot_routing_stretch( ... res(n,l,i).routing_dist_bvr_2h, optimal(n,l,i).optimal_dist, 'k',[-1],0); stretch_cr_mean=plot_routing_stretch( ... res(n,l,i).routing_dist_cr, optimal(n,l,i).optimal_dist, 'k',[-1],0); end fprintf('number:%d,length:%1.2f avg stretch %f\t%f\t%f\n', ... n_obstacles(n), l_obstacles(l), ... mean(stretch_bvr_sf_mean), ... mean(stretch_bvr_2h_mean), ... mean(stretch_cr_mean)); endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -