Search for answers or browse our Knowledge Base.
Guides | Models | Validation | Blog
Building Effective Cost Functions for Antenna Optimization: Weighting, Normalization, and Trade-offs
Master cost function design for antenna optimization: weighting strategies, parameter normalization, and performance trade-offs. Practical methods to balance gain, VSWR, and impedance matching in your designs.

Introduction: The Heart of Antenna Optimization
An antenna optimizer is like a smart assistant that automatically tweaks your design—element lengths, spacings, or feed positions—to hit performance targets. But just like you’d give clear instructions to an assistant, the optimizer needs a cost function to know what “better” means.
Think of the cost function as your design wishlist in math form. Want lower VSWR? Higher gain? A specific front-to-back ratio? The cost function weights these goals and calculates a single “score” the optimizer tries to minimize. For example:
$\displaystyle \mathbf{ \text{cost} } \,=\, \mathbf{\text{80%}} \, \text{weight on VSWR error} \,+\, \mathbf{\text{50%}} \, \text{on gain error}$
Why customization matters:
- No one-size-fits-all: A Wi-Fi antenna prioritizes different goals than a satellite array.
- Trade-off control: Should the optimizer sacrifice 0.5 dB gain for a 10% better VSWR? Your weights decide.
- Problem adaptation: Start with rough targets, then refine weights as you zero in on a design.
For a hands-on example, see our guide Nelder-Mead Optimization for Antenna Design Using the AN-SOF Engine and Scilab, where we tune a Yagi-Uda antenna by weighting VSWR, gain, and front-to-back ratio.
Building a Target-Oriented Cost Function
When you need an antenna to hit a specific performance target—whether it’s gain, VSWR, or any other metric—the cost function acts as your measuring stick. Here’s how to construct it:
The Basic Formula
For a target gain ($G_0$), the simplest cost function calculates the normalized deviation from that ideal:
$\displaystyle \mathbf{ \text{cost} } \,=\, \frac{|\,G \,-\, G_0\,|}{G_0}$
This tells the optimizer, “Get as close as possible to $G_0$” by minimizing the percentage error.
Why Normalize?
- Fair comparisons: A 0.5 dB error matters more if $G_0$ is 5 dB than if it’s 15 dB.
- Unitless results: Works the same whether you’re optimizing gain (dB), VSWR (ratio), or efficiency (%).
Flexibility for Any Metric
The same template works for other parameters—just swap in your target:
$\displaystyle \mathbf{ \text{cost} } \,=\, \frac{|\,\text{VSWR} \,-\, \text{VSWR}_0\,|}{\text{VSWR}_0}$
$\displaystyle \mathbf{ \text{cost} } \,=\, \frac{|\,\text{F/B} \,-\, \text{F/B}_0\,|}{\text{F/B}_0}$
where $\text{VSWR}$ is the Voltage Standing Wave Ratio and $\text{F/B}$ is the front-to-back ratio.
When to Use Alternatives
- Squared errors (e.g., $(G-G_0)^2/G_0^2$):
- Use case: Punishes large deviations aggressively (good for strict specs).
- Asymmetric weights:
- Example: $\text{cost} = 2 \cdot (G-G_0)/G_0$ if $G < G_0$ (undershoot worse than overshoot).
Pro Tip
Start with the basic normalized error, then tweak if your design needs:
- Stricter tolerance? Try squared errors.
- One-sided specs? Adjust weights asymmetrically.
Designing a Cost Function for Maximum Gain
When your goal is pure performance—squeezing every last dB of gain out of your antenna—the cost function needs one job: reward higher gain. Here’s how to structure it:
The Straightforward Approach
The simplest way to maximize gain is to flip the sign:
$\displaystyle \mathbf{ \text{cost} } \,=\, -\alpha \cdot G$
where $\alpha > 0$ (e.g., $\alpha = 1$). Since optimizers minimize cost, the negative sign makes higher gain values “cost less.”
Why Exponential Works Better
For smoother convergence, use:
$\displaystyle \mathbf{ \text{cost} } \,=\, \exp(-\alpha \cdot G)$
Advantages:
- Natural scaling: Large gain improvements (critical near limits) get prioritized.
- Algorithm-friendly: Gentle curves help gradient/Nelder-Mead avoid oscillations.
Choosing α (Alpha)
- α = 0.5 to 2: Typical range for gain in dB scale.
- Tune it: Start with α = 1, then:
- Increase α if the optimizer settles for mediocre gains.
- Decrease α if it overshoots practical limits.
Real-World Tip
Pair this with constraints (e.g., VSWR < 2.0) in your optimizer to avoid unrealistic designs.
Creating a Cost Function for Minimum VSWR
When impedance matching is critical—like for transmitter feedpoints or wideband antennas—your cost function should ruthlessly punish high VSWR values. Here’s how to structure it:
The Direct Approach
The simplest way to minimize VSWR:
$\displaystyle \mathbf{ \text{cost} } \,=\, \beta \cdot \text{VSWR}$
where $\beta > 0$ (e.g., $\beta = 1$). Since optimizers drive cost downward:
- VSWR = 1.0 → cost = 1.0
- VSWR = 2.0 → cost = 2.0 (twice as “expensive”)
When to Get Aggressive
For designs where VSWR must stay ultra-low (e.g., satellite feeds), use:
$\displaystyle \mathbf{ \text{cost} } \,=\, \beta \cdot (\text{VSWR})^2 \quad$ (Quadratic penalty)
or:
$\displaystyle \mathbf{ \text{cost} } \,=\, \beta \cdot \exp(\text{VSWR}) \quad$ (Exponential penalty)
Why? These punish high VSWR disproportionately—ideal for “1.5 or bust” scenarios.
Tuning β (Beta)
- Start with β = 1 for linear scaling.
- Increase β if the optimizer tolerates marginal VSWR (e.g., 1.8 when you want < 1.5).
Pro Tip
Combine with a hard constraint (e.g., cost = ∞ if VSWR > 3.0) to avoid wasting time on unusable designs.
Cost Functions for Resonance and Impedance Matching
Achieving Antenna Resonance
Resonance occurs when the feedpoint reactance is zero ($X_{in} = 0$). To guide the optimizer toward resonance, use this normalized cost function:
$\displaystyle \mathbf{ \text{cost} } \,=\, \left| \frac{\text{imag}(Z_{in})}{Z_0} \right|$
where $Z_{in} = R_{in} + j X_{in}$ is the feedpoint impedance and $Z_0$ is a reference impedance.
Key Features:
- Targets only the imaginary part of $Z_{in}$ (reactance)
- Normalization ($Z_0 = 50 \, \Omega$) ensures consistent scaling across designs
- Zero cost when $X_{in} = 0$ (perfect resonance)
Implementation Tip:
For narrowband antennas, combine with a frequency sweep to ensure resonance at your operating frequency.
Complete Impedance Matching
For perfect matching to $Z_0$ (typically 50 Ω), both real and imaginary parts must be optimized:
$\displaystyle \mathbf{ \text{cost} } \,=\, \left| \frac{\text{real}(Z_{in}) \,-\, Z_0}{Z_0} \right| \,+\, \left| \frac{\text{imag}(Z_{in})}{Z_0} \right|$
Advantages:
- First term minimizes resistive mismatch
- Second term eliminates reactance
- Normalized for consistent behavior
Practical Considerations:
- For most designs, matching ($Z_{in}$ → 50 + j0 Ω) is preferred over pure resonance
- Add weighting ($w_1 + w_2 = 1$) if one aspect is more critical:
$\displaystyle \mathbf{ \text{cost} } \,=\, w_1 \cdot |\text{real}(Z_{in}) \,-\, 50| \,+\, w_2 \cdot |\text{imag}(Z_{in})|$
- For ultra-wideband designs, consider averaging across multiple frequencies
Weighting Strategies for Multi-Objective Optimization
When designing antennas, we often need to balance competing goals – like maximizing gain while minimizing VSWR. Here’s how to create effective weighted cost functions:
Basic Weighted Sum Approach
The simplest combined cost function:
$\displaystyle \mathbf{ \text{cost} } \,=\, -\alpha \cdot G \,+\, \beta \cdot \text{VSWR}$
- α > 0: Encourages higher gain (negative sign flips maximization to minimization)
- β > 0: Penalizes higher VSWR
- Tuning Tip: Start with α = β = 1, then:
- Increase β if VSWR is more critical
- Increase α if gain is the priority
Normalized Weighting (Recommended)
For better balance between parameters with different units/scales:
$\displaystyle \mathbf{ \text{cost} } \,=\, w_G \cdot \left(1 \,-\, \frac{G \,-\, G_{min}}{G_{max} \,-\, G_{min}}\right) \,+\, w_V \cdot \frac{\text{VSWR} \,-\, 1}{\text{VSWR}_{max} \,-\, 1}$
Where:
- Gain normalized to [0, 1] range ($G_{min}$ to $G_{max}$)
- VSWR normalized from 1 (ideal) to $\text{VSWR}_{max}$ (worst acceptable)
- Weights sum to 1 ($w_G + w_V = 1$) for consistent scaling
Example Applications:
- High-Gain Antenna: $w_G$ = 0.7, $w_V$ = 0.3 ($G_{min}$ = 5 dBi, $G_{max}$ = 12 dBi, $\text{VSWR}_{max}$ = 3)
- Matched Feedpoint: $w_G$ = 0.3, $w_V$ = 0.7 ($G_{min}$ = 3dBi, $G_{max}$ = 8 dBi, $\text{VSWR}_{max}$ = 2)
Target-Oriented Approach
When specific values are desired ($G_0$ and $\text{VSWR}_0$):
$\displaystyle \mathbf{ \text{cost} } \,=\, w_G \cdot \frac{|\,G \,-\, G_0\,|}{G_0} \,+\, w_V \cdot \frac{|\,\text{VSWR} \,-\, \text{VSWR}_0\,|}{\text{VSWR}_0}$
Advantages:
- Clearly defined “perfect” targets
- Normalized errors make weights more intuitive
- Easy to add more parameters (e.g., front-to-back ratio, efficiency)
Implementation Tips
- Start with equal weights, then adjust based on simulation results
- For constrained problems (e.g., VSWR < 2.0), use:
$\displaystyle \mathbf{ \text{cost} } \,=\, \text{base cost} \,+\, 1,000 \cdot \max(0, \text{VSWR} \,-\, 2.0)$
- Log important combinations to identify trade-off trends
Conclusions
Optimizing antenna performance requires carefully crafted cost functions that translate design goals into numerical targets. Whether maximizing gain, minimizing VSWR, achieving resonance, or balancing multiple objectives, the key lies in:
- Choosing the Right Formulation – Absolute errors for target values, negative weights for maximization, or exponential terms for aggressive scaling.
- Proper Normalization – Ensuring fair weighting between parameters with different units (e.g., dB vs. ratio).
- Strategic Weighting – Adjusting $\alpha$, $\beta$, or $w_1$, $w_2$ to prioritize critical specs while allowing trade-offs elsewhere.
The AN-SOF Engine, combined with Scilab scripting, provides a flexible framework to implement these cost functions efficiently. By logging iterations and visualizing convergence, you can refine weights and constraints to achieve optimal designs faster.
Final Tip:
Start simple (single objective), then gradually introduce complexity (multi-objective weights) as your design evolves.