예제 #1
0
def main():
#    print('problem generation...')
#    prob = Problem.Random(4, 25)
#    print('saving problem data...')
#    prob.Save()
    print('loading problem data...')
    prob = Problem.Load()    
    print('initializing scheduler...')
    popSize = 20
    sched = Scheduler(popSize, prob)    
#    print('generating random solution...')
#    sched.solution = sched.RandomSolution()
    sched.setSelectionParams()
    n = 10
    print('solving...')
    for u in range(2,10):
        averIters = 0
        averCmax = 0
        sched.setSelectionParams(u)
        print('---------------------------------------')
        print('ParentsInNewPop = {0}'.format(u))        
        for i in range(n):
            sched.solution = sched.Solve(iterations = 5000)
            cmax = sched.Fitness(sched.solution)
            averCmax += cmax/n
            iters = sched.lastIters
            averIters += iters/n
            print('Try {0}: Algorithm took {1} iterations'.format(i, iters) +
            ' with Cmax: {0}'.format(cmax))
        print('In {0} tries, algorithm took on average {1} iterations'.format(n, round(averIters)))
        print('with average Cmax: {0}'.format(averCmax))
    print('saving...')
#    sched.SaveGraphData()
    print('calling gui...')
예제 #2
0
def main():
    #    print('problem generation...')
    #    prob = Problem.Random(4, 25)
    #    print('saving problem data...')
    #    prob.Save()
    print("loading problem data...")
    prob = Problem.Load()
    print("initializing scheduler...")
    sched = Scheduler(20, prob)
    #    print('generating random solution...')
    #    sched.solution = sched.RandomSolution()
    print("solving...")
    sched.solution = sched.Solve(iterations=5000)
    print("Cmax:")
    print(sched.Fitness(sched.solution))
    print("saving...")
    sched.SaveGraphData()
    print("calling gui...")
    main_data.main()
예제 #3
0
    def solve_problem(self):
        ready_to_solve = QtGui.QMessageBox.Yes
        if not self.new:
            ready_to_solve = QtGui.QMessageBox.question(self,  'Solver',
                        'You are going to generate solution for the previously generated problem, are you sure?',  QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
        if ready_to_solve == QtGui.QMessageBox.Yes :
            mutop_operator = self.mutop_combo.currentIndex()
            xop_operator = self.xop_combo.currentIndex()

            self.statusBar.setText('Loading problem data...')
            prob = Problem.Load()

            pop_size = int(self.population_edit.displayText())

            self.statusBar.setText('Initializing scheduler...')
            sched = Scheduler(pop_size, prob)

            self.statusBar.setText('Solving...')

            iter_num = int(self.iter_edit.displayText())
            test_q = int(self.iter_edit.displayText())
            cross_pr = float(self.crossp_edit.displayText())
            parent_f = float(self.parents_edit.displayText())


            sched.SetOperators(mutationOp = mutop_operator,
                               crossingOp = xop_operator)
            sched.setSelectionParams(parentsInNewPop = parent_f,
                                     mutationProb = cross_pr)

            sched.Trials = int(self.test_edit.displayText())
            sched.solution = sched.Solve(iterations = iter_num)

            self.statusBar.setText('Saving...')
            sched.SaveGraphData()

            self.statusBar.setText('Calling graph gui...')
            self.DataAnalysisDialog = DataAnalysis()
            self.DataAnalysisDialog.create()
            self.DataAnalysisDialog.show()
            self.statusBar.setText('Solved!')