Ejemplo n.º 1
0
 def runTest(self):
     from dcgpy import symbolic_regression, generate_koza_quintic, kernel_set_double
     import pygmo as pg
     X, Y = generate_koza_quintic()
     udp = symbolic_regression(points=X,
                               labels=Y,
                               rows=1,
                               cols=20,
                               levels_back=21,
                               arity=2,
                               kernels=kernel_set_double(["sum", "diff"])(),
                               n_eph=2,
                               multi_objective=False,
                               parallel_batches=0)
     prob = pg.problem(udp)
     pop = pg.population(prob, 10)
     udp.pretty(pop.champion_x)
     udp.prettier(pop.champion_x)
     # Unconstrained
     self.assertEqual(prob.get_nc(), 0)
     self.assertEqual(prob.get_nic(), 0)
     # Single objective
     self.assertEqual(prob.get_nobj(), 1)
     # Dimensions
     self.assertEqual(prob.get_nix(), 20 * (2 + 1) + 1)
     self.assertEqual(prob.get_nx(), 2 + prob.get_nix())
     # Has gradient and hessians
     self.assertEqual(prob.has_gradient(), True)
     self.assertEqual(prob.has_hessians(), True)
Ejemplo n.º 2
0
 def runTest(self):
     from dcgpy import symbolic_regression, generate_koza_quintic, kernel_set_double, gd4cgp
     import pygmo as pg
     import pickle
     X, Y = generate_koza_quintic()
     # Interface for the UDPs
     udp = symbolic_regression(points=X,
                               labels=Y,
                               rows=1,
                               cols=20,
                               levels_back=21,
                               arity=2,
                               kernels=kernel_set_double(
                                   ["sum", "diff", "mul", "pdiv"])(),
                               n_eph=2,
                               multi_objective=False,
                               parallel_batches=0)
     prob = pg.problem(udp)
     pop = pg.population(prob, 10)
     # Interface for the UDAs
     uda = gd4cgp(max_iter=10, lr=0.1, lr_min=1e-6)
     algo = pg.algorithm(uda)
     algo.set_verbosity(0)
     # Testing some evolutions
     pop = algo.evolve(pop)
     # In parallel
     archi = pg.archipelago(prob=prob, algo=algo, n=16, pop_size=4)
     archi.evolve()
     archi.wait_check()
     # Pickling.
     self.assertTrue(repr(algo) == repr(pickle.loads(pickle.dumps(algo))))