Exemplo n.º 1
0
def getPTSZToolBox(inputFileName):

    creator.create("FitnessMin", base.Fitness, weights=(-1.0, ))
    creator.create("Individual", list, fitness=creator.FitnessMin)

    numberOfTasks, tasks = utils.readInputFile(inputFileName)

    def getFirstFreeMachine(currentTimes):
        minTime = min(currentTimes)
        return currentTimes.index(minTime)

    def evalBenchmark(individual):
        return eval(individual)

    def eval(list_of_tasks_id):
        currentTimes = []
        solution = []
        for _ in range(4):
            currentTimes.append(0)
            solution.append([])

        tardines_sum = 0

        for task_id in list_of_tasks_id:
            machine = getFirstFreeMachine(currentTimes)
            solution[machine].append(task_id)

            currentTimes[machine] = max(
                currentTimes[machine],
                tasks[task_id - 1].r) + tasks[task_id - 1].p

            tardines_sum += max(0,
                                currentTimes[machine] - tasks[task_id - 1].d)

        return tardines_sum,

    toolbox = registerStandard(numberOfTasks, creator, evalBenchmark, tasks)

    return toolbox
Exemplo n.º 2
0
def submitDataFile(hint, fname, numClusters):
    submitDataArray(hint, fname, utils.readInputFile(fname), numClusters)
Exemplo n.º 3
0
def submitDataFile(hint, fname, gcd=None):
    submitDataArray(hint, fname, utils.readInputFile(fname), gcd)
Exemplo n.º 4
0
        self.remove()
        self.addIndividual(newIndividual)

        #print("---------------- Evolution done ----------------")
        return True

    def addToLog(self, log):
        try:
            log.append(self.getBestIndividual().getFittnesValue())
        except:
            print("Erorr:", len(self.individuals))


##MAIN##
numberOfTasks, tasks = utils.readInputFile("input\\in132207_50.txt")

populationSize = 30

outputLog = []

population = Population(populationSize)
population.generateIndividuals(tasks)
population.generateFirstSolutions()

population.addToLog(outputLog)

best = 99999

for i in range(0, 100000):
    if population.getBestIndividual().getFittnesValue() < best:
Exemplo n.º 5
0
def submitDataFile(hint, fname, maxSpacing):
    submitDataArray(hint, fname, utils.readInputFile(fname), maxSpacing)
Exemplo n.º 6
0
def submitDataFile(hint, fname, optimize=False, gcd=None):
    submitDataArray(hint, fname, utils.readInputFile(fname), optimize, False,
                    gcd)