Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions ATLAS/Learning_ini_chart.m
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
% Find the chart for randomly sampled initial points on the manifold.
%These initial points are evenly sampled from a long trajectory
chart = cell(1,K_int);
% Find the chart for randomly sampled initial points on the manifold.
% These initial points are evenly sampled from a long trajectory.

chart = cell(1, params.learning.K_int);
Sim_parameter = struct( ...
'T_max', T_one, ...
'dt', dt , ...
'gap', 1, ...
'X_int', X_int ...
'T_max', params.learning.T_one, ...
'dt', params.RHS.dt , ...
'gap', 1, ...
'X_int', params.learning.X_int ...
);


disp(['Initial point: ', num2str(X_int), ' T_max: ', num2str(Sim_parameter.T_max)])

% Simulate a long trajctory starting from this initial condition.
tic

[output] = simulator_one(Sim_parameter);
t1=toc;
disp(['one long trajctory is simulated. The time spent is ', num2str(t1/60), ' mins.' ])



% evenly sample N initial points from the trajctory
disp(['Initial point: ', num2str(params.learning.X_int), ' T_max: ', num2str(Sim_parameter.T_max)])

% Simulate a long trajectory starting from this initial condition.
tic

[output] = params.simulator.one(Sim_parameter);
t1=toc;
disp(['one long trajectory is simulated. The time spent is ', num2str(t1/60), ' mins.' ])



% evenly sample N initial points from the trajectory
output = output(10000:end,:);
[L, ~] = size(output);
X_int_sample = output(1: round(L/K_int):end, :);
[L, ~] = size(output);
X_int_sample = output(1: round(L/params.learning.K_int):end, :);

tic
disp(['Parallelly run chart simulator starting from ', num2str(K_int) ,' initial points. '])
for i = 1 : K_int
disp(['Parallelly run chart simulator starting from ', num2str(params.learning.K_int) ,' initial points. '])
for i = 1 : params.learning.K_int
disp(['Landmark',num2str(i), ' is learned.'])

Sim_parameter = struct( ...
'T_max', T_max, ...
'dt', dt , ...
'N', N, ...
'T_max', params.RHS.T_max, ...
'dt', params.RHS.dt , ...
'N', params.RHS.N, ...
'X_int', X_int_sample(i,:) ...
);
[data, Cov_store, Mean_store] = simulator_par(Sim_parameter);
[chart{i}] = Learning_Slow_Manifold( data, Cov_store, Mean_store, D, d,modify );
[data, Cov_store, Mean_store] = params.simulator.parallel(Sim_parameter);
[chart{i}] = Learning_Slow_Manifold( data, Cov_store, Mean_store, params.RHS.D, params.RHS.d, params.RHS.modify );


end
t2 =toc;
disp(['Initial learning stage is completed. The time spent is ', num2str(t2/60), ' mins.' ])
Expand Down
10 changes: 5 additions & 5 deletions ATLAS/MSM_learning.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

disp('Starting MSM learning stage')

[TranM] = MSM(chart, connectivity, MSM_parameter, weighted_dd2, d);
step = MSM_parameter.step;
N_state = MSM_parameter.N_state;
dt_s = MSM_parameter.dt_s;
save( TranM_fileName ,'TranM','step','N_state','dt_s')
[TranM] = MSM(chart, connectivity, params.MSM, weighted_dd2, params.RHS.d);
step = params.MSM.step;
N_state = params.MSM.N_state;
dt_s = params.MSM.dt_s;
save( params.paths.TranM ,'TranM','step','N_state','dt_s')
disp('MSM learning stage is completed')
27 changes: 13 additions & 14 deletions ATLAS/exploration_learning.m
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@

disp('Starting exploration learning stage')

% set to exploration mode
mode = 1;
weighted_dd2 = @(X0, chart,neigh,nearest, connectivity_indices) weighted_drift_diffusion2( X0, chart, neigh, nearest, connectivity_indices, t0, chi_p, D,d, threshold, option,mode );
weighted_dd2 = @(X0, chart,neigh,nearest, connectivity_indices) weighted_drift_diffusion2( X0, chart, neigh,nearest, connectivity_indices, params.RHS.t0, params.RHS.chi_p, params.RHS.D,params.RHS.d, params.RHS.threshold, params.learning.option,mode );


%% Use the exploration mode to further Learn
%% Use the exploration mode to further Learn
explore_round = 1;
explore_round_max = 100;
explore_round_max = 100;
K = length(chart);
random_start;
random_start;
while bin_N~=1 && explore_round<explore_round_max
disp(['Round ',num2str(explore_round),' of exploration'])
[~, ~, chart] = ATLAS_simulator2(weighted_dd2, chart_sim_parameter,RHS_parameter, simulator_par, chart);
[chart, ~, ~, ~, ~] = landmark(chart, t0, chi_p,threshold(1), connectivity_threshold);
[~, ~, chart] = ATLAS_simulator2(weighted_dd2, params.chart_sim_parameter,params.RHS, params.simulator.parallel, chart);
[chart, ~, ~, ~, ~] = landmark(chart, params.RHS.t0, params.RHS.chi_p,params.RHS.threshold(1), params.RHS.connectivity_threshold);
disp(['No. of landmarks after exploration is ', num2str(length(chart)) ])

if relearn_option == 1
if params.relearn.option == 1
K_next = length(chart);
index_to_learn = K+1: K_next;
[ chart ] = relearn_chart(chart, relearn_parameter, index_to_learn);
[chart, connectivity, P, bin_N, bins] = landmark(chart, t0, chi_p,threshold(1), connectivity_threshold);
[ chart ] = relearn_chart(chart, params.relearn.settings, index_to_learn);
[chart, connectivity, P, bin_N, bins] = landmark(chart, params.RHS.t0, params.RHS.chi_p,params.RHS.threshold(1), params.RHS.connectivity_threshold);
end
K = length(chart);
random_start;
random_start;
explore_round = explore_round + 1;
end

save( chart_fileName ,'chart','connectivity','P')
disp('exploration learning stage is completed')
save( params.paths.chart ,'chart','connectivity','P')

disp('exploration learning stage is completed')
12 changes: 6 additions & 6 deletions ATLAS/initial_learning.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

disp('Starting initial learning stage')
Learning_ini_chart;
[chart, ~, ~, ~] = landmark(chart, t0, chi_p,threshold(1), connectivity_threshold);
if relearn_option == 1
[chart, ~, ~, ~] = landmark(chart, params.RHS.t0, params.RHS.chi_p,params.RHS.threshold(1), params.RHS.connectivity_threshold);

if params.relearn.option == 1
K = length(chart);
index_to_learn = 1:K;
[ chart ] = relearn_chart(chart, relearn_parameter, index_to_learn);
[chart, connectivity, P, bin_N, bins] = landmark(chart, t0, chi_p,threshold(1), connectivity_threshold);
[ chart ] = relearn_chart(chart, params.relearn.settings, index_to_learn);
[chart, connectivity, P, bin_N, bins] = landmark(chart, params.RHS.t0, params.RHS.chi_p,params.RHS.threshold(1), params.RHS.connectivity_threshold);
end
save(chart_part_fileName , 'chart','connectivity','P');
save(params.paths.chart_part , 'chart','connectivity','P');
disp(['No. of landmarks after initial learning stage is ', num2str(length(chart)) ])

disp('Initial learning stage is completed')
6 changes: 3 additions & 3 deletions ATLAS/random_start.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[N_min, index_min] = min(bins_hist);
minimum_block = find(bins==bins_unique(index_min));
nearest = minimum_block(ceil(rand * N_min));
chart_sim_parameter.nearest = nearest;
chart_sim_parameter.connectivity = connectivity;
chart_sim_parameter.X_int = chart{nearest}.X_int;
params.chart_sim_parameter.nearest = nearest;
params.chart_sim_parameter.connectivity = connectivity;
params.chart_sim_parameter.X_int = chart{nearest}.X_int;


60 changes: 28 additions & 32 deletions Butane.m
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

clear all
clear all
close all
clc


system_type = 'Butane';
system_type = 'Butane';
disp(['Starting ',system_type,' model.'])
addpath_settings; % setup path

Expand All @@ -16,68 +15,65 @@
for k =1:10

%% Set up the parameter
rng(k)
set_parameter; % setup parameter
disp('Parameter is set')

%set path
butane_paths = build_butane_paths(datapath, k);
chart_fileName = butane_paths.chart;
chart_part_fileName = butane_paths.chart_part;
TranM_fileName = butane_paths.TranM;
diary_fileName = butane_paths.diary;
rng(k)
params = set_parameter(); % setup parameter
disp('Parameter is set')

% Update paths for this iteration
params.paths.chart = [params.paths.datapath,'chart',num2str(k),'.mat'];
params.paths.chart_part = [params.paths.datapath,'chart_part',num2str(k),'.mat'];
params.paths.TranM = [params.paths.datapath,'TranM',num2str(k),'.mat'];
diary_fileName = [params.paths.datapath,'diary',num2str(k),'.txt'];
diary(diary_fileName)

tstart=tic;
tstart=tic;

%% Generate the chart for randomly sampled initial points.

initial_learning;


%% Use the exploration mode to further Learn
%% Use the exploration mode to further Learn

exploration_learning;

%% Using ATLAS simulator to run lots of trajs to further Learn

butane_simulation_learning;


%% Relearn ATLAS
%% Relearn ATLAS

butane_relearning;

%% Build up Markov state model

MSM_learning;
%%


%%
t_final = toc(tstart);
disp(['Learning stage is finished. The time spent is ',num2str(t_final/3600), ' hours']);
diary off

end

elseif x==2

set_parameter;
disp('Parameter is set')
butane_paths = build_butane_paths(datapath);
diary_FPT_fileName = butane_paths.diary_FPT;
Butane_analysis_fileName = butane_paths.Butane_analysis;
params = set_parameter();
disp('Parameter is set')
diary_FPT_fileName = [params.paths.datapath,'diary_FPT.txt'];
diary(diary_FPT_fileName)


%% Simulate long trajectory with the original simulator

butane_ori_simulation;

%% Calculate MFPT

butane_MFPT;

diary off

end
end
58 changes: 28 additions & 30 deletions Halfmoon.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

clear all
close all
clc
Expand All @@ -11,68 +10,67 @@
prompt = '1-Learning ATLAS, 2-Simulating MRT';
x = input(prompt);

if x==1
if x==1

for k =1:10
%% Set up the parameter
rng(k)
set_parameter;
disp('Parameter is set')

chart_fileName = [datapath,'chart',num2str(k),'.mat'];
chart_part_fileName = [datapath,'chart_part',num2str(k),'.mat'];
TranM_fileName = [datapath,'TranM',num2str(k),'.mat'];
diary_fileName = [datapath,'diary',num2str(k),'.txt'];
rng(k)
params = set_parameter();
disp('Parameter is set')

params.paths.chart = [params.paths.datapath,'chart',num2str(k),'.mat'];
params.paths.chart_part = [params.paths.datapath,'chart_part',num2str(k),'.mat'];
params.paths.TranM = [params.paths.datapath,'TranM',num2str(k),'.mat'];
diary_fileName = [params.paths.datapath,'diary',num2str(k),'.txt'];
diary(diary_fileName)
tstart=tic;
tstart=tic;


%% Generate the chart for randomly sampled initial points.

initial_learning;
initial_learning;


%% Use the exploration mode to further Learn
%% Use the exploration mode to further Learn

exploration_learning;

%% Using ATLAS simulator to run lots of trajs to further learn.

halfmoon_simulation_learning;
%% Relearn ATLAS

%% Relearn ATLAS

halfmoon_relearning;

%% Build up Markov state model

MSM_learning;

%%
%%
t_final = toc(tstart);
disp(['Learning stage is finished. The time spent is ',num2str(t_final/3600), ' hours']);
diary off

end

elseif x==2

set_parameter;
disp('Parameter is set')
diary_FPT_fileName = [datapath,'diary_FPT.txt'];
Halfmoon_analysis_fileName = [datapath,'Halfmoon_analysis.mat'];

params = set_parameter();
disp('Parameter is set')
diary_FPT_fileName = [params.paths.datapath,'diary_FPT.txt'];
diary(diary_FPT_fileName)


%% Simulate long trajectory with the original simulator

halfmoon_ori_simulation;
%% Calculate MFPT

%% Calculate MFPT

halfmoon_MFPT;
diary off

diary off


end
end
Loading