Skip to main content

A genetic algorithm optimization based Uda-Yagi antenna generator,

Project description

genuy

A genetic algorithm-based Uda-Yagi antenna optimizer. Uses PyGAD as the GA engine and pymininec for antenna simulation to evolve element lengths and spacings that maximise gain, front-to-back ratio, and VSWR across a specified bandwidth.

Features

  • Optimizes reflector, driven element, and an arbitrary number of director elements
  • Evaluates fitness across the full bandwidth (low edge, centre, high edge) to avoid narrow-band solutions
  • Adaptive mutation and tournament selection for robust multimodal search
  • Parallel fitness evaluation using all available CPU cores
  • Exports the best solution as an MMANA-GAL .maa file

Requirements

Installation

pip install genuy

Or from source:

git clone https://github.com/r2axz/genuy
cd genuy
pip install .

Usage

genuy [OPTIONS]

Key options

Antenna parameters

Option Default Description
-n, --num-elements 4 Number of elements (reflector+driven+directors)
-f, --frequency 145.0 Centre frequency, MHz
-b, --bandwidth 10.0 Optimization bandwidth, MHz
-r, --element-radius 3.0 Element radius, mm
-z, --reference-impedance 50+0j Reference impedance for VSWR, Ω

GA and output parameters

Option Default Description
--num-generations 200 Maximum GA generations
--num-solutions 0 (auto: 10×genes) Population size
--percent-mating 10.0 % of population selected as parents
--mutation-percent-max 40.0 Max gene mutation % (adaptive)
--mutation-percent-min 20.0 Min gene mutation % (adaptive)
--vswr-punish-early (off) Return penalty on first bad-VSWR frequency
--seed (random) Random seed; printed so runs are reproducible
--save-maa (none) Save best solution as MMANA .maa file
--plot-fitness (off) Plot fitness vs. generation after run

Run genuy --help for the full option list.

Per-element constraints

Use --constrain-length and --constrain-spacing to narrow the search space for individual elements. Elements and spacings are numbered starting from 1. Both options are repeatable.

# Fix element 1 (reflector) length range tightly, leave others free
genuy -n 5 -f 145 -b 10 --constrain-length 1 0.51 0.53

# Constrain spacing between elements 2 and 3
genuy -n 5 -f 145 -b 10 --constrain-spacing 2 0.10 0.15

# Multiple constraints
genuy -n 5 -f 145 -b 10 \
  --constrain-length 1 0.51 0.53 \
  --constrain-length 2 0.47 0.49 \
  --constrain-spacing 1 0.12 0.18

Examples

Optimize a 4-element 145 MHz antenna and save the result:

genuy -n 4 -f 145 -b 10 --save-maa antenna.maa

Optimize a 6-element antenna, plot convergence, and save:

genuy -n 6 -f 145 -b 10 --num-generations 500 --save-maa 6el.maa --plot-fitness

Reproduce a previous run using a saved seed:

genuy -n 4 -f 145 -b 10 --seed 1234567890 --save-maa antenna.maa

Fitness function

Each candidate solution is evaluated at three frequencies — lower band edge, centre, and upper band edge. The fitness score is:

$$F = \begin{cases} \dfrac{w_\text{vswr}}{\text{VSWR}\text{worst}} + w\text{gain} \cdot G_\text{worst} + w_\text{fb} \cdot \text{FB}\text{worst} & \text{if } \text{VSWR}\text{worst} < \text{threshold} \ p_\text{vswr} + w_\text{gain} \cdot G_\text{worst} + w_\text{fb} \cdot \text{FB}_\text{worst} & \text{otherwise} \end{cases}$$

Default weights: vswr_weight=100, gain_weight=3.0, fb_weight=1.0, boom_length_weight=1.0. The hard VSWR penalty (high_vswr_penalty=-100) discourages solutions that are badly mismatched anywhere in the band.

Output

After the run the best solution is printed to stdout:

Best solution :  [0.512 0.18 0.474 0.15 0.452 0.19 0.438]
Best solution fitness :  47.23
VSWR :  1.34
Impedance :  (42.1+3.2j)
Gain :  10.8
Front-to-Back Ratio :  18.4

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genuy-0.1.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genuy-0.1.5-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file genuy-0.1.5.tar.gz.

File metadata

  • Download URL: genuy-0.1.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for genuy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 463e91e808f5c4c44c7ebc151d40ea09afe5f67352f32ea3bede49a990ee794f
MD5 a58b4c2343cbd6b04de73f92538973f4
BLAKE2b-256 a68a37b24b2edb045a8ad01364be0681a47429f114e3dc83d0bd34929a7fd5a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for genuy-0.1.5.tar.gz:

Publisher: publish.yml on r2axz/genuy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genuy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: genuy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for genuy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c657d0273b582035ed5c888b24ce833fa7856eba3a33c76591881c9e380147eb
MD5 7cf9795e658e3f619046c3089b6f0d1b
BLAKE2b-256 d494c899ebd829c51a39991a0cdbb3a005d3135eac15512f0693770971c8a2cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for genuy-0.1.5-py3-none-any.whl:

Publisher: publish.yml on r2axz/genuy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page