<jupyter_start><jupyter_text>The River Pollution Problem<jupyter_code>from desdeo_emo.EAs.RVEA import RVEA
from desdeo_problem import variable_builder, ScalarObjective, VectorObjective, MOProblem

import numpy as np
import pandas as pd
from desdeo_emo.utilities.plotlyanimate import animate_init_, animate_next_
# create the problem
def f_1(x):
    return 4.07 + 2.27 * x[:, 0]

def f_2(x):
    return 2.60 + 0.03*x[:, 0] + 0.02*x[:, 1] + 0.01 / (1.39 - x[:, 0]**2) + 0.30 / (1.39 - x[:, 1]**2)

def f_3(x):
    return 8.21 - 0.71 / (1.09 - x[:, 0]**2)

def f_4(x):
    return 0.96 - 0.96 / (1.09 - x[:, 1]**2)

# def f_5(x):
    # return -0.96 + 0.96 / (1.09 - x[:, 1]**2)

def f_5(x):
    return np.max([np.abs(x[:, 0] - 0.65), np.abs(x[:, 1] - 0.65)], axis=0)
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, maximize=True)
f5 = ScalarObjective(name="f5", evaluator=f_5, maximize=False)
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=5, n_gen_per_iter=100)
figure = animate_init_(evolver.population.objectives, filename="river.html")
pref, plot = evolver.start()
print(plot.content["dimensions_data"])
print(pref[0].content['message'])
pref[2].response = pd.DataFrame([[6.3,3.3,7,-2,0.3]],
                             columns=pref[2].content['dimensions_data'].columns)
pref, plot = evolver.iterate(pref[2])
figure = animate_next_(
    plot.content['data'].values,
    figure,
    filename="river.html",
    generation=evolver._iteration_counter,
)

message = (f"Current generation number:{evolver._current_gen_count}. "
           f"Is looping back recommended: {'Yes' if evolver.continue_evolution() else 'No'}")
print(message)<jupyter_output>Current generation number:400. Is looping back recommended: Yes
{'fraction_non_alphanumeric': 0.17436380772855797, 'fraction_numerical': 0.06361922714420358, 'mean_word_length': 4.3075, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '507606', 'license': 'MIT', 'n_tokens_mistral': 891, 'n_tokens_neox': 826, 'n_words': 169, 'path': 'docs/notebooks/River_Pollution.ipynb', 'repo_name': 'ppouyaa/desdeo-emo', 'size': '2122'}