PKU-DAIR / open-box

Generalized and Efficient Blackbox Optimization System
https://open-box.readthedocs.io
Other
356 stars 52 forks source link

Is PSO works for multi objective problems? #62

Closed chizro0 closed 1 year ago

chizro0 commented 1 year ago

Hi, I would like to solve a multiple objective optimization with PSO Algorithm. I found the OpenBox supports PSO, but not really sure if the algorithm works for multiple objective problems. I would be appreciated if you could let me know the answers. Thank you very much in advance.

jhj0411jhj commented 1 year ago

PSO algorithm works for MO problems. Please note that PSO in OpenBox is still under development, thus the performance is not stable and the interface might be changed in the future.

Here is an example of using PSOAdvisor:

import numpy as np
from openbox import space as sp, Observation
from openbox.core.pso.pso_advisor import PSOAdvisor

n_dim = 3
ref_point = [11.0, 11.0]

def zdt2(config):
    x = [config['x%d' % i] for i in range(n_dim)]
    f1 = x[0]
    g = 1 + 9 * sum(x[1:]) / (len(x) - 1)
    f2 = g * (1 - np.sqrt(f1 / g))
    return f1, f2

config_space = sp.Space()
for i in range(n_dim):
    xi = sp.Real('x%d' % i, 0, 1)
    config_space.add_hyperparameter(xi)

max_iter = 10
advisor = PSOAdvisor(config_space, num_objectives=2, population_size=30, max_iter=max_iter)
for i in range(max_iter):
    configs = advisor.get_suggestions()
    obs_list = []
    for config in configs:
        f1, f2 = zdt2(config)
        obs = Observation(config=config, objectives=[f1, f2])
        obs_list.append(obs)
    advisor.update_observations(obs_list)

history = advisor.get_history()
history.ref_point = ref_point
print(history)
history.visualize_html()
chizro0 commented 1 year ago

Thanks for the reply and example! I would like to know if there were source paper of the algorithm, is there any infomation?

jhj0411jhj commented 1 year ago

@chizro0 Here are some papers for PSO algorithm found on wikipedia: [1] Kennedy, James, and Russell Eberhart. "Particle swarm optimization." Proceedings of ICNN'95-international conference on neural networks. Vol. 4. IEEE, 1995. [2] Zhang, Yudong, Shuihua Wang, and Genlin Ji. "A comprehensive survey on particle swarm optimization algorithm and its applications." Mathematical problems in engineering 2015 (2015). [3] Bonyadi, Mohammad Reza, and Zbigniew Michalewicz. "Particle swarm optimization for single objective continuous space problems: a review." Evolutionary computation 25.1 (2017): 1-54. [4] Parsopoulos, Konstantinos E., and Michael N. Vrahatis. "Particle swarm optimization method in multiobjective problems." Proceedings of the 2002 ACM symposium on Applied computing. 2002. [5] Coello, CA Coello, and Maximino Salazar Lechuga. "MOPSO: A proposal for multiple objective particle swarm optimization." Proceedings of the 2002 Congress on Evolutionary Computation. CEC'02 (Cat. No. 02TH8600). Vol. 2. IEEE, 2002.

chizro0 commented 1 year ago

@jhj0411jhj I will read these papers, thanks a lot for the detailed information!