-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial_temp_decision.m
More file actions
71 lines (49 loc) · 1.9 KB
/
Copy pathinitial_temp_decision.m
File metadata and controls
71 lines (49 loc) · 1.9 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function T_init = initial_temp_decision(costfun,s_init,varargin)
% INITIAL_TEMP_DECISION: Determines a suitable initial temperature
% for simulation annealing, given an initial state and the cost function.
%
% Input:
% - costfun: a function handle for the cost function, with one argument
% that is the domain state vector -- e.g., costfun(s)
% - s_init: initial state (N-vector)
% - const_a: [OPTIONAL] acceptance probability for the "worst" move
%
% Output:
% - T_init: initial temperature (single number)
% ------------------------------------------------------------------------
% Copyright 2018 Min Hyeok Kim & Ji Hyun Bak
%% unpack input
% specify the desired acceptance probability for the "worst" move
if(nargin>2)
const_a = varargin{1}; % may be passed as input
else
const_a = 0.5; % default value
end
% unpack dimensions
N = size(s_init,1); % number of loci
Kmax = max(s_init); % number of existing clusters
% NOTE: the number of all possible single mutations is N*Kmax.
%% scan through all possible single-mutation moves
HS = costfun(s_init); % initial value of the cost function
dH_list = -Inf(N,Kmax);
for j = 1:N
s_j = s_init(j); % locus to mutate
for s = 1:Kmax
% ----- make a single mutation ------------
s_mut = s; % move to the selected domain
if(s==s_j)
s_mut = Kmax+1; % if self, create a new domain
end
s_set_cdd = s_init;
s_set_cdd(j) = s_mut; % apply the mutation
% ------------------------------------------
s_set_cdd = renumber_clusters(s_set_cdd); % renumber
HSpos = costfun(s_set_cdd);
deltaHS = HSpos-HS; % the "energy" difference
dH_list(j,s) = deltaHS;
end
end
% calculate the temperature that corresponds to the
% "worst" acceptance probability specified above
T_init = -max(dH_list(:))/log(const_a);
end