mirror of
https://github.com/jung-geun/PSO.git
synced 2025-12-20 04:50:45 +09:00
23-05-29
EBPSO 알고리즘 구현 - 선택지로 추가 random 으로 분산시키는 방법 구현 - 선택지로 추가 iris 기준 98퍼센트로 나오나 정확한 결과를 지켜봐야 할것으로 보임
This commit is contained in:
31
psokeras/util.py
Executable file
31
psokeras/util.py
Executable file
@@ -0,0 +1,31 @@
|
||||
class ProgressBar:
|
||||
def __init__(self, steps, updates=10):
|
||||
self.step = 0
|
||||
self.step_size = (steps // updates)
|
||||
self.total_steps = steps
|
||||
self.updates = updates
|
||||
|
||||
bar = self._make_bar(0)
|
||||
print(bar, end=' ')
|
||||
|
||||
def update(self, i):
|
||||
if i % self.step_size > 0:
|
||||
return
|
||||
|
||||
self.step = i // self.step_size
|
||||
bar = self._make_bar(i)
|
||||
|
||||
print(bar, end=' ')
|
||||
|
||||
def done(self):
|
||||
self.step = self.total_steps
|
||||
bar = self._make_bar(self.updates)
|
||||
print(bar)
|
||||
|
||||
def _make_bar(self, x):
|
||||
bar = "["
|
||||
for x in range(self.updates):
|
||||
print("\r", end=' ')
|
||||
bar += "=" if x < self.step else " "
|
||||
bar += "]"
|
||||
return bar
|
||||
Reference in New Issue
Block a user