UnivariatePiecewiseLinearObjective¶
- class UnivariatePiecewiseLinearObjective(num_state_qubits, min_state_value, max_state_value, breakpoints, slopes, offsets, f_min, f_max, c_approx, i_state=None, i_objective=None)[source]¶
Univariate Piecewise Linear Objective Function.
This objective function applies controlled Y-rotation to the target qubit, where the control qubits represent integer value, and rotation approximates a piecewise linear function of the amplitude f:
\[|x\rangle |0\rangle \mapsto |x\rangle (\sqrt(1 - f(x))|0\rangle + sqrt(f(x))|1\rangle )\]- Parameters
num_state_qubits (
int
) – number of qubits to represent the statemin_state_value (
float
) – lower bound of values to be represented by state qubitsmax_state_value (
float
) – upper bound of values to be represented by state qubitsbreakpoints (
Union
[List
[float
],ndarray
]) – breakpoints of piecewise linear functionslopes (
Union
[List
[float
],ndarray
]) – slopes of linear segmentsoffsets (
Union
[List
[float
],ndarray
]) – offset of linear segmentsf_min (
float
) – minimal value of resulting function (required for normalization of amplitude)f_max (
float
) – maximal value of resulting function (required for normalization of amplitude)c_approx (
float
) – approximating factor (linear segments are approximated by contracting rotation around pi/4, where sin^2() is locally linear)i_state (
Optional
[int
]) – indices of qubits that represent the statei_objective (
Optional
[int
]) – index of target qubit to apply the rotation to
Attributes
Returns the number of target qubits
Methods
Adds corresponding controlled sub-circuit to given circuit
UnivariatePiecewiseLinearObjective.build_controlled_inverse
(qc, …)Adds controlled inverse of corresponding sub-circuit to given circuit
UnivariatePiecewiseLinearObjective.build_controlled_inverse_power
(qc, …)Adds controlled, inverse, power of corresponding circuit.
UnivariatePiecewiseLinearObjective.build_controlled_power
(qc, …)Adds controlled power of corresponding circuit.
Adds inverse of corresponding sub-circuit to given circuit
UnivariatePiecewiseLinearObjective.build_inverse_power
(qc, …)Adds inverse power of corresponding circuit.
Adds power of corresponding circuit.
returns number of qubits
UnivariatePiecewiseLinearObjective.get_num_qubits_controlled
()returns number of qubits controlled
requires ancillas
UnivariatePiecewiseLinearObjective.required_ancillas_controlled
()returns required ancillas controlled
UnivariatePiecewiseLinearObjective.value_to_estimation
(value)value to estimation