27 lines
747 B
Python
27 lines
747 B
Python
import math
|
|
import random
|
|
from model.base_model import Model
|
|
import numpy as np
|
|
|
|
class MyModel(Model):
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
def init(self, nodes):
|
|
"""
|
|
Put your initialization here.
|
|
"""
|
|
super().init(nodes)
|
|
|
|
def fit(self, max_it):
|
|
"""
|
|
Put your iteration process here.
|
|
"""
|
|
random_solutions = []
|
|
for i in range(0, max_it):
|
|
solution = np.random.permutation(self.N).tolist()
|
|
random_solutions.append(solution)
|
|
self.fitness_list.append(self.fitness(solution))
|
|
|
|
self.best_solution = random_solutions[self.fitness_list.index(min(self.fitness_list))]
|
|
return self.best_solution, self.fitness_list |