@@ -68,7 +68,7 @@ def __accept_proposal__(self,curr_score,new_score,t):
68
68
p = min (exp ((new_score - curr_score - 1e-12 )/ T ),1 )
69
69
return random () < p
70
70
71
- def search (self ,resolve_polytomies = True ,maxiter = 100 ,verbose = False ,nreps = 1 ,strategy = DEFAULT_STRATEGY ,checkpoint_file = "laml_topo_search._ckpt.txt" ):
71
+ def search (self ,resolve_polytomies = True ,maxiter = 100 ,verbose = False ,nreps = 1 ,strategy = DEFAULT_STRATEGY ,checkpoint_file = None ):
72
72
original_topos = self .treeTopoList
73
73
original_params = self .params
74
74
#nni_replicates = [(None,None)]*nreps
@@ -132,7 +132,7 @@ def search(self,resolve_polytomies=True,maxiter=100,verbose=False,nreps=1,strate
132
132
133
133
return best_trees ,best_score ,best_params
134
134
135
- def __search_one__ (self ,strategy ,maxiter = 100 ,verbose = False ,only_marked = False , checkpoint_file = "laml_topo_search._ckpt.txt" ):
135
+ def __search_one__ (self ,strategy ,maxiter = 100 ,verbose = False ,only_marked = False , checkpoint_file = None ):
136
136
# optimize branch lengths and other parameters for the starting tree
137
137
mySolver = self .get_solver ()
138
138
score_tree_strategy = deepcopy (strategy )
@@ -164,8 +164,8 @@ def __search_one__(self,strategy,maxiter=100,verbose=False,only_marked=False, ch
164
164
print ("Current score: " + str (curr_score ))
165
165
stop_time = timeit .default_timer ()
166
166
print ("Runtime (s):" , stop_time - start_time )
167
- if nni_iter % 50 == 0 :
168
- with open (checkpoint_file , "w " ) as fout :
167
+ if nni_iter % chkpt_freq == 0 and checkpoint_file is not None :
168
+ with open (checkpoint_file , "a " ) as fout :
169
169
fout .write (f"NNI Iteration: { nni_iter } \n " )
170
170
fout .write (f"Current newick tree: { best_trees } \n " )
171
171
fout .write (f"Current negative-llh: { best_score } \n " )
0 commit comments