From 46d01ce618c9301b25d890b217e952d0e0f74819 Mon Sep 17 00:00:00 2001 From: Bill Huang Date: Sat, 13 Apr 2024 22:18:16 +0800 Subject: [PATCH] dev: deprecate cpso_s in favor of the CC framework fix: import --- docs/source/api/algorithms/so/cpso_s.rst | 6 --- .../algorithms/so/pso_variants/__init__.py | 1 - src/evox/algorithms/so/pso_variants/cpso_s.py | 54 ------------------- 3 files changed, 61 deletions(-) delete mode 100644 docs/source/api/algorithms/so/cpso_s.rst delete mode 100644 src/evox/algorithms/so/pso_variants/cpso_s.py diff --git a/docs/source/api/algorithms/so/cpso_s.rst b/docs/source/api/algorithms/so/cpso_s.rst deleted file mode 100644 index f6d39eb1..00000000 --- a/docs/source/api/algorithms/so/cpso_s.rst +++ /dev/null @@ -1,6 +0,0 @@ -======= -CPSO_S -======= - -.. autoclass:: evox.algorithms.CPSOS - :members: diff --git a/src/evox/algorithms/so/pso_variants/__init__.py b/src/evox/algorithms/so/pso_variants/__init__.py index 48840622..757afc83 100644 --- a/src/evox/algorithms/so/pso_variants/__init__.py +++ b/src/evox/algorithms/so/pso_variants/__init__.py @@ -2,7 +2,6 @@ from .sl_pso_gs import SLPSOGS from .cso import CSO from .clpso import CLPSO -from .cpso_s import CPSOS from .dms_pso_el import DMSPSOEL from .fips import FIPS from .swmmpso import SwmmPSO diff --git a/src/evox/algorithms/so/pso_variants/cpso_s.py b/src/evox/algorithms/so/pso_variants/cpso_s.py deleted file mode 100644 index e62f27a9..00000000 --- a/src/evox/algorithms/so/pso_variants/cpso_s.py +++ /dev/null @@ -1,54 +0,0 @@ -# -------------------------------------------------------------------------------------- -# 1. This code implements algorithms described in the following papers: -# -# Title: A Cooperative approach to particle swarm optimization -# Link: https://ieeexplore.ieee.org/document/1304845 -# -------------------------------------------------------------------------------------- - -import jax -import jax.numpy as jnp - -from evox.utils import * -from evox import Algorithm, State, jit_class -from evox.algorithms.containers.coevolution import Coevolution -from evox.algorithms.so.pso_variants.pso import PSO - - -# CPSO-S: Cooperative PSO -@jit_class -class CPSOS(Coevolution): - """Cooperative particle swarm optimizer. - Implemented using EvoX's built-in coevolution framework. - CPSOS essentially a wrapper around PSO and Coevolution. - - https://ieeexplore.ieee.org/document/1304845 - """ - - def __init__( - self, - lb, # lower bound of problem - ub, # upper bound of problem - subpop_size: int, - inertia_weight: float, # w - cognitive_coefficient: float, # c_pbest - social_coefficient: float, # c_gbest - ): - assert jnp.all(lb[0] == lb) and jnp.all( - ub[0] == ub - ), "Currently the coevolution framewrok restricts that the upper/lower bound should be the same across dimensions" - pso = PSO( - lb[:1], - ub[:1], - subpop_size, - inertia_weight, - cognitive_coefficient, - social_coefficient, - ) - super().__init__( - base_algorithm=pso, - dim=lb.shape[0], - num_subpops=lb.shape[0], - subpop_size=subpop_size, - num_subpop_iter=1, - random_subpop=False, - )