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)
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:
Parameters
- num_state_qubits (
int
) – number of qubits to represent the state - min_state_value (
float
) – lower bound of values to be represented by state qubits - max_state_value (
float
) – upper bound of values to be represented by state qubits - breakpoints (
Union
[List
[float
],ndarray
]) – breakpoints of piecewise linear function - slopes (
Union
[List
[float
],ndarray
]) – slopes of linear segments - offsets (
Union
[List
[float
],ndarray
]) – offset of linear segments - f_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 state - i_objective (
Optional
[int
]) – index of target qubit to apply the rotation to
Attributes
num_target_qubits
Returns the number of target qubits
Methods
build
UnivariatePiecewiseLinearObjective.build(qc, q, q_ancillas=None, params=None)
build_controlled
UnivariatePiecewiseLinearObjective.build_controlled(qc, q, q_control, q_ancillas=None, use_basis_gates=True)
Adds corresponding controlled sub-circuit to given circuit
Parameters
- qc (QuantumCircuit) – quantum circuit
- q (list) – list of qubits (has to be same length as self._num_qubits)
- q_control (Qubit) – control qubit
- q_ancillas (list) – list of ancilla qubits (or None if none needed)
- use_basis_gates (bool) – use basis gates for expansion of controlled circuit
build_controlled_inverse
UnivariatePiecewiseLinearObjective.build_controlled_inverse(qc, q, q_control, q_ancillas=None, use_basis_gates=True)
Adds controlled inverse of corresponding sub-circuit to given circuit
Parameters
- qc (QuantumCircuit) – quantum circuit
- q (list) – list of qubits (has to be same length as self._num_qubits)
- q_control (Qubit) – control qubit
- q_ancillas (list) – list of ancilla qubits (or None if none needed)
- use_basis_gates (bool) – use basis gates for expansion of controlled circuit
build_controlled_inverse_power
UnivariatePiecewiseLinearObjective.build_controlled_inverse_power(qc, q, q_control, power, q_ancillas=None, use_basis_gates=True)
Adds controlled, inverse, power of corresponding circuit. May be overridden if a more efficient implementation is possible
build_controlled_power
UnivariatePiecewiseLinearObjective.build_controlled_power(qc, q, q_control, power, q_ancillas=None, use_basis_gates=True)
Adds controlled power of corresponding circuit. May be overridden if a more efficient implementation is possible
build_inverse
UnivariatePiecewiseLinearObjective.build_inverse(qc, q, q_ancillas=None)
Adds inverse of corresponding sub-circuit to given circuit
Parameters
- qc (QuantumCircuit) – quantum circuit
- q (list) – list of qubits (has to be same length as self._num_qubits)
- q_ancillas (list) – list of ancilla qubits (or None if none needed)
build_inverse_power
UnivariatePiecewiseLinearObjective.build_inverse_power(qc, q, power, q_ancillas=None)
Adds inverse power of corresponding circuit. May be overridden if a more efficient implementation is possible
build_power
UnivariatePiecewiseLinearObjective.build_power(qc, q, power, q_ancillas=None)
Adds power of corresponding circuit. May be overridden if a more efficient implementation is possible
get_num_qubits
UnivariatePiecewiseLinearObjective.get_num_qubits()
returns number of qubits
get_num_qubits_controlled
UnivariatePiecewiseLinearObjective.get_num_qubits_controlled()
returns number of qubits controlled
required_ancillas
UnivariatePiecewiseLinearObjective.required_ancillas()
requires ancillas
required_ancillas_controlled
UnivariatePiecewiseLinearObjective.required_ancillas_controlled()
returns required ancillas controlled
value_to_estimation
UnivariatePiecewiseLinearObjective.value_to_estimation(value)
value to estimation