qiskit-documentation/docs/api/qiskit/0.29/qiskit.aqua.components.unce...

171 lines
9.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: UnivariatePiecewiseLinearObjective (v0.29)
description: API reference for qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective in qiskit v0.29
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective
---
# UnivariatePiecewiseLinearObjective
<Class id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective" isDedicatedPage={true} github="https://github.com/qiskit-community/qiskit-aqua/tree/stable/0.9/qiskit/aqua/components/uncertainty_problems/univariate_piecewise_linear_objective.py" signature="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)" modifiers="class">
Bases: `qiskit.aqua.utils.circuit_factory.CircuitFactory`
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`\[`List`\[`int`]]) indices of qubits that represent the state
* **i\_objective** (`Optional`\[`int`]) index of target qubit to apply the rotation to
## Methods
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build" />
### build
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build" signature="UnivariatePiecewiseLinearObjective.build(qc, q, q_ancillas=None, params=None)" />
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-controlled" />
### build\_controlled
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_controlled" signature="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*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) quantum circuit
* **q** (*list*) list of qubits (has to be same length as self.\_num\_qubits)
* **q\_control** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.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
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-controlled-inverse" />
### build\_controlled\_inverse
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_controlled_inverse" signature="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*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) quantum circuit
* **q** (*list*) list of qubits (has to be same length as self.\_num\_qubits)
* **q\_control** ([*Qubit*](qiskit.circuit.Qubit "qiskit.circuit.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
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-controlled-inverse-power" />
### build\_controlled\_inverse\_power
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_controlled_inverse_power" signature="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
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-controlled-power" />
### build\_controlled\_power
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_controlled_power" signature="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
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-inverse" />
### build\_inverse
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_inverse" signature="UnivariatePiecewiseLinearObjective.build_inverse(qc, q, q_ancillas=None)">
Adds inverse of corresponding sub-circuit to given circuit
**Parameters**
* **qc** ([*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.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)
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-inverse-power" />
### build\_inverse\_power
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_inverse_power" signature="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
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-build-power" />
### build\_power
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.build_power" signature="UnivariatePiecewiseLinearObjective.build_power(qc, q, power, q_ancillas=None)">
Adds power of corresponding circuit. May be overridden if a more efficient implementation is possible
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-get-num-qubits" />
### get\_num\_qubits
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.get_num_qubits" signature="UnivariatePiecewiseLinearObjective.get_num_qubits()">
returns number of qubits
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-get-num-qubits-controlled" />
### get\_num\_qubits\_controlled
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.get_num_qubits_controlled" signature="UnivariatePiecewiseLinearObjective.get_num_qubits_controlled()">
returns number of qubits controlled
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-required-ancillas" />
### required\_ancillas
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.required_ancillas" signature="UnivariatePiecewiseLinearObjective.required_ancillas()">
requires ancillas
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-required-ancillas-controlled" />
### required\_ancillas\_controlled
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.required_ancillas_controlled" signature="UnivariatePiecewiseLinearObjective.required_ancillas_controlled()">
returns required ancillas controlled
</Function>
<span id="qiskit-aqua-components-uncertainty-problems-univariatepiecewiselinearobjective-value-to-estimation" />
### value\_to\_estimation
<Function id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.value_to_estimation" signature="UnivariatePiecewiseLinearObjective.value_to_estimation(value)">
value to estimation
</Function>
## Attributes
### num\_target\_qubits
<Attribute id="qiskit.aqua.components.uncertainty_problems.UnivariatePiecewiseLinearObjective.num_target_qubits">
Returns the number of target qubits
</Attribute>
</Class>