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]))
class TaskConvPrintTestCase(TestCase): def setUp(self): self.D, self.nFES, self.nGEN = 10, 10, 10 self.t = TaskConvPrint(D=self.D, nFES=self.nFES, nGEN=self.nGEN, benchmark=MyBenchmark()) def test_eval(self): self.t.eval(full(self.D, 2.)) self.assertTrue(array_equal(full(self.D, 2.), self.t.xb)) self.t.eval(full(self.D, -1.)) self.assertTrue(array_equal(full(self.D, -1.), self.t.xb)) self.t.eval(full(self.D, .0)) self.assertTrue(array_equal(full(self.D, .0), self.t.xb))
def logging_example(alg, cec, fnum=1, D=10, nFES=50000, nGEN=5000, seed=[None], optType=OptimizationType.MINIMIZATION, optFunc=MinMB, wout=False, sr=[-100, 100], **kwu): func = getCecBench(cec, D) task = TaskConvPrint(D=D, nFES=nFES, nGEN=nGEN, optType=optType, benchmark=optFunc(func, sr[0], sr[1], fnum)) algo = alg(seed=seed[0], task=task) best = algo.run() logger.info('%s %s' % (best[0], best[1]))
def setUp(self): self.D, self.nFES, self.nGEN = 10, 10, 10 self.t = TaskConvPrint(D=self.D, nFES=self.nFES, nGEN=self.nGEN, benchmark=MyBenchmark())