private void down(final Reaction<T> r, final int i) { int index = i; final Time newTime = r.getTau(); do { int minIndex = 2 * index + 1; if (minIndex > tree.size() - 1) { return; } Time minTime = times.get(minIndex); Reaction<T> min = tree.get(minIndex); final int right = minIndex + 1; if (right < tree.size()) { final Time rr = times.get(right); if (rr.compareTo(minTime) < 0) { min = tree.get(right); minIndex = right; minTime = rr; } } if (newTime.compareTo(minTime) > 0) { swap(index, r, minIndex, min); index = minIndex; } else { return; } } while (true); }
@Override public synchronized void goToTime(final Time t) { runUntil(() -> getTime().compareTo(t) < 0); }
private boolean up(final Reaction<T> r, final int i) { int index = i; int parentIndex = getParent(index); final Time newTime = r.getTau(); if (parentIndex == -1) { return false; } else { Reaction<T> parent = tree.get(parentIndex); if (newTime.compareTo(times.get(parentIndex)) >= 0) { return false; } else { do { swap(index, r, parentIndex, parent); index = parentIndex; parentIndex = getParent(index); if (parentIndex == -1) { return true; } parent = tree.get(parentIndex); } while (newTime.compareTo(times.get(parentIndex)) < 0); return true; } } }
@Override public int compareTo(final DependencyHandler<T> o) { return reaction.getTau().compareTo(o.getReaction().getTau()); }
idleProcessSingleCommand(); while (status != Status.TERMINATED && curStep < steps && currentTime.compareTo(finalTime) < 0) { while (!commands.isEmpty()) { commands.poll().run();
mu = root; final Time t = mu.getTau(); if (t.compareTo(currentTime) < 0) { throw new IllegalStateException(mu + "\nis scheduled in the past at time " + t + ", current time is " + currentTime + "\nProblem occurred at step " + curStep);