Ejemplo n.º 1
0
    def notify(self, algorithm):
        problem = algorithm.problem

        pcp = PCP(title=("Gen %s" % algorithm.n_gen, {
            'pad': 30
        }),
                  bounds=(problem.xl, problem.xu),
                  labels=["$x_%s$" % k for k in range(problem.n_var)])
        pcp.set_axis_style(color="grey", alpha=0.5)

        pcp.add(algorithm.pop.get("X"),
                color="black",
                alpha=0.8,
                linewidth=1.5)
        if algorithm.off is not None:
            pcp.add(algorithm.off.get("X"),
                    color="blue",
                    alpha=0.8,
                    linewidth=0.5)

        pcp.add(algorithm.opt.get("X"), color="red", linewidth=4)
        pcp.do()

        self.video.record()
Ejemplo n.º 2
0
               verbose=False)

print(ret.F)

with Video(GIF("animation.gif")) as vid:
    for algorithm in ret.history:

        if algorithm.n_gen % 5 == 0:
            X, F = algorithm.pop.get("X", "F")
            nds = NonDominatedSorting().do(F, only_non_dominated_front=True)
            other = [k for k in range(len(F)) if k not in nds]

            fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 6))
            fig.suptitle("%s - %s - Gen %s" %
                         ("ZDT1", "NSGA2", algorithm.n_gen),
                         fontsize=16)

            pcp = PCP(ax=ax1, bounds=(problem.xl, problem.xu))
            pcp.set_axis_style(color="black", alpha=0.7)
            pcp.add(X[other], color="blue", linewidth=0.5)
            pcp.add(X[nds], color="red", linewidth=2)
            pcp.do()

            sc = Scatter(ax=ax2)
            sc.add(F[other], color="blue")
            sc.add(F[nds], color="red")
            sc.add(problem.pareto_front(), plot_type="line", color="black")
            sc.do()

            vid.record()
Ejemplo n.º 3
0
from pymoo.factory import get_problem, get_reference_directions
from pymoo.visualization.pcp import PCP

ref_dirs = get_reference_directions("das-dennis", 6, n_partitions=5) * [2, 4, 8, 16, 32, 64]
F = get_problem("dtlz1").pareto_front(ref_dirs)

PCP().add(F).show()
plot = PCP()
plot.set_axis_style(color="grey", alpha=0.5)
plot.add(F, color="grey", alpha=0.3)
plot.add(F[50], linewidth=5, color="red")
plot.add(F[75], linewidth=5, color="blue")
plot.show()

plot.reset()
plot.normalize_each_axis = False
plot.bounds = [[1, 1, 1, 2, 2, 5], [32, 32, 32, 32, 32, 32]]
plot.show()