Example #1
0
 def test_getDictArgs_fine(self):
     args = getDictArgs(['-D', '10', '-nFES', '100000000', '-a', 'SCA'])
     self.assertTrue(args)
     self.assertEqual(args['D'], 10)
     self.assertEqual(args['nFES'], 100000000)
     self.assertEqual(args['algo'], 'SCA')
     self.assertEqual(args['seed'], [None])
Example #2
0
 def test_getDictArgs_seed_fine(self):
     args = getDictArgs([
         '-D', '10', '-nFES', '100000000', '-a', 'SCA', '-seed', '1', '234',
         '231523'
     ])
     self.assertTrue(args)
     self.assertEqual(args['D'], 10)
     self.assertEqual(args['nFES'], 100000000)
     self.assertEqual(args['algo'], 'SCA')
     self.assertEqual(args['seed'], [1, 234, 231523])
Example #3
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), SineCosineAlgorithm
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #4
0
		algo = alg(seed=seed[i % len(seed)], task=task)
		best = algo.run()
		logger.info('%s %s' % (best[0], best[1]))

def logging_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))

def plot_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')

def getOptType(otype):
	if otype == OptimizationType.MINIMIZATION: return MinMB
	elif otype == OptimizationType.MAXIMIZATION: return MaxMB
	else: return None

if __name__ == '__main__':
	pargs, algo = getDictArgs(sys.argv[1:]), GravitationalSearchAlgorithm
	optFunc = getOptType(pargs['optType'])
	if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'log': logging_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'plot': plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #5
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), MonkeyKingEvolutionV1
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #6
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), FireworksAlgorithm
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #7
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0])
    best = algo.run(task)
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), EvolutionStrategyML
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #8
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), MultipleTrajectorySearch
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #9
0
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(
        sys.argv[1:]), Runner.getAlgorithm('EnhancedFireworksAlgorithm')
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #10
0
		algo = alg(seed=seed[i % len(seed)], task=task)
		best = algo.run()
		logger.info('%s %s' % (best[0], best[1]))

def logging_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))

def plot_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')

def getOptType(otype):
	if otype == OptimizationType.MINIMIZATION: return MinMB
	elif otype == OptimizationType.MAXIMIZATION: return MaxMB
	else: return None

if __name__ == '__main__':
	pargs, algo = getDictArgs(sys.argv[1:]), FireflyAlgorithm
	optFunc = getOptType(pargs['optType'])
	if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'log': logging_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'plot': plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #11
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), SimulatedAnnealing
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #12
0
                 nGEN=100000,
                 seed=[None],
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), ForestOptimizationAlgorithm
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)
Example #13
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), CamelAlgorithm
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #14
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), NelderMeadMethod
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #15
0
                 optFunc=MinMB,
                 **kn):
    NP = 120
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task, Np=NP)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), Runner.getAlgorithm('DE')
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #16
0
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed[0], task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), ParticleSwarmAlgorithm
    optFunc = getOptType(pargs['optType'])
    pargs.pop('nFES', None), pargs.pop('nGEN', None)
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #17
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed, task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), GlowwormSwarmOptimizationV3
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #18
0
		algo = alg(seed=seed, task=task)
		best = algo.run()
		logger.info('%s %s' % (best[0], best[1]))

def logging_example(alg, D=10, nFES=50000, nGEN=100000, seed=None, optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed, task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))

def plot_example(alg, D=10, nFES=50000, nGEN=100000, seed=None, optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed, task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')

def getOptType(otype):
	if otype == OptimizationType.MINIMIZATION: return MinMB
	elif otype == OptimizationType.MAXIMIZATION: return MaxMB
	else: return None

if __name__ == '__main__':
	pargs, algo = getDictArgs(sys.argv[1:]), HarmonySearchV1
	optFunc = getOptType(pargs['optType'])
	if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'log': logging_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'plot': plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #19
0
		algo = alg(seed=seed, task=task)
		best = algo.run()
		logger.info('%s %s' % (best[0], best[1]))

def logging_example(alg, D=10, nFES=50000, nGEN=100000, seed=None, optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed, task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))

def plot_example(alg, D=10, nFES=50000, nGEN=100000, seed=None, optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed, task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')

def getOptType(otype):
	if otype == OptimizationType.MINIMIZATION: return MinMB
	elif otype == OptimizationType.MAXIMIZATION: return MaxMB
	else: return None

if __name__ == '__main__':
	pargs, algo = getDictArgs(sys.argv[1:]), TabuSearch
	optFunc = getOptType(pargs['optType'])
	if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'log': logging_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'plot': plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #20
0
		algo = alg(seed=seed[i % len(seed)], task=task)
		best = algo.run()
		logger.info('%s %s' % (best[0], best[1]))

def logging_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))

def plot_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')

def getOptType(otype):
	if otype == OptimizationType.MINIMIZATION: return MinMB
	elif otype == OptimizationType.MAXIMIZATION: return MaxMB
	else: return None

if __name__ == '__main__':
	pargs, algo = getDictArgs(sys.argv[1:]), GeneticAlgorithm
	optFunc = getOptType(pargs['optType'])
	if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'log': logging_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'plot': plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #21
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed, task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), HillClimbAlgorithm
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #22
0
                 optType=OptimizationType.MINIMIZATION,
                 optFunc=MinMB,
                 **kn):
    task = TaskConvPlot(D=D,
                        nFES=nFES,
                        nGEN=nGEN,
                        optType=optType,
                        benchmark=optFunc())
    algo = alg(seed=seed, task=task)
    best = algo.run()
    logger.info('%s %s' % (best[0], best[1]))
    input('Press [enter] to continue')


def getOptType(otype):
    if otype == OptimizationType.MINIMIZATION: return MinMB
    elif otype == OptimizationType.MAXIMIZATION: return MaxMB
    else: return None


if __name__ == '__main__':
    pargs, algo = getDictArgs(sys.argv[1:]), KrillHerdV4
    optFunc = getOptType(pargs['optType'])
    if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'log':
        logging_example(algo, optFunc=optFunc, **pargs)
    elif pargs['runType'] == 'plot':
        plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
Example #23
0
		algo = alg(seed=seed[i % len(seed)], task=task)
		best = algo.run()
		logger.info('%s %s' % (best[0], best[1]))

def logging_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))

def plot_example(alg, D=10, nFES=50000, nGEN=100000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, **kn):
	task = TaskConvPlot(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc())
	algo = alg(seed=seed[0], task=task)
	best = algo.run()
	logger.info('%s %s' % (best[0], best[1]))
	input('Press [enter] to continue')

def getOptType(otype):
	if otype == OptimizationType.MINIMIZATION: return MinMB
	elif otype == OptimizationType.MAXIMIZATION: return MaxMB
	else: return None

if __name__ == '__main__':
	pargs, algo = getDictArgs(sys.argv[1:]), Runner.getAlgorithm('DynamicFireworksAlgorithmGauss')
	optFunc = getOptType(pargs['optType'])
	if not pargs['runType']: simple_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'log': logging_example(algo, optFunc=optFunc, **pargs)
	elif pargs['runType'] == 'plot': plot_example(algo, optFunc=optFunc, **pargs)

# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3