Esempio n. 1
0
 def getRandam1HDMutant(self, configuration, avoidNodes={}):
     randomNode = sim.getRandomInt(0, self.__inputs.nValue()-1, avoidNodes)
     randomAllele = sim.getRandomInt(0, self.__inputs.aValue()-1)
     # Find an Allele at position randomNode that is different
     while randomAllele == configuration[randomNode]:
         randomAllele = sim.getRandomInt(0, self.__inputs.aValue()-1)
     randomConfig = list(configuration)
     randomConfig[randomNode] = randomAllele
     return [randomNode, randomConfig]
Esempio n. 2
0
 def __init__(self, simInput):
     self.__inputs = simInput
     if simInput.isUserDefinedStartConfig():
         [self.__nodeConfig, self.__fitnessDict] = simInput.startConfig()
     else:
         self.__nodeConfig = list([])
         self.__fitnessDict = dict({})
         for index in range(0, self.__inputs.nValue()):
             nextNodeValue = sim.getRandomInt(0, self.__inputs.aValue()-1)
             self.__nodeConfig.append(nextNodeValue)
             self.__fitnessDict[index] = dict({})
     self.logger =  logging.getLogger(__name__)
Esempio n. 3
0
 def setup(self):
     self.__randContext = dict({})
     self.__attemptedFlips = 0
     self.__attLog = []
     self.__acceptedFlips = 0
     self.__accLog = []
     self.__visibleNodes = {}
     self.__opaqueNodes = {}
     for index in range(0, self.__inputs.nBar()):
         nextVisibleNode = sim.getRandomInt(0, self.__inputs.nValue() - 1, self.__visibleNodes)
         self.__visibleNodes[nextVisibleNode] = 1
     for index in range(0, self.__inputs.nValue()):
         if index not in self.__visibleNodes:
             self.__opaqueNodes[index] = 1
Esempio n. 4
0
 def getJumpNeighbour(self, configuration, distance, cumulative):
     """
     When cumulative is True a random distance in [1, distance] is chosen
     and a configuration at that random distance is generated 
     When cumulative is False a configuration at exactly distance is generated
     """
     nodesMutated = {}
     nodesMutated.update(self.__opaqueNodes)
     current = configuration
     if cumulative == True:
         generatedDistance = sim.getRandomInt(1, distance)
     else:
         generatedDistance = distance
         
     for index in range(0, generatedDistance):
         [nextNode, nextConfig] = self.getRandam1HDMutant(current, nodesMutated)
         nodesMutated[nextNode] = 1
         current = nextConfig
     return current