Esempio n. 1
0

parse_doc_string(MMGA.__init__)

if __name__ == '__main__':
    problem = MultiModalSimple2()

    algorithm = MMGA(pop_size=20, eliminate_duplicates=True)

    ret = minimize(problem,
                   algorithm,
                   termination=('n_gen', 100),
                   seed=1,
                   save_history=True,
                   verbose=False)

    def plot(algorithm):
        pop = algorithm.pop
        sc = Scatter(title=algorithm.n_gen)
        sc.add(curve(algorithm.problem), plot_type="line", color="black")
        sc.add(np.column_stack([pop.get("X"), pop.get("F")]), color="red")
        sc.do()

    plot(ret.algorithm)
    plt.show()

    with Video(File("mm.mp4")) as vid:
        for entry in ret.history:
            plot(entry)
            vid.record()
Esempio n. 2
0
 def __init__(self):
     super().__init__()
     self.vid = Video(File("tsp.mp4"))
Esempio n. 3
0
import numpy as np
from matplotlib import pyplot as plt

from pyrecorder.recorders.file import File
from pyrecorder.video import Video

with Video(File("wave.mp4", fps=15)) as vid:

    for t in range(200):
        x = np.linspace(0, 4, 1000)
        y = np.sin(2 * np.pi * (x - 0.01 * t))
        plt.plot(x, y)

        vid.record()
Esempio n. 4
0
import matplotlib.pyplot as plt
import numpy as np

from pyrecorder.recorders.file import File
from pyrecorder.video import Video

plt.style.use('dark_background')

with Video(File("coil.mp4", fps=15)) as vid:
    for t in range(500):
        a = np.arange(t) * 0.1
        plt.plot(a * np.sin(a), a * np.cos(a))
        plt.xlim(-50, 50)
        plt.ylim(-50, 50)
        plt.axis('off')
        vid.record()

Esempio n. 5
0
# START example
import numpy as np
from pyrecorder.recorders.file import File
from pyrecorder.video import Video

from pymoo.algorithms.nsga2 import NSGA2
from pymoo.visualization.scatter import Scatter

vid = Video(File("example.mp4"))

for k in range(10):
    X = np.random.random((100, 2))
    Scatter(title=str(k)).add(X).do()
    vid.record()

vid.close()
# END example

# START ga
from pymoo.factory import get_problem
from pymoo.optimize import minimize

problem = get_problem("zdt1")

algorithm = NSGA2(pop_size=100, eliminate_duplicates=True)

ret = minimize(problem,
               algorithm,
               termination=('n_gen', 100),
               seed=1,
               save_history=True,