diff --git a/evolve.py b/evolve.py index 19b1d72f818984f863075dc4b6ef8ab986a03237..7f101b79c764b3c42fb8930e223139c9ade5a274 100644 --- a/evolve.py +++ b/evolve.py @@ -37,7 +37,10 @@ if "__main__" == __name__: else: conf["selection"]["name"] = "tools." + conf["selection"]["name"] conf["params"]["selection"] = conf["selection"] - + + if "qd" in conf["algorithm"]["name"]: + conf["params"]["mono-objectif"] = True + if conf["individual"] == "Tree": import experiments.gp as evoTool elif conf["individual"] == "Linear": @@ -58,7 +61,6 @@ if "__main__" == __name__: from GPRL.containers.grid import FixGrid as Grid conf["population"]["args"]["features_domain"] = np.array(conf["population"]["args"]["features_domain"])[conf["params"]["features_kept"]] conf["algorithm"]["args"]["container"] = Grid(**conf["population"]["args"]) - if conf["individual"] == "Tree": from experiments.qdgp import MC_fitness elif conf["individual"] == "Linear": diff --git a/experiments/gp.py b/experiments/gp.py index d6ecdc57833056c5f2b4c3c1d5d5df0996efa9ff..487ed2785a03a52e78fa3bbc251310ca626e72a1 100644 --- a/experiments/gp.py +++ b/experiments/gp.py @@ -88,8 +88,10 @@ class Factory(EvolveFactory): pset.addEphemeralConstant("const_"+str(k), lambda: np.random.uniform(-20.0, 20.0), float) pset.addTerminal(True, bool) pset.addTerminal(1, int) - - creator.create("FitnessMax", UCBFitness, weights=(1.0, -1.0), c=self.conf["c"], sigma=1) + weights = (1.0, -1.0) + if self.conf.get("mono-objectif", None): + weights = (1.0,) + creator.create("FitnessMax", UCBFitness, weights=weights, c=self.conf["c"], sigma=1) creator.create("Individual", list, fitness=creator.FitnessMax) toolbox = base.Toolbox() diff --git a/experiments/linGP.py b/experiments/linGP.py index b451ccd81e265bec9d0a24cf30e5849fcb7974fe..9795198f0aee4f45ccdfdb60118e3638b8599dac 100644 --- a/experiments/linGP.py +++ b/experiments/linGP.py @@ -78,7 +78,10 @@ class Factory(EvolveFactory): toolbox, creator = self.make_toolbox() def make_toolbox(self): - creator.create("FitnessMax", UCBFitness, weights=(1.0, -1.0), c=self.conf["c"], sigma=1) + weights = (1.0, -1.0) + if self.conf.get("mono-objectif", None): + weights = (1.0,) + creator.create("FitnessMax", UCBFitness, weights=weights, c=self.conf["c"], sigma=1) creator.create("Individual", linGP.Program, fitness=creator.FitnessMax) if self.conf['function_set']=="small":