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

Commitadc1a11

Browse files
committed
readme update
1 parent1be4704 commitadc1a11

File tree

1 file changed

+141
-3
lines changed

1 file changed

+141
-3
lines changed

‎README.md‎

Lines changed: 141 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,142 @@
1-
#chicken_swarm_python
2-
an AntennaCAT compatable chicken swarm optimizer
1+
#chicknen_swarm_python
32

4-
PLACEHOLDER! 6/3/2024
3+
Basic chicken swarm optimizer written in Python. Modified from the[adaptive timestep PSO optimizer](https://github.com/jonathan46000/pso_python) by[jonathan46000](https://github.com/jonathan46000) to keep a consistent format across optimizers in AntennaCAT.
4+
5+
6+
7+
Now featuring AntennaCAT hooks for GUI integration and user input handling.
8+
9+
##Table of Contents
10+
*[Chicken Swarm Optimization](#chicken-swarm-optimization)
11+
*[Requirements](#requirements)
12+
*[Implementation](#implementation)
13+
*[Constraint Handling](#constraint-handling)
14+
*[Boundary Types](#boundary-types)
15+
*[Multi-Object Optimization](#multi-object-optimization)
16+
*[Objective Function Handling](#objective-function-handling)
17+
*[Internal Objective Function Example](internal-objective-function-example)
18+
*[Examples](#example-implementations)
19+
*[Basic PSO Example](#basic-pso-example)
20+
*[Detailed Messages](#detailed-messages)
21+
*[Realtime Graph](#realtime-graph)
22+
*[References](#references)
23+
*[Publications and Integration](#publications-and-integration)
24+
*[Licensing](#licensing)
25+
26+
##Chicken Swarm Optimization
27+
28+
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.
29+
30+
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:
31+
32+
1) Roosters:
33+
34+
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.
35+
36+
2) Hens:
37+
38+
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.
39+
40+
3) Chicks:
41+
42+
Chicks follow their mother hens. They update their positions based on their mother's positions with some random factor to simulate the dependent behavior.
43+
44+
##Requirements
45+
46+
This project requires numpy and matplotlib.
47+
48+
Use 'pip install -r requirements.txt' to install the following dependencies:
49+
50+
```python
51+
contourpy==1.2.1
52+
cycler==0.12.1
53+
fonttools==4.51.0
54+
importlib_resources==6.4.0
55+
kiwisolver==1.4.5
56+
matplotlib==3.8.4
57+
numpy==1.26.4
58+
packaging==24.0
59+
pillow==10.3.0
60+
pyparsing==3.1.2
61+
python-dateutil==2.9.0.post0
62+
six==1.16.0
63+
zipp==3.18.1
64+
65+
```
66+
67+
##Implementation
68+
###Constraint Handling
69+
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).
70+
71+
###Boundary Types
72+
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).
73+
74+
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.
75+
76+
###Multi-Object Optimization
77+
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.
78+
79+
###Objective Function Handling
80+
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.
81+
82+
####Internal Objective Function Example
83+
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.
84+
<palign="center">
85+
<img src="https://github.com/LC-Linkous/cat_swarm_python/blob/main/media/obj_func_pareto.png" alt="Function Feasable Decision Space and Objective Space with Pareto Front" height="200">
86+
</p>
87+
<palign="center">Function Feasable Decision Space and Objective Space with Pareto Front</p>
88+
89+
90+
```math
91+
\text{minimize}:
92+
\begin{cases}
93+
f_{1}(\mathbf{x}) = (x_1-0.5)^2 + (x_2-0.1)^2 \\
94+
f_{2}(\mathbf{x}) = (x_3-0.2)^4
95+
\end{cases}
96+
```
97+
98+
| Num. Input Variables| Boundary| Constraints|
99+
|----------|----------|----------|
100+
| 3| $0.21\leq x_1\leq 1$ <br> $0\leq x_2\leq 1$ <br> $0.1 \leq x_3\leq 0.5$| $x_3\gt \frac{x_1}{2}$ or $x_3\lt 0.1$|
101+
102+
103+
This function has three files:
104+
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
105+
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.
106+
3) func_F.py - contains a function with the objective function.
107+
108+
Other multi-objective functions can be applied to this project by following the same format (and several have been collected into a compatable library, and will be realeased in a seperate repo)
109+
110+
111+
112+
##Example Implementations
113+
114+
###Basic Swarm Example
115+
main_test.py provides a sample use case of the optimizer.
116+
117+
###Detailed Messages
118+
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.
119+
120+
###Realtime Graph
121+
122+
<palign="center">
123+
<img src="https://github.com/LC-Linkous/chicken_swarm_python/blob/main/media/chicken_swarm.gif" alt="Example Chicken Swarm Optimizer" height="200">
124+
</p>
125+
126+
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.
127+
128+
NOTE: if you close the graph as the code is running, the code will continue to run, but the graph will not re-open.
129+
130+
131+
##References
132+
133+
[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.
134+
135+
##Publications and Integration
136+
This software works as a stand-alone implementation, and as one of the optimizers integrated into AntennaCAT.
137+
138+
Publications featuring the code in this repo will be added as they become public.
139+
140+
##Licensing
141+
142+
The code in this repository has been released under GPL-2.0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp