upper_bounds=prob.upper,
            )
            objective = VectorObjective(name=obj_names, evaluator=prob.eval)
            problem = MOProblem([objective], variables, None)
            problem.ideal = prob.ideal
            problem.nadir = (
                abs(np.random.normal(size=n_obj, scale=0.15)) + 1
            ) * prob.nadir

            true_nadir = prob.nadir

            scalar = asf(ideal=problem.ideal, nadir=true_nadir)

            # a posteriori
            a_post_rvea = RVEA(
                problem=problem, interact=False, n_gen_per_iter=gen, n_iterations=4
            )
            a_post_nsga = NSGAIII(
                problem=problem, interact=False, n_gen_per_iter=gen, n_iterations=4
            )
            # interactive
            int_rvea = RVEA(problem=problem, interact=True, n_gen_per_iter=gen)
            int_nsga = NSGAIII(problem=problem, interact=True, n_gen_per_iter=gen)
            # New algorithm
            nimb_rvea = IOPIS_RVEA(problem, n_gen_per_iter=gen)
            nimb_nsga = IOPIS_NSGAIII(problem, n_gen_per_iter=gen)

            responses = np.random.rand(4, n_obj)

            _, pref_int_rvea = int_rvea.requests()
            _, pref_int_nsga = int_nsga.requests()
예제 #2
0
    x_names = [f"x{i}" for i in range(1, num_var[problem_name] + 1)]
    y_names = ["f1", "f2"]

    data = pd.DataFrame(np.hstack((x, y.objectives)),
                        columns=x_names + y_names)

    problem = DataProblem(data=data,
                          variable_names=x_names,
                          objective_names=y_names)

    problem.train(LipschitzianRegressor)
    evolver_L_opt = oRVEA(problem, use_surrogates=True)
    while evolver_L_opt.continue_evolution():
        evolver_L_opt.iterate()

    evolver_L = RVEA(problem, use_surrogates=True)
    while evolver_L.continue_evolution():
        evolver_L.iterate()

    evolver_L_robust = robust_RVEA(problem, use_surrogates=True)
    while evolver_L_robust.continue_evolution():
        evolver_L_robust.iterate()

    problem.train(GaussianProcessRegressor)
    evolver_G_opt = oRVEA(problem, use_surrogates=True)
    while evolver_G_opt.continue_evolution():
        evolver_G_opt.iterate()

    evolver_G = RVEA(problem, use_surrogates=True)
    while evolver_G.continue_evolution():
        evolver_G.iterate()
예제 #3
0
파일: server.py 프로젝트: light-weaver/misc
f1 = _ScalarObjective(name="f1", evaluator=f_1, maximize=[True])
f2 = _ScalarObjective(name="f2", evaluator=f_2, maximize=[True])
f3 = _ScalarObjective(name="f3", evaluator=f_3, maximize=[True])
f4 = _ScalarObjective(name="f4", evaluator=f_4)
f5 = _ScalarObjective(name="f5", evaluator=f_5)

varsl = variable_builder(
    ["x_1", "x_2"],
    initial_values=[0.5, 0.5],
    lower_bounds=[0.3, 0.3],
    upper_bounds=[1.0, 1.0],
)

problem = MOProblem(variables=varsl, objectives=[f1, f2, f3, f4, f5])

evolver = RVEA(problem, interact=True, n_iterations=10, n_gen_per_iter=100)

_, pref = evolver.iterate()
n_iteration = 1

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("10.0.2.15", 5005))
# sock.bind(("127.0.0.1", 5005))
sock.listen(1)

print("Waiting for ComVis to connect...")
connection, client_addr = sock.accept()

print("Connection estabilished!")

while True:
예제 #4
0
for gen in num_gen_per_iter:
    for n_obj, n_var in zip(n_objs, n_vars):
        for problem_name in problem_names:
            print(f"Loop {counter} of {total_count}")
            counter += 1
            problem = test_problem_builder(name=problem_name,
                                           n_of_objectives=n_obj,
                                           n_of_variables=n_var)

            problem.ideal = np.asarray([0] * n_obj)
            problem.nadir = abs(np.random.normal(size=n_obj, scale=0.15)) + 1

            true_nadir = np.asarray([1] * n_obj)

            # interactive
            int_rvea = RVEA(problem=problem, interact=True, n_gen_per_iter=gen)
            int_nsga = NSGAIII(problem=problem,
                               interact=True,
                               n_gen_per_iter=gen)

            # initial reference point is specified randomly
            response = np.random.rand(n_obj)

            # run algorithms once with the randomly generated reference point
            _, pref_int_rvea = int_rvea.requests()
            _, pref_int_nsga = int_nsga.requests()
            pref_int_rvea.response = pd.DataFrame(
                [response],
                columns=pref_int_rvea.content["dimensions_data"].columns)
            pref_int_nsga.response = pd.DataFrame(
                [response],
from desdeo_problem.testproblems.TestProblems import test_problem_builder
from desdeo_emo.EAs.RVEA import RVEA
from desdeo_emo.EAs.NSGAIII import NSGAIII
from desdeo_emo.othertools.plotlyanimate import animate_init_, animate_next_


dtlz3 = test_problem_builder("DTLZ3", n_of_variables=12, n_of_objectives=11)
evolver = RVEA(dtlz3, n_iterations=10)
figure = animate_init_(evolver.population.objectives, filename="dtlz3.html")
while evolver.continue_evolution():
    evolver.iterate()
    figure = animate_next_(
        evolver.population.objectives,
        figure,
        filename="dtlz3.html",
        generation=evolver._iteration_counter,
    )
예제 #6
0

list_vars = variable_builder(["x", "y"],
                             initial_values=[0, 0],
                             lower_bounds=[0, 0],
                             upper_bounds=[np.pi, np.pi])

f1 = _ScalarObjective(name="f1", evaluator=f_1)
f2 = _ScalarObjective(name="f2", evaluator=f_2)

c1 = ScalarConstraint("c1", 2, 2, c_1)
c2 = ScalarConstraint("c2", 2, 2, c_2)

problem = MOProblem(variables=list_vars,
                    objectives=[f1, f2],
                    constraints=[c1, c2])

evolver = RVEA(problem)
"""
figure = animate_init_(evolver.population.objectives, filename="MOPC4.html")
"""
while evolver.continue_evolution():
    evolver.iterate()
    """figure = animate_next_(
        evolver.population.objectives,
        figure,
        filename="MOPC4.html",
        generation=evolver._iteration_counter,
    )
"""