Commit e414568a by Sander Roet

### Merge branch 'make_algorithm' into 'master'

```Working code and example

See merge request !1```
parents db534787 b9747791
This diff is collapsed.
 import openpathsampling as paths class LeastChangedPath(object): def __init__(self): pass def __init__(self, steps=None): self.steps = steps self._result = paths.Trajectory() self.n = self.find_first_n(steps) self.make_results() def make_results(self): while self.n > 0: old_step = self.steps[self.n] new_n = self.find_next_n(steps=self.steps, n=self.n) if new_n > 0: new_step = self.steps[new_n] self.add_sub_trajectory(steps=self.steps, old_step=old_step, new_step=new_step) else: self.add_sub_trajectory(steps=self.steps, old_step=old_step, new_step=None) self.n = new_n def sp(self, step=None): return step.change.canonical.details.shooting_snapshot def find_first_n(self, steps=None): n = -1 step = steps[n] while not step.change.accepted: n -= 1 step = steps[n] return n + len(steps) def find_next_n(self, steps=None, n=None): y = 0 old_step = steps[n] old_sp = self.sp(old_step) while n-y >= 0: new_step = steps[n-y] new_trj = new_step.active[0].trajectory if old_sp not in new_trj: new_n = n-y+1 return new_n y += 1 return 0 def add_sub_trajectory(self, steps=None, old_step=None, new_step=None): if new_step is None: sub_traj = paths.Trajectory([self.sp(old_step)]) else: full_traj = new_step.active[0].trajectory new_sp = self.sp(new_step) old_sp = self.sp(old_step) i_new_sp = full_traj.index(new_sp) i_old_sp = full_traj.index(old_sp) if i_old_sp < i_new_sp: sub_traj = full_traj[i_old_sp:i_new_sp] elif i_old_sp > i_new_sp: sub_traj = full_traj[i_old_sp:i_new_sp:-1] else: raise ValueError("shooting point indexes are equal") self._result += sub_traj @property def result(self): return self._result
Markdown is supported
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