Cost functions
De Seitn is no ned ibersetzt worn. Sie schaung de englische Originalversion o.
During this lesson, we'll learn how to evaluate a cost function:
- First, we'll learn about Qiskit Runtime primitives
- Define a cost function . This is a problem-specific function that defines the problem's goal for the optimizer to minimize (or maximize)
- Defining a measurement strategy with the Qiskit Runtime primitives to optimize speed versus accuracy
Primitives
All physical systems, whether classical or quantum, can exist in different states. For example, a car on a road can have a certain mass, position, speed, or acceleration that characterize its state. Similarly, quantum systems can also have different configurations or states, but they differ from classical systems in how we deal with measurements and state evolution. This leads to unique properties such as superposition and entanglement that are exclusive to quantum mechanics. Just like we can describe a car's state using physical properties like speed or acceleration, we can also describe the state of a quantum system using observables, which are mathematical objects.
In quantum mechanics, states are represented by normalized complex column vectors, or kets (), and observables are Hermitian linear operators () that act on the kets. An eigenvector () of an observable is known as an eigenstate. Measuring an observable for one of its eigenstates () will give us the corresponding eigenvalue () as readout.
If you're wondering how to measure a quantum system and what you can measure, Qiskit offers two primitives that can help:
Sampler: Given a quantum state , this primitive obtains the probability of each possible computational basis state.Estimator: Given a quantum observable and a state , this primitive computes the expected value of .
The Sampler primitive
The Sampler primitive calculates the probability of obtaining each possible state