Skip to content

Commit

Permalink
Enhance Documentation for docs/en/tutorial/tsp_sampling_with_openjij_…
Browse files Browse the repository at this point in the history
…adapter.ipynb (#295)

## Summary
This pull request updates the tutorial to explain and guide how to solve
TSP via ommx.
## Changes
The file `docs/en/tutorial/tsp_sampling_with_openjij_adapter.ipynb`.

Co-authored-by: Taro P. Shimizu <[email protected]>
  • Loading branch information
ahao27 and Shitaro authored Feb 14, 2025
1 parent 5823d6e commit b61bf0c
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions docs/en/tutorial/tsp_sampling_with_openjij_adapter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Sampling from QUBO with OMMX Adapter\n",
"\n",
"Here we explain how to convert a problem to QUBO and perform sampling using the Traveling Salesman Problem as an example.\n",
"Here, we explain how to convert a problem to QUBO and perform sampling using the Traveling Salesman Problem as an example.\n",
"\n",
"```{figure} ./assets/taraimawashi_businessman.png\n",
"[Illustration of a man in a suit](https://www.irasutoya.com/2017/03/blog-post_739.html)\n",
Expand Down Expand Up @@ -46,7 +46,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's plot the locations of the cities"
"Let's plot the locations of the cities."
]
},
{
Expand Down Expand Up @@ -228,7 +228,7 @@
"+ \\sum_{i=0}^{N-1} \\left(\\sum_{t=0}^{N-1} x_{t, i} - 1\\right)^2 \\right]\n",
"$$\n",
"\n",
"You can check what parameters the `ParametricInstance` has using the `parameters` property."
"You can check the parameters of the `ParametricInstance` using the `parameters` property."
]
},
{
Expand Down Expand Up @@ -315,7 +315,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The resulting `qubo` now has all parameters substituted, so it is a `ommx.v1.Instance` instead of a `ommx.v1.ParametricInstance`. Additionally, it is an unconstrained optimization problem without any constraints."
"The resulting `qubo` now has all parameters substituted, so it is an `ommx.v1.Instance` instead of an `ommx.v1.ParametricInstance`. Additionally, it is an unconstrained optimization problem without any constraints."
]
},
{
Expand Down Expand Up @@ -600,7 +600,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"`ommx_openjij_adapter.sample_qubo_sa` returns `ommx.v1.Samples`, which can be passed to `Instance.evaluate_samples` to calculate the objective function values and constraint violations. The `SampleSet.summary` property is used to display summary information. `feasible` indicates the feasibility with respect to **the original problem** before conversion to QUBO. This is calculated using the information stored in `removed_constraints` of the `qubo` instance.\n",
"`ommx_openjij_adapter.sample_qubo_sa` returns `ommx.v1.Samples`, which can be passed to `Instance.evaluate_samples` to calculate the objective function values and constraint violations. The `SampleSet.summary` property is used to display summary information. `feasible` indicates the feasibility to **the original problem** before conversion to QUBO. This is calculated using the information stored in `removed_constraints` of the `qubo` instance.\n",
"\n",
"To view the feasibility for each constraint, use the `summary_with_constraints` property."
]
Expand Down Expand Up @@ -1478,7 +1478,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"To obtain the samples, use the `SampleSet.extract_decision_variables` method. This interprets the samples using the `name` and `subscripts` registered when creating `ommx.v1.DecisionVariables`. For example, to get the value of the decision variable named `x` with `sample_id=1`, use the following to obtain it in the form of `dict[subscripts, value]`."
]
},
Expand Down Expand Up @@ -1532,7 +1531,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's display this. First, obtain the IDs of samples that are feasible for the original problem."
"Let's display this. First, we obtain the IDs of samples that are feasible for the original problem."
]
},
{
Expand Down Expand Up @@ -1600,7 +1599,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -1614,9 +1613,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.8"
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

0 comments on commit b61bf0c

Please sign in to comment.