From 20648e9bf841df28306dfdb3b44dae3de51000d4 Mon Sep 17 00:00:00 2001 From: mjjo Date: Mon, 20 Aug 2018 17:32:15 +0900 Subject: [PATCH] update end condition --- utility.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/utility.py b/utility.py index 1318cce..11fa70a 100644 --- a/utility.py +++ b/utility.py @@ -19,7 +19,7 @@ class Loader: class Stepper: - def __init__(self, print_gap=1.0e-2, break_gap=1.0e-9): + def __init__(self, print_gap=1.0e-4, break_gap=1.0e-9): self._prev_cost = 0 self._cost = 0 self._cost_diff = 0 @@ -41,22 +41,19 @@ class Stepper: self._cost = step self._cost_diff = self._cost - self._prev_cost - self.accumulator += self._cost_diff + self.accumulator += abs(self._cost_diff) if self.accumulator >= self._print_gap: - self.accumulator -= self._print_gap + self.accumulator = 0 self._b_print_turn = True - if self._prev_cost != 0 and self._cost_diff > 0: + if self._prev_cost != 0 and (self._cost_diff > 0 or abs(self._cost_diff) < self._break_gap): self._serial_divergence_cnt += 1 - if self._serial_divergence_cnt >= 3: + if self._serial_divergence_cnt >= 5: self._b_break_turn = True else: self._serial_divergence_cnt = 0 - if abs(self._cost_diff) < self._break_gap: - self._b_break_turn = True - def is_print_turn(self): return self._b_print_turn