Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

an AntennaCAT compatible chicken swarm optimizer. Includes branches for a traditional chicken swarm, improved chicken swarm, and a 'quantum' inspired movement model for chicken swarm

License

NotificationsYou must be signed in to change notification settings

LC-Linkous/chicken_swarm_python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic chicken swarm optimizer written in Python. Modified from theadaptive timestep PSO optimizer byjonathan46000 to keep a consistent format across optimizers in AntennaCAT.

Now featuring AntennaCAT hooks for GUI integration and user input handling.

Table of Contents

Chicken Swarm Optimization

The Chicken Swarm Optimization (CSO) algorithm, introduced by Meng et al. in 2014 [1], is inspired by the hierarchy and behaviors observed in a swarm of chickens, including roosters, hens, and chicks. Each type of bird has its own unique movement rules and interactions.

In CSO, there is an absence of a direct random velocity component, which is an important distinction from many PSO variations, though it is not the only variation without a velocity vector. Instead, the movements are based on specific behaviors and social interactions within the swarm. Generally, the movement rules for each type of bird in CSO can be described as:

  1. Roosters:

    Roosters have the best positions (fitness values) in the swarm. They move based on their current position and the random perturbation to avoid getting stuck in local optima.

  2. Hens:

    Hens follow roosters. They update their positions based on the positions of the roosters they follow and a randomly selected chicken. This reflects the social hierarchy and interaction in the swarm.

  3. Chicks:

    Chicks follow their mother hens. They update their positions based on their mother's positions with some random factor to simulate the dependent behavior.

Requirements

This project requires numpy and matplotlib.

Use 'pip install -r requirements.txt' to install the following dependencies:

contourpy==1.2.1cycler==0.12.1fonttools==4.51.0importlib_resources==6.4.0kiwisolver==1.4.5matplotlib==3.8.4numpy==1.26.4packaging==24.0pillow==10.3.0pyparsing==3.1.2python-dateutil==2.9.0.post0six==1.16.0zipp==3.18.1

Implementation

Constraint Handling

Users must create their own constraint function for their problems, if there are constraints beyond the problem bounds. This is then passed into the constructor. If the default constraint function is used, it always returns true (which means there are no constraints).

Boundary Types

This optimizers has 4 different types of bounds, Random (Particles that leave the area respawn), Reflection (Particles that hit the bounds reflect), Absorb (Particles that hit the bounds lose velocity in that direction), Invisible (Out of bound particles are no longer evaluated).

Some updates have not incorporated appropriate handling for all boundary conditions. This bug is known and is being worked on. The most consistent boundary type at the moment is Random. If constraints are violated, but bounds are not, currently random bound rules are used to deal with this problem.

Multi-Object Optimization

The no preference method of multi-objective optimization, but a Pareto Front is not calculated. Instead the best choice (smallest norm of output vectors) is listed as the output.

Objective Function Handling

The optimizer minimizes the absolute value of the difference from the target outputs and the evaluated outputs. Future versions may include options for function minimization absent target values.

Internal Objective Function Example

The current internal optimization function takes 3 inputs, and has 2 outputs. It was created as a simple 3-variable optimization objective function that would be quick to converge.

Function Feasible Decision Space and Objective Space with Pareto Front

Function Feasible Decision Space and Objective Space with Pareto Front

$$\text{minimize}: \begin{cases}f_{1}(\mathbf{x}) = (x_1-0.5)^2 + (x_2-0.1)^2 \\\f_{2}(\mathbf{x}) = (x_3-0.2)^4\end{cases}$$
Num. Input VariablesBoundaryConstraints
3$0.21\leq x_1\leq 1$
$0\leq x_2\leq 1$
$0.1 \leq x_3\leq 0.5$
$x_3\gt \frac{x_1}{2}$ or$x_3\lt 0.1$

This function has three files:

  1. configs_F.py - contains imports for the objective function and constraints, CONSTANT assignments for functions and labeling, boundary ranges, the number of input variables, the number of output values, and the target values for the output
  2. constr_F.py - contains a function with the problem constraints, both for the function and for error handling in the case of under/overflow.
  3. func_F.py - contains a function with the objective function.

Other multi-objective functions can be applied to this project by following the same format (and several have been collected into a compatible library, and will be released in a separate repo)

Example Implementations

Basic Swarm Example

main_test.py provides a sample use case of the optimizer.

Detailed Messages

main_test_details.py provides an example using a parent class, and the self.suppress_output and detailedWarnings flags to control error messages that are passed back to the parent class to be printed with a timestamp. This implementation sets up the hooks for integration with AntennaCAT in order to provide the user feedback of warnings and errors.

Realtime Graph

Example Chicken Swarm Optimizer

main_test_graph.py provides an example using a parent class, and the self.suppress_output and detailedWarnings flags to control error messages that are passed back to the parent class to be printed with a timestamp. Additionally, a realtime graph shows particle locations at every step.

NOTE: if you close the graph as the code is running, the code will continue to run, but the graph will not re-open.

References

[1] X. B. Meng, Y. Liu, X. Gao, and H. Zhang, "A new bio-inspired algorithm: Chicken swarm optimization," in Proc. Int. Conf. Swarm Intell. Cham, Switzerland, Springer, 2014, pp. 86–94.

Publications and Integration

This software works as a stand-alone implementation, and as one of the optimizers integrated into AntennaCAT.

Publications featuring the code in this repo will be added as they become public.

Licensing

The code in this repository has been released under GPL-2.0

About

an AntennaCAT compatible chicken swarm optimizer. Includes branches for a traditional chicken swarm, improved chicken swarm, and a 'quantum' inspired movement model for chicken swarm

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp