Skip to content

Commit e74169f

Browse files
authored
Add files via upload
1 parent 4aa5292 commit e74169f

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

algorithm/APNsgaIII.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ def dualCtrlStrategy(self, population, bestNotEnhance, nMax):
5858
tumor.mutation(self._mutationSize, self._mutationProbability)
5959

6060
self._worst = population[-1]
61-
if self.dominate(tumor, chromosome):
61+
if tumor.dominates(chromosome):
6262
population[i] = tumor
63-
if self.dominate(tumor, self._best):
63+
if tumor.dominates(self._best):
6464
self._best = tumor
6565
else:
6666
if bestNotEnhance >= 15 and N < nMax:
6767
N += 1
68-
if self.dominate(self._worst, tumor):
68+
if self._worst.dominates(tumor):
6969
population.append(tumor)
7070
self._worst = tumor
7171
else:
@@ -124,7 +124,7 @@ def run(self, maxRepeat=9999, minFitness=0.999):
124124

125125
# replacement
126126
pop[next] = self.replacement(pop[cur])
127-
self._best = pop[next][0] if self.dominate(pop[next][0], pop[cur][0]) else pop[cur][0]
127+
self._best = pop[next][0] if pop[next][0].dominates(pop[cur][0]) else pop[cur][0]
128128

129129
self.dualCtrlStrategy(pop[next], bestNotEnhance, nMax)
130130

algorithm/NsgaIII.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ def normalizeObjectives(self, pop, fronts, intercepts, idealPoint):
257257
else:
258258
convObj /= np.finfo(float).eps
259259

260-
def dominate(self, left, right):
261-
better = False
262-
for f, leftObj in enumerate(left.objectives):
263-
if leftObj > right.objectives[f]:
264-
return False
265-
266-
if leftObj < right.objectives[f]:
267-
better = True
268-
269-
return better
270260

271261
def nondominatedSort(self, pop):
272262
numAssignedIndividuals, rank = 0, 1
@@ -281,10 +271,10 @@ def nondominatedSort(self, pop):
281271

282272
be_dominated = False
283273
for j, front in enumerate(curFront):
284-
if self.dominate(pop[front], chromosome):
274+
if pop[front].dominates(chromosome):
285275
be_dominated = True
286276
break
287-
elif self.dominate(chromosome, pop[front]):
277+
elif chromosome.dominates(pop[front]):
288278
del curFront[j]
289279

290280
if not be_dominated:
@@ -462,7 +452,7 @@ def run(self, maxRepeat=9999, minFitness=0.999):
462452

463453
# replacement
464454
pop[next] = self.replacement(pop[cur])
465-
self._best = pop[next][0] if self.dominate(pop[next][0], pop[cur][0]) else pop[cur][0]
455+
self._best = pop[next][0] if pop[next][0].dominates(pop[cur][0]) else pop[cur][0]
466456

467457
cur, next = next, cur
468458
currentGeneration += 1

model/Schedule.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,14 @@ def resizeConvertedObjectives(self, numObj):
420420

421421
def clone(self):
422422
return self.copy(self, False)
423+
424+
def dominates(self, other):
425+
better = False
426+
for f, obj in enumerate(self.objectives):
427+
if obj > other.objectives[f]:
428+
return False
429+
430+
if obj < other.objectives[f]:
431+
better = True
432+
433+
return better

0 commit comments

Comments
 (0)