Commit 9588e095 authored by Malthe Kjær Bisbo's avatar Malthe Kjær Bisbo
Browse files

in GOFEE: split get_surrogate_relaxed_candidates into candidate generation and...

in GOFEE: split get_surrogate_relaxed_candidates into candidate generation and candidate relaxation, also separated the timing of these tasks
parent 06721060
......@@ -290,8 +290,10 @@ class GOFEE():
t1 = time()
t2 = time()
relaxed_candidates = self.get_surrogate_relaxed_candidates()
unrelaxed_candidates = self.generate_new_candidates()
t3 = time()
relaxed_candidates = self.relax_candidates_with_surrogate(unrelaxed_candidates)
t4 = time()
kappa = self.kappa
a_add = []
for _ in range(5):
......@@ -312,8 +314,8 @@ class GOFEE():
# log timing
self.log_msg += "Timing:\n"
self.log_msg += f"{'Training':12}{'Relax pop.':12}{'Relax candidates':18}{'Evaluate':12}\n"
self.log_msg += f"{t1-t0:12.2e}\t{t2-t1:12.2e}\t{t3-t2:16.2e}\t{time()-t3:12.2e}\n\n"
self.log_msg += f"{'Training':12}{'Relax pop.':12}{'Make cands.':15}{'Relax cands.':16}{'Evaluate':12}\n"
self.log_msg += f"{t1-t0:<12.2e}{t2-t1:<12.2e}{t3-t2:<15.2e}{t4-t3:<16.2e}{time()-t4:<12.2e}\n\n"
# Add structure to population
index_lowest = np.argmin([a.get_potential_energy() for a in a_add])
......@@ -352,10 +354,10 @@ class GOFEE():
return a_dp
def get_surrogate_relaxed_candidates(self):
""" Method supplying a number of surrogate-relaxed new
candidates. The method combines the generation of new
candidates with subsequent surrogate relaxation.
def generate_new_candidates(self):
"""Method to generate a self.Ncandidates new candidates
by applying the operations defined in self.candidate_generator
to the structures currently in the population.
The tasks are parrlelized over all avaliable cores.
Njobs = self.Ncandidates
......@@ -363,6 +365,15 @@ class GOFEE():
def func1():
return [self.generate_candidate() for i in task_split[self.comm.rank]]
candidates = parallel_function_eval(self.comm, func1)
return candidates
def relax_candidates_with_surrogate(self, candidates):
""" Method to relax new candidates using the
The tasks are parrlelized over all avaliable cores.
Njobs = self.Ncandidates
task_split = split(Njobs, self.comm.size)
def func2():
return [self.surrogate_relaxation(candidates[i], Fmax=0.1, steps=200, kappa=self.kappa)
for i in task_split[self.comm.rank]]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment