fird

fird is an open-source toolbox for optimizing FIR and Farrow filters with continuous or fixed-point coefficients. It supports linear and quadratic optimization, including mixed-integer designs.

The key thing to note is that fird clearly separates Objective and Constraint. Constraints specify requirements, while the objective describes what to optimize. For example, minimize implementation complexity subject to a frequency-response specification, or minimize approximation error for a given implementation complexity. Check solver termination before using a solution. In many papers, these two things are mixed up, where statements like the following (made up, but you hopefully get the idea) make things very arbitrary:

their method reaches -80 dB with 40 multipliers, but our much better method reaches -70 dB with only 30 multipliers

With fird, you must decide: do you want to minimize the error with 40 multipliers, or do you want to minimize the number of multipliers with a -70 dB error? Optimality and feasibility are assessed for the specified model, within solver tolerances. Sampled response specifications apply at the supplied design points. And nothing prohibits you from trying both approaches and any intermediate ones and comparing the results.

There are constraints and objectives for both frequency-response specifications and implementation complexity. You can combine constraints of different types, for example maximizing stopband attenuation while bounding passband ripple and coefficient complexity.

Features

Supported features

  • Linear-phase FIR filters with symmetric or antisymmetric coefficients.

  • Weighted minimax objectives and response bounds specified by samples, functions, or piecewise linear specifications.

  • Least-squares FIR design with analytically integrated W * error**2 objectives, including linearly interpolated targets and weights; see QuadraticObjective.

  • Continuous coefficients or direct optimization on a fixed-point coefficient grid with a specified number of fractional bits.

  • Coefficient gain scaling while keeping frequency specifications normalized to a unity-gain response.

  • Coefficient bounds, fixed coefficient values, L1 coefficient norms, and nonzero coefficient-count objectives and constraints.

  • Coefficient bounders that minimize and maximize each FIR or Farrow coefficient under the supplied constraints and export reusable bound constraints.

  • Nyquist coefficient constraints for interpolation filters.

  • Design of one stage of a multistage filter using the known cascade response for supported frequency specifications.

  • Plotting of FIR frequency objectives and constraints in Matplotlib figures.

  • Export of fixed-point FIR coefficients as NumPy arrays or APyTypes fixed-point arrays.

  • Joint Farrow filter design with different subfilter lengths, integer tap offsets, optional symmetry, and per-branch fractional-bit precision, including mixed continuous and fixed-point branches.

  • Farrow specifications with complex desired responses and weights varying over a frequency-delay grid. Peak-error bounds use convex quadratic constraints or a conservative linear polygon approximation.

  • Farrow objectives for peak complex error, sampled weighted least squares, analytically integrated stopband energy, L1 coefficient norm, and nonzero tap count.

  • Exact Farrow DC-gain constraints valid for every delay, together with branch-specific coefficient bounds, fixed taps, and complexity limits.

  • Automatic HiGHS/SCIP selection through Pyomo, with explicit solver selection and access to solver settings.

Response bounds based on samples must be checked between design points when continuous-frequency or continuous-delay guarantees are required. FIR sparsity controls count independent coefficients; Farrow tap counts include symmetric copies. These measures are not universal counts of hardware multipliers. Analytic quadratic FIR objectives support only constant-magnitude cascades; general cascade responses remain available for the supported sampled FIR specifications.

Not yet supported

  • Complex-valued coefficient vectors. Farrow desired frequency responses may be complex, but the optimized coefficients are real.

  • Joint optimization of multiple cascaded filter stages.

  • Automatic minimization of FIR order or Farrow subfilter lengths.

  • Coefficient sets restricted to powers of two or signed-digit representations.

  • General nonzero-target analytic frequency-delay error integrals for Farrow filters; the analytic Farrow integral objective currently targets zero stopband response.

Outside the current scope

  • A dedicated multi-objective optimization interface. Use hard constraints to express requirements and optimize one objective; open an issue to discuss use cases requiring multiple objectives.

  • IIR filter design, including stability and implementation-structure choices.

Choosing an optimization solver

fird uses Pyomo to formulate optimization models. The solver must support the objective, constraints, and variable types in the model. HiGHS and SCIP are installed with fird and selected automatically when no solver is supplied:

Solver choices for fird models

Problem class

Typical design

Default

Other suitable solvers

LP / MILP

Sampled minimax or coefficient-complexity design with linear constraints

HiGHS

SCIP, CBC, GLPK, Gurobi, CPLEX

QP

Least-squares objective, continuous variables, linear constraints

HiGHS

SCIP, Gurobi, CPLEX

MIQP

Least-squares objective with fixed-point coefficients or binary sparsity indicators

SCIP

Gurobi, CPLEX

QCQP / MIQCP

Quadratic Farrow error bounds, with continuous or integer variables

SCIP

Gurobi, CPLEX

LP denotes linear programming; QP has a quadratic objective and linear constraints. QCQP additionally allows quadratic constraints. The mixed-integer variants are MILP, MIQP, and MIQCP. Both fixed-point coefficient grids and binary sparsity indicators introduce integer variables, so real-valued coefficients alone do not guarantee a continuous model.

HiGHS supports LP, MILP, and continuous convex QP, but not MIQP or quadratic constraints. Use the highs Pyomo interface for QP rather than appsi_highs. CBC and GLPK are options for LP/MILP models, not the quadratic models above. For MIQP or quadratic constraints, use a capable solver such as SCIP, Gurobi, or CPLEX.

Farrow minimax design uses convex quadratic constraints by default, including when all coefficients are continuous. Its method="linear" option instead uses a conservative polygon approximation, giving an LP or MILP when the other constraints are linear; those models can use HiGHS.

The automatic solver names are highs and scip_direct. The latter uses SCIP through PySCIPOpt; the name scip instead requires a separate SCIP executable. Pass a compatible solver name to designer.solve(...) to override automatic selection, or supply a configured solver instance, for example:

import pyomo.environ as pyo

solver = pyo.SolverFactory("scip_direct")
solver.options["limits/time"] = 60
solver.options["display/verblevel"] = 0
results = designer.solve(solver)
pyo.assert_optimal_termination(results)

For HiGHS, the corresponding time-limit option is time_limit. Always check termination before reading coefficients: a time-limited solve may have an incumbent without proving optimality. Solver tolerances, coefficient scaling, and ill-conditioned quadratic forms can affect numerical accuracy.

Alternative solvers require their own installation and, where applicable, a license. See Pyomo’s solver installation guide. See Solver Benchmarks for measured FIR and Farrow comparisons, model definitions, and timing methodology. Solver speed depends on the specification, precision, and sparsity requirements; the benchmark page records unsupported models and time limits separately from successful solve times.

References

A good reference for FIR filter design using linear programming is:

Most of the things possible in METEOR are currently possible in fird. As well as things not possible with METEOR.

Overview