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.6.tar.gz (8.2 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.6-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: genuy-0.1.6.tar.gz
  • Upload date:
  • Size: 8.2 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.6.tar.gz
Algorithm Hash digest
SHA256 70cd9a95b021e616f7827acbc824720a0034c8329f3953ca94608b7c16f1b0a8
MD5 4d4745d79eed21659a9b36ca81c7e23e
BLAKE2b-256 bafc2c1eb0356fd4d9864cb627591b3872325c4020d1ba3b9e91262fe832a85a

See more details on using hashes here.

Provenance

The following attestation bundles were made for genuy-0.1.6.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.6-py3-none-any.whl.

File metadata

  • Download URL: genuy-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6d7d81e1cca235ea546c499f79a8799e117983ec04aa0c36ba307bc0652c03ea
MD5 432612cad472c5a4e77e46e48ab49536
BLAKE2b-256 8c7938e8feb5af3a7b9378ebad3389252f869ffac35e64ad3e72964c90dc1f1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for genuy-0.1.6-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