Skip to content

Add Anarchic Society Optimization (ASO) algorithm#762

Open
marryzhuuu wants to merge 10 commits into
NiaOrg:masterfrom
marryzhuuu:feature/aso-algorithm
Open

Add Anarchic Society Optimization (ASO) algorithm#762
marryzhuuu wants to merge 10 commits into
NiaOrg:masterfrom
marryzhuuu:feature/aso-algorithm

Conversation

@marryzhuuu

Copy link
Copy Markdown

Port ASO from NiaPy 1.x to 2.x API:

  • Add init method with proper parameter initialization
  • Fix in-place mutation bug in MP_C, MP_S, MP_P strategies
  • Fix euclidean distance used on scalar fitness values in EI and II indices
  • Rename methods to snake_case per new API conventions
  • Add elitism, sequential and crossover combination strategies
  • Add tests for all three strategies

Summary

Port ASO algorithm from NiaPy 1.x to 2.x API.

Bugs fixed:

  • In-place mutation bug in MP_C, MP_S, MP_P strategies (old code modified original array, making comparison unfair)
  • euclidean distance incorrectly used on scalar fitness values in EI and II indices

Other changes:

  • Add init with proper parameter initialization
  • Rename methods to snake_case per new API conventions
  • Add elitism, sequential and crossover combination strategies
  • Add tests for all three strategies

Port ASO from NiaPy 1.x to 2.x API:
- Add init method with proper parameter initialization
- Fix in-place mutation bug in MP_C, MP_S, MP_P strategies
- Fix euclidean distance used on scalar fitness values in EI and II indices
- Rename methods to snake_case per new API conventions
- Add elitism, sequential and crossover combination strategies
- Add tests for all three strategies
@firefly-cpp firefly-cpp added the enhancement New feature or request label May 26, 2026
@firefly-cpp

Copy link
Copy Markdown
Contributor

@marryzhuuu, please review this PR - unit tests are failing.

scipy is not a dependency of NiaPy, which caused
ModuleNotFoundError on CI. Replaced scipy.spatial.distance.euclidean
with a small numpy-based implementation.
- run_iteration now matches base Algorithm.run_iteration signature
  (5 explicit params + **params), unpacking ASO-specific state from params dict
- init now forwards **kwargs to set_parameters so extra
  keyword arguments are not silently dropped
set_parameters and init now correctly forward *args before
keyword arguments when calling super(), matching the base
Algorithm class signature (population_size, *args, **kwargs).
@firefly-cpp

Copy link
Copy Markdown
Contributor

Thanks, @marryzhuuu! PR is now ready. However, can you please confirm that the results provided by the Niapy implementation are consistent with the original publications?

@marryzhuuu

Copy link
Copy Markdown
Author

Hi @firefly-cpp, thanks for the review!

I checked the formulas against the original paper (Ahmadi-Javid, 2011, "Anarchic Society Optimization: A human-inspired method", IEEE CEC 2011).

The Fickleness Index (FI) formula matches the paper exactly (Eq. 1-2 in the general framework):
FI = 1 - alpha*(f_best/f_current) - (1-alpha)*(f_personal/f_current)

For the External Irregularity Index (EI) and Internal Irregularity Index (II), it's worth noting that the original paper presents ASO as a general framework rather than a single fixed algorithm. The paper explicitly offers two alternative formulations for EI (comparison with G-best, Eq. 3, or a society-wide dispersion measure, Eq. 4), and states that II "can be used in the scenarios presented for EI" without giving one fixed closed-form formula. The implementation here uses a neighbor-based variant consistent with the framework's intent (exponential decay based on fitness difference), which is one of the valid concretizations the paper allows for, since the paper leaves the exact choice of comparison basis and dispersion measure to the implementer for each specific problem.

This was verified through:

  1. Line-by-line comparison with the original paper's equations.
  2. A numerical experiment confirming the algorithm converges correctly on standard benchmark functions (Sphere, Griewank, Rastrigin), with convergence curves showing proper minimization behavior across all three combination strategies (elitism, sequential, crossover).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants