示例#1
0
    def __init__(self):
        AlgConfig.__init__(self)

        #Maximum number of elements in parallel
        self.pmax = 4
        #Parameter that controls the relative weight of the pheromone
        #Use in the transition between subsystem-node and count-components-in-subsystem-node
        self.alpha1 = 0.1
        #Parameter thaht control the relative weight ot the pheromone
        #Use in the transition between count-components-in-subsystem-node and version-node
        self.alpha2 = 0.5
        #Parameter that control the local heuristic - version heuristic
        self.beta = 1
        #Use in pheromone update. Coefficient in front of old pheromone-value
        self.ro = 0.9
        #Use in pheromone update. Coefficient in delta-pheromone-value
        self.Q = 0.01
        #Use in pheromone update. Use in delta-pheromone-value calculation. Coefficient in penalty
        self.a = 1
        #Use in pheromone update. Use in delta-pheromone-value calculation. Coefficient in penalty
        self.b = 10
        #Initial pheromone-value on the edges
        self.pheromone0 = 1.0
        #Step in degraded ceiling algorithm
        self.localSearchStep = 0.0001
        #Good solution affinity
        self.affinity = 0.01
        #Amount of the ants
        self.antCounts = 50
        #ACO/DC algorithm maximum iteration
        self.maxIter = 300
        #Maximum iterations without changes in degraded ceiling algorithm
        self.dcMaxIterWithoutChange = 100
示例#2
0
 def __init__(self):
     AlgConfig.__init__(self)
     self.popNum = 30
     self.maxIter = 30
     self.crossPercent = GAParameter(0.7, 0.8, 0.9)
     self.Pcross = GAParameter(0.5, 0.75, 1.0)
     self.mutPercent = GAParameter(0.7, 0.8, 0.9)
     self.Pmut = GAParameter(0.5, 0.75, 0.9)
示例#3
0
 def __init__(self):
     AlgConfig.__init__(self)
     self.popNum = 30
     self.maxIter = 30
     self.crossPercent = GAParameter(0.7, 0.8, 0.9)
     self.Pcross = GAParameter(0.5, 0.75, 1.0)
     self.mutPercent = GAParameter(0.7, 0.8, 0.9)
     self.Pmut = GAParameter(0.5, 0.75, 0.9)
示例#4
0
    def Run(self):
        if self.sysconfig == None:
            QMessageBox.critical(self, "An error occurred",
                                 "System configuration must be defined")
            return
        Module.conf = self.sysconfig
        if self.constraints == None:
            QMessageBox.critical(self, "An error occurred",
                                 "Constraints must be defined")
            return
        System.constraints = self.constraints
        if self.algconfig == None and self.ui.algorithm.currentIndex() < 2:
            QMessageBox.critical(self, "An error occurred",
                                 "Algorithm configuration must be defined")
            return
        Algorithm.algconf = self.algconfig
        if Algorithm.algconf == None:
            Algorithm.algconf = AlgConfig()

        algidx = self.ui.algorithm.currentIndex()
        if algidx == 0:
            algorithm = GA()
        elif algidx == 1:
            algorithm = HGA()
        elif algidx == 2:
            algorithm = GA_optimistic()
        elif algidx == 3:
            algorithm = GA_optimistic_left()
        elif algidx == 4:
            algorithm = GA_Moore()
        elif algidx == 5:
            algorithm = HGA_Moore()
        Algorithm.result_filename = self.ui.result_filename.text()
        for i in range(self.ui.execNum.value()):
            if algorithm.algconf.metamodel:
                algorithm.algconf.metamodel.Clear()
            algorithm.Run()
            self.best = algorithm.currentSolution
        algorithm.PrintStats()
        try:
            os.remove("sch" + str(os.getpid()) + ".xml")
            os.remove("res" + str(os.getpid()) + ".xml")
        except:
            pass
示例#5
0
 def LoadFromXmlNode(self, node):
     AlgConfig.LoadFromXmlNode(self, node)
     self.popNum = int(node.getAttribute("popsize"))
     self.maxIter = int(node.getAttribute("maxiter"))
     type = node.getAttribute("type")
     for p in node.getElementsByTagName("par"):
         name = p.getAttribute("name")
         norm = float(p.getAttribute("norm"))
         if type == "hga":
             min = float(p.getAttribute("min"))
             max = float(p.getAttribute("max"))
             par = GAParameter(min, norm, max)
         else:
             par = GAParameter(None, norm, None)
         if name == "crosspercent":
             self.crossPercent = par
         elif name == "crossprob":
             self.Pcross = par
         elif name == "mutpercent":
             self.mutPercent = par
         elif name == "mutprob":
             self.Pmut = par