def HookeJeevesMove(self): currentPoint = self.history[self.iIter] bestPoints = list() for i in range(len(currentPoint.DV)): newDV = list() for j in range(len(currentPoint.DV)): if i == j: newDV.append(currentPoint.DV[j] + self.stepSize[j]) else: newDV.append(currentPoint.DV[j]) newPoint = Solution(Solution.getName(),newDV) if (not self.isTabu(newPoint)) and (not newPoint.isValid): self.addIfNotDominated(newPoint,bestPoints) self.removeDominatedPoints(bestPoints) newDV = list() for j in range(len(currentPoint.DV)): if i == j: newDV.append(currentPoint.DV[j] - self.stepSize[j]) else: newDV.append(currentPoint.DV[j]) newPoint = Solution(Solution.getName(),newDV) if (not self.isTabu(newPoint)) and (not newPoint.isValid): self.addIfNotDominated(newPoint,bestPoints) self.removeDominatedPoints(bestPoints) self.iIter += 1 self.iLocal += 1 nextPoint = self.selectRandom(bestPoints) self.history.append(nextPoint) bestPoints.remove(nextPoint) for remainingPoints in bestPoints: self.addIfNotDominated(remainingPoint,self.IM) self.removeDominatedPoints(self.IM) self.nextMoveHookeJeeves = False
def createChild(self,parent): """ create a candidate child """ i = self.P.index(parent) a = i b = i c = i while i == a or i == b or i == c or a == b or a == c or b == c: a = random.randint(0,len(self.P)-1) b = random.randint(0,len(self.P)-1) c = random.randint(0,len(self.P)-1) mateDV = self.mate(self.P[a],self.P[b],self.P[c]) if self.debug: for DV in mateDV: print str(DV) childDV = self.crossover(self.P[i],DV) return Solution(Solution.getName(),childDV)
def PatternMove(self): currentPoint = self.history[self.iIter] lastPoint = self.history[self.iIter-1] # find out last move lastMove = list() for i in range(len(currentPoint.DV)): lastMove.append(currentPoint.DV[i] - lastPoint.DV[i]) # recreate last move to current design vector nextDV = list() for i in range(len(currentPoint.DV)): nextDV.append(currentPoint.DV[i] + lastMove[i]) newPoint = Solution(Solution.getName(),nextDV) newPoint.evaluate() if newPoint.dominate(currentPoint): self.iIter += 1 self.iLocal += 1 self.history.append(newPoint) return True return False