Skip to content

Commit f0aab83

Browse files
author
Julian Blank
committed
VERSION 0.3.2
1 parent 6d8cb13 commit f0aab83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+650
-187
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ However, for instance executing NSGA2:
7878
7979
problem = get_problem("zdt2")
8080
81-
algorithm = NSGA2(pop_size=100, elimate_duplicates=True)
81+
algorithm = NSGA2(pop_size=100, eliminate_duplicates=True)
8282
8383
res = minimize(problem,
8484
algorithm,

benchmark/benchmark_nelder_mead.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
import os
55
import pickle
66

7-
from pymoo.algorithms.so_genetic_algorithm import ga
8-
from pymoo.algorithms.so_nelder_mead import nelder_mead
9-
from pymoo.factory import get_problem, get_termination
10-
from pymoo.operators.crossover.nelder_mead_crossover import NelderMeadCrossover
7+
from pymoo.algorithms.so_nelder_mead import NelderMead
8+
9+
from pymoo.factory import get_problem
1110

1211
setup = [
1312
"go-amgm",
@@ -222,7 +221,7 @@ def add_with_variables(D, problem, n_vars):
222221
prefix = "runs"
223222

224223
# name of the experiment
225-
name = "nelder-mead-0.3.1"
224+
name = "nelder-mead-0.3.2"
226225

227226
# number of runs to execute
228227
n_runs = 10
@@ -234,7 +233,7 @@ def add_with_variables(D, problem, n_vars):
234233

235234
problem = get_problem(_problem)
236235

237-
method = nelder_mead(n_max_restarts=100)
236+
method = NelderMead(n_max_local_restarts=2)
238237

239238
for run in range(1, n_runs + 1):
240239
fname = "%s_%s.run" % (_problem, run)

benchmark/benchmark_nsga2.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import os
55
import pickle
66

7-
from pymoo.algorithms.nsga2 import nsga2
7+
from pymoo.algorithms.nsga2 import NSGA2
8+
89
from pymoo.factory import get_sampling, get_crossover, get_mutation, get_problem
910
from pymoo.operators.crossover.simulated_binary_crossover import SimulatedBinaryCrossover
1011
from pymoo.operators.mutation.polynomial_mutation import PolynomialMutation
@@ -90,7 +91,7 @@
9091
prefix = "runs"
9192

9293
# name of the experiment
93-
name = "pynsga2-0.3.1"
94+
name = "pynsga2-0.3.2"
9495

9596
# number of runs to execute
9697
n_runs = 100
@@ -107,7 +108,7 @@
107108
s = setup[_problem]
108109
problem = s['problem']
109110

110-
method = nsga2(
111+
method = NSGA2(
111112
pop_size=s['pop_size'],
112113
crossover=s['crossover'],
113114
mutation=s['mutation'],

benchmark/benchmark_nsga3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import pickle
33

4-
from pymoo.algorithms.nsga3 import nsga3
4+
from pymoo.algorithms.nsga3 import NSGA3
55
from pymoo.factory import get_problem, get_reference_directions
66
from pymoo.operators.crossover.simulated_binary_crossover import SimulatedBinaryCrossover
77
from pymoo.operators.mutation.polynomial_mutation import PolynomialMutation
@@ -206,7 +206,7 @@ def get_setup(n_obj):
206206
prefix = "runs"
207207

208208
# name of the experiment
209-
name = "pynsga3-0.3.1"
209+
name = "pynsga3-0.3.2"
210210

211211
# number of runs to execute
212212
n_runs = 50
@@ -222,7 +222,7 @@ def get_setup(n_obj):
222222
s = setup[_problem]
223223
problem = s['problem']
224224

225-
method = nsga3(
225+
method = NSGA3(
226226
s['ref_dirs'],
227227
pop_size=s['pop_size'],
228228
crossover=s['crossover'],

pymoo/algorithms/moead.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,4 @@ def _next(self):
130130
pop[N[I]] = off
131131

132132

133-
# =========================================================================================================
134-
# Interface
135-
# =========================================================================================================
136-
137-
def moead(*args, **kwargs):
138-
return MOEAD(*args, **kwargs)
139-
140-
141133
parse_doc_string(MOEAD.__init__)

pymoo/algorithms/nsga2.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,4 @@ def calc_crowding_distance(F, filter_out_duplicates=True):
202202
return crowding
203203

204204

205-
# =========================================================================================================
206-
# Interface
207-
# =========================================================================================================
208-
209-
def nsga2(*args, **kwargs):
210-
return NSGA2(*args, **kwargs)
211-
212-
213205
parse_doc_string(NSGA2.__init__)

pymoo/algorithms/nsga3.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,4 @@ def calc_niche_count(n_niches, niche_of_individuals):
335335
return niche_count
336336

337337

338-
# =========================================================================================================
339-
# Interface
340-
# =========================================================================================================
341-
342-
def nsga3(*args, **kwargs):
343-
return NSGA3(*args, **kwargs)
344-
345-
346338
parse_doc_string(NSGA3.__init__)

pymoo/algorithms/rnsga2.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,4 @@ def calc_norm_pref_distance(A, B, weights, ideal, nadir):
185185
return np.reshape(N, (A.shape[0], B.shape[0]))
186186

187187

188-
# =========================================================================================================
189-
# Interface
190-
# =========================================================================================================
191-
192-
193-
def rnsga2(*args, **kwargs):
194-
return RNSGA2(*args, **kwargs)
195-
196-
197188
parse_doc_string(RNSGA2.__init__)

pymoo/algorithms/rnsga3.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,4 @@ def line_plane_intersection(l0, l1, p0, p_no, epsilon=1e-6):
244244
return ref_proj
245245

246246

247-
# =========================================================================================================
248-
# Interface
249-
# =========================================================================================================
250-
251-
252-
def rnsga3(*args, **kwargs):
253-
return RNSGA3(*args, **kwargs)
254-
255-
256247
parse_doc_string(RNSGA3.__init__)

pymoo/algorithms/so_adam.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import numpy as np
2+
3+
from pymoo.algorithms.so_gradient_descent import GradientBasedAlgorithm
4+
5+
6+
class Adam(GradientBasedAlgorithm):
7+
8+
def __init__(self, X,
9+
alpha=0.005,
10+
beta_1=0.9,
11+
beta_2=0.999,
12+
epsilon=1e-8,
13+
**kwargs) -> None:
14+
super().__init__(X, **kwargs)
15+
16+
self.alpha = alpha
17+
self.beta_1 = beta_1
18+
self.beta_2 = beta_2
19+
self.epsilon = epsilon
20+
21+
self.t = 0
22+
self.m_t = 0
23+
self.v_t = 0
24+
25+
def apply(self):
26+
X, dX = self.X, self.dX
27+
28+
self.t += 1
29+
beta_1, beta_2 = self.beta_1, self.beta_2
30+
31+
# update moving average of gradient and squared gradient
32+
self.m_t = beta_1 * self.m_t + (1 - beta_1) * dX
33+
self.v_t = beta_2 * self.v_t + (1 - beta_2) * (dX * dX)
34+
35+
# calculates the bias-corrected estimates
36+
m_cap = self.m_t / (1 - (beta_1 ** self.t))
37+
v_cap = self.v_t / (1 - (beta_2 ** self.t))
38+
39+
# do the gradient update
40+
self.X = X - (self.alpha * m_cap) / (np.sqrt(v_cap) + self.epsilon)
41+
42+
def restart(self):
43+
self.t = 0
44+
self.m_t = 0
45+
self.v_t = 0
46+
self.alpha /= 2
47+
48+

0 commit comments

Comments
 (0)