Optimization Module
Pluggable optimisation framework for selecting the best encoding.
Provides a composable pipeline for encoding selection: users supply a
cost function (any PauliRegisterSequence → float) and a set of
encoding candidates. The framework evaluates each candidate and returns
the one that minimises cost, together with full comparison data.
Built-in cost functions cover the most common metrics: λ-norm (qubitization), total Pauli weight (Trotter CNOT cost), term count (measurement overhead), and maximum Pauli weight (circuit depth). Users can define custom cost functions (e.g., weighted combinations) and pass them directly.
The framework is intentionally strategy-agnostic: it evaluates whatever candidates you give it, so external optimisers (genetic algorithms, Bayesian optimisation, simulated annealing) can generate candidates and use this module for evaluation.
Types
| Type | Description |
|
A cost function maps an encoded Hamiltonian to a scalar to minimise. |
|
|
An encoding candidate: a named encoder function. |
|
|
Result of evaluating a single encoding candidate. |
|
|
Result of an optimisation run across multiple candidates. |
Functions and values
| Function or value |
Description
|
Full Usage:
combinedCost w1 f1 w2 f2 h
Parameters:
float
-
Weight for the first cost function.
f1 : CostFunction
-
First cost function.
w2 : float
-
Weight for the second cost function.
f2 : CostFunction
-
Second cost function.
h : PauliRegisterSequence
Returns: float
A combined cost function.
|
Combine two cost functions with weights: w₁·f₁ + w₂·f₂.
|
Full Usage:
evaluate costFn coefficientFactory n candidate
Parameters:
CostFunction
-
The cost function to evaluate.
coefficientFactory : string -> Complex option
-
Molecular integral lookup.
n : uint32
-
Number of spin-orbitals (qubits).
candidate : EncodingCandidate
-
The encoding candidate to evaluate.
Returns: EvaluationResult
An EvaluationResult with cost and Hamiltonian data.
|
Evaluate a single encoding candidate against a cost function.
|
Full Usage:
evaluateCustom costFn name encoder coefficientFactory n
Parameters:
CostFunction
-
The cost function to evaluate.
name : string
-
Display name for the encoding.
encoder : EncoderFn
-
The encoder function.
coefficientFactory : string -> Complex option
-
Molecular integral lookup.
n : uint32
-
Number of spin-orbitals (qubits).
Returns: EvaluationResult
An EvaluationResult.
|
Evaluate a custom encoder (e.g., from an external optimiser generating trees) without needing to construct a full EncodingCandidate.
|
|
LCU 1-norm: Σ|cₖ|. Minimising this minimises qubitization query complexity.
|
|
Maximum Pauli weight across all terms. Proxy for worst-case circuit depth per rotation.
|
Full Usage:
optimizeOver costFn candidates coefficientFactory n
Parameters:
CostFunction
-
The cost function to minimise.
candidates : EncodingCandidate[]
-
Array of encoding candidates to evaluate.
coefficientFactory : string -> Complex option
-
Molecular integral lookup.
n : uint32
-
Number of spin-orbitals (qubits).
Returns: OptimizationResult
An OptimizationResult with the best candidate and full comparison.
|
Evaluate all candidates and return the best (lowest cost).
|
Full Usage:
optimizeStandard costFn coefficientFactory n
Parameters:
CostFunction
-
The cost function to minimise.
coefficientFactory : string -> Complex option
-
Molecular integral lookup.
n : uint32
-
Number of spin-orbitals (qubits).
Returns: OptimizationResult
An OptimizationResult.
|
Optimise over all six standard encodings.
|
Full Usage:
standardEncodings n
Parameters:
uint32
-
Number of qubits / spin-orbitals.
Returns: EncodingCandidate[]
Array of encoding candidates.
|
The six standard encodings built into FockMap. For tree-based encodings (balanced binary, balanced ternary, Vlasov), the tree is rebuilt per call to the encoder function, matching the library's existing convention for these encodings.
|
|
Number of distinct Pauli terms. Proxy for measurement overhead in VQE.
|
|
Total Pauli weight: Σ weight(Pₖ). Proxy for total CNOT count in Trotter.
|
Full Usage:
trotterCnotCost dt h
Parameters:
float
-
Time step size for the Trotter decomposition.
h : PauliRegisterSequence
Returns: float
A cost function computing the CNOT count.
|
Actual first-order Trotter CNOT count at the given time step.
|