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 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

UnivariatePiecewiseLinearObjective.num_target_qubits

Returns the number of target qubits

Methods

UnivariatePiecewiseLinearObjective.build(qc, q)

UnivariatePiecewiseLinearObjective.build_controlled(qc, …)

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.

UnivariatePiecewiseLinearObjective.build_inverse(qc, q)

Adds inverse of corresponding sub-circuit to given circuit

UnivariatePiecewiseLinearObjective.build_inverse_power(qc, …)

Adds inverse power of corresponding circuit.

UnivariatePiecewiseLinearObjective.build_power(qc, …)

Adds power of corresponding circuit.

UnivariatePiecewiseLinearObjective.get_num_qubits()

returns number of qubits

UnivariatePiecewiseLinearObjective.get_num_qubits_controlled()

returns number of qubits controlled

UnivariatePiecewiseLinearObjective.required_ancillas()

requires ancillas

UnivariatePiecewiseLinearObjective.required_ancillas_controlled()

returns required ancillas controlled

UnivariatePiecewiseLinearObjective.value_to_estimation(value)

value to estimation