Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreyp committed Jun 6, 2020
2 parents f165cc8 + 6ba69ec commit 8cf4b5f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
20 changes: 7 additions & 13 deletions moead_framework/problem/combinatorial/knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,16 @@ def penality(self, function_id):

return max_founded

def generate_random_solution(self):
solution = []
for i in range(0, self.object_number):
solution.append(random.getrandbits(1))

x = OneDimensionSolution(solution)

for j in range(self.function_numbers):
x.F.append(self.f(j, x.solution))

return x
def generate_random_solution(self, evaluate=True):
return self.generate_solution(array=np.random.randint(0, 2, self.object_number).tolist()[:], evaluate=evaluate)

def generate_solution(self, array):
def generate_solution(self, array, evaluate=True):
x = OneDimensionSolution(array)

for j in range(self.function_numbers):
x.F.append(self.f(j, x.solution))
if evaluate:
x.F.append(self.f(j, x.solution))
else:
x.F.append(None)

return x
14 changes: 2 additions & 12 deletions moead_framework/problem/combinatorial/rmnk.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,8 @@ def sigma(self, function_id, solution_array, item):

return accu

def generate_random_solution(self, evaluate=True, seed=None):
# solution = []
# for i in range(0, self.n):
# solution.append(random.getrandbits(1))

#print(solution)
# print(np.random.randint(0, 2, self.n).tolist())

if seed is not None:
np.random.seed(seed)

return self.generate_solution(np.random.randint(0, 2, self.n).tolist()[:])
def generate_random_solution(self, evaluate=True):
return self.generate_solution(array=np.random.randint(0, 2, self.n).tolist()[:], evaluate=evaluate)

def generate_solution(self, array, evaluate=True):
x = OneDimensionSolution(array)
Expand Down
4 changes: 2 additions & 2 deletions moead_framework/problem/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def f(self, function_id, solution):
pass

@abstractmethod
def generate_random_solution(self):
def generate_random_solution(self, evaluate=True):
pass

@abstractmethod
def generate_solution(self, array):
def generate_solution(self, array, evaluate=True):
pass
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

setuptools.setup(
name="moead-framework",
version="0.0.4",
version="0.3.1",
author="Geoffrey Pruvost",
author_email="geoffrey@pruvost.xyz",
description="MOEA/D Framework in Python 3",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/geoffreyp/moead",
url="https://moead-framework.github.io/documentation/html/index.html",
packages=setuptools.find_packages(),
install_requires=['numpy'],
classifiers=[
Expand Down

0 comments on commit 8cf4b5f

Please sign in to comment.