Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Quantum Computing Experimentation with Amazon Braket

You're reading from   Quantum Computing Experimentation with Amazon Braket Explore Amazon Braket quantum computing to solve combinatorial optimization problems

Arrow left icon
Product type Paperback
Published in Jul 2022
Publisher Packt
ISBN-13 9781800565265
Length 420 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Alex Khan Alex Khan
Author Profile Icon Alex Khan
Alex Khan
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Introduction
2. Section 1: Getting Started with Amazon Braket FREE CHAPTER
3. Chapter 1: Setting Up Amazon Braket 4. Chapter 2: Braket Devices Explained 5. Chapter 3: User Setup, Tasks, and Understanding Device Costs 6. Chapter 4: Writing Your First Amazon Braket Code Sample 7. Section 2: Building Blocks for Real-World Use Cases
8. Chapter 5: Using a Quantum Annealer – Developing a QUBO Function and Applying Constraints 9. Chapter 6: Using Gate-Based Quantum Computers – Qubits and Quantum Circuits 10. Chapter 7: Using Gate Quantum Computers – Basic Quantum Algorithms 11. Chapter 8: Using Hybrid Algorithms – Optimization Using Gate-Based Quantum Computers 12. Chapter 9: Running QAOA on Simulators and Amazon Braket Devices 13. Section 3: Real-World Use Cases
14. Chapter 10: Amazon Braket Hybrid Jobs, PennyLane, and other Braket Features 15. Chapter 11: Single-Objective Optimization Use Case 16. Chapter 12: Multi-Objective Optimization Use Case 17. Other Books You May Enjoy Appendix: Knapsack BQM Derivation

Visualizing the knapsack problem

The code for the knapsack problem has been provided in this book’s GitHub repository. This initial part of the code sets up a sample knapsack problem and then solves it using a probabilistic method. Other classical methods are available and have been mentioned in the Further reading section.

First, let’s explain how the plot_knapsack() function works. This function tries adding the items in a variety of ways, starting with one-item combinations, then two-item combinations, and then tracks the maximum value and weight found. It will do this until it reaches the total number of items. While sampling, it will print the solution (items, value, and weight) if the value exceeds the previously stored maximum value. The plots show all the combinations it finds. The X-axis is the sample number (not the number of items in the solution).

Now, let’s set up and run through a sample knapsack problem. The data of the value and the weight...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime