mirror of
https://github.com/jung-geun/PSO.git
synced 2025-12-20 04:50:45 +09:00
EBPSO 알고리즘 구현 - 선택지로 추가 random 으로 분산시키는 방법 구현 - 선택지로 추가 iris 기준 98퍼센트로 나오나 정확한 결과를 지켜봐야 할것으로 보임
32 lines
760 B
Python
Executable File
32 lines
760 B
Python
Executable File
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
|