<jupyter_start><jupyter_text>Import whale optimization algorithm<jupyter_code>from woa import WOA
import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Visualize Search Space ![image-2.png](attachment:image-2.png)  Define Obj Function<jupyter_code># minimum solution : (1, 1)
def f(X):
    a, b = 1, 100
    sol = []
    for x in X:
        sol.append(((a - x[0]) ** 2) + b*(x[1]-x[0]**2)**2)
    return np.array(sol)<jupyter_output><empty_output><jupyter_text>Define Variable Boundary<jupyter_code>x_lb = y_lb = -5
x_ub = y_ub = 5

lb = np.array([x_lb, y_lb])
ub = np.array([x_ub, y_ub])<jupyter_output><empty_output><jupyter_text>Optimize<jupyter_code>woa = WOA(f, 100, 0.5, 100, lb, ub)
%time f_values, optimal_x = woa.run()

plt.plot(f_values)
plt.title(f"Optimal X : {optimal_x}")<jupyter_output>Wall time: 53.9 ms
{'fraction_non_alphanumeric': 0.1548311990686845, 'fraction_numerical': 0.03143189755529686, 'mean_word_length': 5.515151515151516, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '370297', 'license': 'MIT', 'n_tokens_mistral': 392, 'n_tokens_neox': 364, 'n_words': 72, 'path': '[Banana] Whale Optimization Algorithm.ipynb', 'repo_name': 'hobinkwak/Whale-Optimization-Algorithm-python', 'size': '859'}