From 6a57e17c94947a3b402c706d1b529f39e7c15c43 Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 09:54:12 -0700 Subject: [PATCH 1/7] jn1: Replace Leap JNs with dwave-examples JNs --- 01-hybrid-computing-getting-started.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-hybrid-computing-getting-started.ipynb b/01-hybrid-computing-getting-started.ipynb index 1a0e265..23fe622 100644 --- a/01-hybrid-computing-getting-started.ipynb +++ b/01-hybrid-computing-getting-started.ipynb @@ -29,7 +29,7 @@ "\n", "## Prerequisite Knowledge\n", "\n", - "These notebooks assume basic familiarity with [Ocean Software](https://docs.ocean.dwavesys.com/en/stable/index.html) and its binary quadratic model ([BQM](https://docs.ocean.dwavesys.com/en/stable/concepts/bqm.html)) approach to formulating problems on quantum computers. [Leap's](https://cloud.dwavesys.com/leap) *Structural Imbalance* and *Factoring* Jupyter Notebooks are good introductions to the basics of solving problems on a quantum computer, as is the [Getting Started with the D-Wave System](https://docs.dwavesys.com/docs/latest/doc_getting_started.html) guide. For an introduction to Ocean software, see [Ocean Software documentation](https://docs.ocean.dwavesys.com/en/stable/getting_started.html#gs). " + "These notebooks assume basic familiarity with [Ocean Software](https://docs.ocean.dwavesys.com/en/stable/index.html) and its binary quadratic model ([BQM](https://docs.ocean.dwavesys.com/en/stable/concepts/bqm.html)) approach to formulating problems on quantum computers. The [Structural Imbalance](https://github.com/dwave-examples/structural-imbalance-notebook) and [Factoring](https://github.com/dwave-examples/factoring-notebook) Jupyter Notebooks are good introductions to the basics of solving problems on a quantum computer, as is the [Getting Started with the D-Wave System](https://docs.dwavesys.com/docs/latest/doc_getting_started.html) guide. For an introduction to Ocean software, see [Ocean Software documentation](https://docs.ocean.dwavesys.com/en/stable/getting_started.html#gs). " ] }, { From 4b69ea7094693edc2a15cd24d045e9e8fc51ab65 Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 10:08:04 -0700 Subject: [PATCH 2/7] jn1: Change URL with parenthesis to wiki-shortened URL --- 01-hybrid-computing-getting-started.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-hybrid-computing-getting-started.ipynb b/01-hybrid-computing-getting-started.ipynb index 23fe622..95be25a 100644 --- a/01-hybrid-computing-getting-started.ipynb +++ b/01-hybrid-computing-getting-started.ipynb @@ -66,7 +66,7 @@ "\n", "\n", "\n", - "Such a graph might represent the problem of [antenna selection](https://github.com/dwave-examples/antenna-selection), finding good coverage for a sprinkler system, or many other real-world optimization problems. If the graph represents a sprinkler system, with edges corresponding to overlaps in sprinklers' watering, a [maximum independent set](https://en.wikipedia.org/wiki/Independent_set_(graph_theory)) solves the problem of watering a lawn evenly with the lowest number of sprinklers. " + "Such a graph might represent the problem of [antenna selection](https://github.com/dwave-examples/antenna-selection), finding good coverage for a sprinkler system, or many other real-world optimization problems. If the graph represents a sprinkler system, with edges corresponding to overlaps in sprinklers' watering, a [maximum independent set](https://w.wiki/4zwn) solves the problem of watering a lawn evenly with the lowest number of sprinklers. " ] }, { From 62b31ec6f37d3380d421de38bd799ab10d896110 Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 10:19:20 -0700 Subject: [PATCH 3/7] jn1: Update ref to helpers --- 01-hybrid-computing-getting-started.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-hybrid-computing-getting-started.ipynb b/01-hybrid-computing-getting-started.ipynb index 95be25a..729099d 100644 --- a/01-hybrid-computing-getting-started.ipynb +++ b/01-hybrid-computing-getting-started.ipynb @@ -73,7 +73,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The first code cell below uses [networkx](https://networkx.github.io) to build a random sparse graph—the `random_geometric_graph()` function places uniformly at random a specified number of nodes, `problem_node_count`, in a unit cube, joining edges of any two if the distance is below a given `radius`—and utility graphics code to plot it. To see this graphics code, select **Jupyter File Explorer View** from the Online Learning page and navigate to the folder for this notebook.\n", + "The first code cell below uses [networkx](https://networkx.github.io) to build a random sparse graph—the `random_geometric_graph()` function places uniformly at random a specified number of nodes, `problem_node_count`, in a unit cube, joining edges of any two if the distance is below a given `radius`—and utility graphics code to plot it. To see this graphics code, navigate to the `helpers` folder of this repository.\n", "\n", "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
" ] From b39fa5241cb08433fe25a82838409e32b48e50ac Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 10:46:40 -0700 Subject: [PATCH 4/7] jn1: Update alerts --- 01-hybrid-computing-getting-started.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/01-hybrid-computing-getting-started.ipynb b/01-hybrid-computing-getting-started.ipynb index 729099d..bd7d777 100644 --- a/01-hybrid-computing-getting-started.ipynb +++ b/01-hybrid-computing-getting-started.ipynb @@ -75,7 +75,8 @@ "source": [ "The first code cell below uses [networkx](https://networkx.github.io) to build a random sparse graph—the `random_geometric_graph()` function places uniformly at random a specified number of nodes, `problem_node_count`, in a unit cube, joining edges of any two if the distance is below a given `radius`—and utility graphics code to plot it. To see this graphics code, navigate to the `helpers` folder of this repository.\n", "\n", - "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
" + "\n", + "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
" ] }, { @@ -127,7 +128,8 @@ "\n", "This section provides a demonstration of using a Leap hybrid solver.\n", "\n", - "
Note: Not all accounts have access to this type of solver. This is the only section of the Hybrid Computing notebooks that uses these solvers—if you do not see solvers in the Hybrid section of Supported Solvers in your Leap dashboard, skip to the next section.
" + "\n", + "
Note: Not all accounts have access to this type of solver. This is the only section of the Hybrid Computing notebooks that uses these solvers—if you do not see solvers in the Hybrid section of Solvers in your Leap dashboard, skip to the next section.
" ] }, { From eae1bbec31ab369f2484e0c27f087fcd1ba6e51a Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 12:13:41 -0700 Subject: [PATCH 5/7] jn2: Updates alerts for VS Code compatibility --- 02-hybrid-computing-workflows.ipynb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/02-hybrid-computing-workflows.ipynb b/02-hybrid-computing-workflows.ipynb index cde850f..6818f66 100644 --- a/02-hybrid-computing-workflows.ipynb +++ b/02-hybrid-computing-workflows.ipynb @@ -27,9 +27,11 @@ "# A Sample Problem\n", "This section recreates the [Quantum-Classical Hybrid Computing: Getting Started](01-hybrid-computing-getting-started.ipynb) problem for use in the following sections. \n", "\n", - "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
\n", + "\n", + "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
\n", "\n", - "
Note: The code cell below imports from helpers, a folder colocated with this Jupyter Notebook. Users running it in Leap can see helper functions by selecting Jupyter File Explorer View on the Online Learning page.
" + "> **Note:** The code cell below imports from the `helpers` module. To see this code, navigate to the `helpers` folder \n", + " of this repository." ] }, { @@ -338,7 +340,8 @@ "

Hint: You have seen that the samples field of a state is of type dimod SampleSet, which has methods to convert from samples, and state has its own convenience method, from_sample, for constructing a state from a raw (dict) sample.

\n", "\n", "\n", - "
Note: When using a hybrid tabu sampler, be sure to correctly configure how it expands input-state samples into its initial states.
" + "> **Note:** When using a hybrid tabu sampler, be sure to correctly configure how it expands input-state samples into \n", + " its initial states." ] }, { From 37beb6caaa141ee24edee78af208101f6b178935 Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 13:43:33 -0700 Subject: [PATCH 6/7] jn2: Update exercise hint formatting --- 02-hybrid-computing-workflows.ipynb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/02-hybrid-computing-workflows.ipynb b/02-hybrid-computing-workflows.ipynb index 6818f66..6a4f3c6 100644 --- a/02-hybrid-computing-workflows.ipynb +++ b/02-hybrid-computing-workflows.ipynb @@ -212,6 +212,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "\n", "
\n", " Exercise: By default, TabuProblemSampler runs for 100 ms. In the placeholder code cell below, modify the previous example to increase the timeout parameter or the tabu tenure and see if that produces a better solution. \n", "
" @@ -260,9 +261,7 @@ "source": [ "
\n", " Exercise: Use the Runnable Lambda to add an \"info\" field to an input state.\n", - "\n", - "

Hint 1: Lambda creates a Runnable on the fly. You can use Lambda(next)—where callable next can be a lambda expression that accepts the Runnable instance and state instance—to process an input state. For example, hybrid.Lambda(lambda _, s: s), like the Identity used above, returns a copy of the input state.

Hint 2: For this exercise, use the State method updated() that returns a copy of a state updated from specified arguments.

\n", - "
" + "

Hint 1: Lambda creates a Runnable on the fly. You can use Lambda(next)—where callable next can be a lambda expression that accepts the Runnable instance and state instance—to process an input state. For example, hybrid.Lambda(lambda _, s: s), like the Identity used above, returns a copy of the input state.

Hint 2: For this exercise, use the State method updated() that returns a copy of a state updated from specified arguments.

" ] }, { From 99fb8fa4c7cc16c05b4eed14ace20d5386f1d592 Mon Sep 17 00:00:00 2001 From: Joel Pasvolsky Date: Tue, 29 Mar 2022 13:59:33 -0700 Subject: [PATCH 7/7] jn3: Update alert formats for VS Code compatibility --- 03-hybrid-computing-components.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/03-hybrid-computing-components.ipynb b/03-hybrid-computing-components.ipynb index bf22839..0682692 100644 --- a/03-hybrid-computing-components.ipynb +++ b/03-hybrid-computing-components.ipynb @@ -27,7 +27,8 @@ "# A Sample Problem\n", "This section recreates the [Quantum-Classical Hybrid Computing: Getting Started](01-hybrid-computing-getting-started.ipynb) problem for use in the following sections. \n", "\n", - "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
" + "\n", + "
Note: Problem size (nodes and density of edges) selected below ensures that runtimes on compute resources (virtual CPUs) provided by the Leap environment do not exceed a few minutes.
" ] }, { @@ -388,6 +389,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "\n", "
\n", " Exercise: In the placeholder code cell below, modify IncrementCount to also print the state's best energy. Test your code in the EXERCISE TEST CELL below.\n", "

Note: a samples field is present in the tested input state, state_count_0, and for simplicity, assume this is always the case. In the Adding Custom Traits subsection below, you will see how to ensure this is always the case.

"