Migrate tutorial notebooks to jijmodeling #518
Conversation
- Replace jm.Placeholder/Element/BinaryVar with problem-centric API (problem.Float, problem.DependentVar, problem.BinaryVar) - Replace jm.Interpreter with problem.eval() - Replace extract_decision_variables() with decision_variables_df (extract_decision_variables does not support parameterized decision variables generated by jijmodeling 2.x) - Update ommx-openjij-adapter usage to OMMXOpenJijSAAdapter pattern - Update docs/pyproject.toml dependencies (ommx>=2.3.6, openjij>=0.11.6)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update EN clique_cover to new JijModeling API - Fix graph layout consistency with pos=spring_layout - Rename section headings to "モデル化" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rewrite EN clustering tutorial to match JA version with new JijModeling 2 API - Update JA clustering tutorial with new API (problem.Float, DependentVar, BinaryVar, OMMXOpenJijSAAdapter) - Revert "インスタンスデータの作成" back to "インスタンスの作成" across all tutorials - Minor formatting fixes in graph_coloring, knapsack, number_partition, integer_jobs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Migrate JA/EN QBoost tutorials to new JijModeling 2 API (problem.Integer, BinaryVar, DependentVar, Float, OMMXOpenJijSAAdapter) - Unify heading levels: promote "求解/Running Optimization" and "可視化/Visualizing the Solution" from ### to ## - Fix knapsack heading "モデル構築" → "モデル化" - Revert "インスタンスデータの作成" back to "インスタンスの作成" - Fix λ value description (3.0 → 10.0) to match code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Migrate EN version to new API (problem.Natural, problem.Float,
problem.BinaryVar, problem.Constraint, problem.eval, jm.product)
- Fix index notation: x_{t,i} → x_{i,t} to match code x[i, t]
- Fix tour reconstruction: unpack (i, t) instead of (t, i)
- Fix sum indices from 1-indexed to 0-indexed
- Update explanations: jm.Placeholder → problem.Natural/Float,
jm.Constraint → problem.Constraint, extract_decision_variables
→ decision_variables_df, sampleset.constraints → constraints_df
- Fix city count "10" → "7" to match code
- Fix typo "instnace" → "instance"
- Remove duplicate cells
- Add shortcut section to EN version
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This notebook contained clustering and QBoost sections that are now covered by the dedicated, already-migrated tutorials: - docs/en/tutorial/machine_learning/clustering.ipynb - docs/en/tutorial/machine_learning/qboost.ipynb The removed file used the old API (jm.Placeholder, jm.Binary, to_pyqubo, oj.SASampler) and was fully redundant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove duplicate "## JijModelingによるモデル化" heading in knapsack - Unify heading hierarchy across optimization tutorials - Minor text and structure fixes in graph_coloring, clique_cover, number_partition - Update EN _toc.yml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These .md files contained old API code (jm.Placeholder, jijmodeling_transpiler, PyQUBO) and are superseded by the migrated .ipynb notebooks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…round Temporarily revert the EIGEN3_FOUND workaround and add debug output to verify Eigen3 detection state (EIGEN3_FOUND, Eigen3_FOUND, TARGET Eigen3::Eigen, version) across CI environments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove temporary debug output added for CI verification. Restore the TARGET-based Eigen3 detection and EIGEN3_FOUND workaround for cimod, confirmed necessary by CI results: - Ubuntu (apt, Eigen3 3.4.0): EIGEN3_FOUND set → OK - macOS (brew, Eigen3 5.0.1): EIGEN3_FOUND not set → needs fix - Windows (vcpkg, Eigen3 5.0.1): EIGEN3_FOUND not set → build fails Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts: # CMakeLists.txt # external/cimod.cmake
Revert unintended kernelspec metadata changes (display_name, etc.) that were introduced during tutorial migration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Standardize section headers (制約条件→制約, Modeling by→Modeling with, etc.) - Use invitational tone consistently (実装します→実装しましょう, can be implemented→Let us implement) - Split combined code cells in number_partition for consistency - Minor text cleanups (punctuation, spacing) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Standardize JijModeling section headers (定式化→実装) - Rename Objective Function → Hamiltonian (Objective Function) for ML tutorials - Unify intro text for modeling sections - Clarify constraint/objective references (式(1)→式(1)の制約) - Add backticks to code references in text Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Align terminology: JijModeling sections describe mathematical formulation, not code implementation. Updated headers and body text in both JA (定式化) and EN (Formulation/formulate) tutorials. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove "(Objective Function)" from Hamiltonian section headers - Use math notation for variable n in clique cover description - Fix remaining implement→formulate wording Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates the tutorial documentation (primarily Jupyter notebooks) to the jijmodeling 2.x API and the newer ommx/openjij adapter flow, while also cleaning up redundant tutorial sources and updating documentation links.
Changes:
- Updated docs runtime dependencies to jijmodeling 2.x / ommx 2.3.6 / openjij 0.11.6 and related packages.
- Migrated multiple JA/EN tutorial notebooks to jijmodeling 2.x constructs and
decision_variables_df-based result extraction. - Removed unused/redundant markdown tutorial files and updated the English TOC accordingly.
Reviewed changes
Copilot reviewed 19 out of 27 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/uv.lock | Updates locked versions for jijmodeling/ommx/openjij ecosystem packages. |
| docs/pyproject.toml | Bumps jijmodeling/ommx/openjij requirements and adds scikit-learn for ML tutorials. |
| docs/en/_toc.yml | Removes the deleted QA notebook entry and normalizes formatting. |
| docs/ja/tutorial/optimization/number_partition.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/optimization/knapsack.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/optimization/integer_jobs.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/optimization/graph_coloring.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/optimization/clique_cover.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/machine_learning/qboost.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/machine_learning/clustering.md | Deleted unused markdown version of the tutorial. |
| docs/ja/tutorial/optimization/number_partition.ipynb | Migrates formulation + OpenJij execution to jijmodeling 2.x / adapter; updates links and decoding. |
| docs/ja/tutorial/optimization/knapsack.ipynb | Migrates to jijmodeling 2.x formulation, adapter execution, and updated decoding/outputs. |
| docs/ja/tutorial/optimization/integer_jobs.ipynb | Migrates to jijmodeling 2.x constraint/objective constructs and adapter-based solving + visualization. |
| docs/ja/tutorial/machine_learning/qboost.ipynb | Migrates QBoost model/solve path to jijmodeling 2.x + adapter and updates result interpretation. |
| docs/en/tutorial/optimization/number_partition.ipynb | Aligns explanation with constraint-based formulation; migrates to adapter flow + decoding updates. |
| docs/en/tutorial/optimization/knapsack.ipynb | Migrates to jijmodeling 2.x + adapter and refreshes explanation/output formatting. |
| docs/en/tutorial/optimization/integer_jobs.ipynb | Migrates to jijmodeling 2.x constructs and adapter-based solve + visualization. |
| docs/en/tutorial/machine_learning/qboost.ipynb | Migrates QBoost workflow to jijmodeling 2.x + adapter and updates evaluation code. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Fix TSP JA/EN: update text reference from `dist` to `d` to match code - Fix integer_jobs JA: use 0-based indexing (A_0) to match EN and code - Fix integer_jobs EN: formatting improvements Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change "コンピュータ1" to "コンピュータ0" and A_1 to A_0 in the mathematical model description to be consistent with the code which uses 0-based indexing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
integer_jobs は パラメータを追加しました。 テキスト修正
パラメータの変更
|
|
日本語版を基準にされたとのことで、日本語版に関しては回答の通りです。 英語版では あと 1 点、 |
Restore the uniform_penalty_weight parameter that was present in the EN version of number_partition on main. Also update uv.lock to reflect the scikit-learn dependency addition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
なるほど、enとjaで異なっていたのは見落としていました。 また、 |
There was a problem hiding this comment.
修正ありがとうございます。
knapsack の uniform_penalty_weight について、graph_coloring や clustering、qboost でも指定されていません。
knapsack だけ追加すると不統一になるため、この対応で問題ないと思います。
Copilot の指摘について
decision_variables_df での名前フィルタリング
(該当コメント)
main ブランチでは extract_decision_variables("x") で変数名 "x" が絞り込まれていました。
一方、decision_variables_df は全変数を含む DataFrame を返すため、移行後は明示的な絞り込みが必要です。
knapsack ではこのプルリクエストで name フィルタを追加されていますが、他のノートブックでは入っていません。
# knapsack(名前フィルタあり — この PR で追加)
x_df = df[(df["name"] == "x") & (df["value"] == 1)]
# integer_jobs(名前フィルタなし — この PR で追加)
x_indices = df[df["value"]==1]["subscripts"].to_list()現在のチュートリアルでは決定変数が 1 種類のみなので動作します。
読者がコードを参考にすることを考えると、knapsack のように df["name"] == "x" での絞り込みを統一しておくとより良いかもしれません。
もちろん、別途対応でも構いません。
value == 1.0 と value > 0.5 の混在
(該当コメント)
TSP は main の時点から > 0.5 を使っており、他のノートブックはこの PR で == 1 を使っています。
# TSP(main から > 0.5)
nonzero_keys = {... for _, row in df.iterrows() if row["value"] > 0.5}
# integer_jobs(この PR で == 1)
x_indices = df[df["value"]==1]["subscripts"].to_list()OpenJij の SA サンプラーは numpy.int8 の 0/1 を返し、
State への変換で float64 になります。
0 と 1 は IEEE 754 で正確に表現されるため、どちらでも動作します。
個人的には > 0.5 の方が他のソルバーにも対応できて汎用的かなと思いますが、こちらも別途対応で構いません。
もし両方まとめて修正される場合、対象は以下のファイルです。
| ファイル | Copilot コメント |
|---|---|
en/.../number_partition.ipynb |
link |
ja/.../number_partition.ipynb |
link |
en/.../graph_coloring.ipynb |
— |
ja/.../graph_coloring.ipynb |
— |
en/.../clique_cover.ipynb |
— |
ja/.../clique_cover.ipynb |
— |
en/.../integer_jobs.ipynb |
link |
ja/.../integer_jobs.ipynb |
link |
en/.../clustering.ipynb |
— |
ja/.../clustering.ipynb |
— |
en/.../qboost.ipynb |
link |
ja/.../qboost.ipynb |
link |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Add name filter (df["name"] == "x"/"w") to all notebooks for explicit variable selection from decision_variables_df - Standardize value filtering to use > 0.5 instead of == 1.0 for better solver compatibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR migrates the documentation tutorial notebooks to the JijModeling 2.x API and updates the docs build environment accordingly, addressing known runtime issues with parameterized decision variables and modernizing links/content.
Changes:
- Update docs dependencies to JijModeling 2.x / OMMX 2.x / OpenJij 0.11.x (and add scikit-learn for ML tutorials).
- Refactor tutorial notebooks to the JijModeling 2.x modeling/evaluation flow and use
decision_variables_dffor decoding. - Remove unused/duplicated markdown tutorial sources and drop the duplicated EN notebook from the TOC.
Reviewed changes
Copilot reviewed 19 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/uv.lock | Updates locked dependency set for JijModeling 2.x / OMMX 2.x / OpenJij 0.11.x; adds scikit-learn transitive deps. |
| docs/pyproject.toml | Bumps JijModeling/OMMX/OpenJij requirements and adds scikit-learn. |
| docs/ja/tutorial/optimization/number_partition.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/ja/tutorial/optimization/number_partition.ipynb | Migrates to JijModeling 2.x API and updates decoding to decision_variables_df. |
| docs/ja/tutorial/optimization/knapsack.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/ja/tutorial/optimization/knapsack.ipynb | Migrates to JijModeling 2.x API and updates solution extraction/printing. |
| docs/ja/tutorial/optimization/integer_jobs.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/ja/tutorial/optimization/graph_coloring.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/ja/tutorial/optimization/clique_cover.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/ja/tutorial/machine_learning/qboost.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/ja/tutorial/machine_learning/qboost.ipynb | Migrates to JijModeling 2.x API; switches to OMMX/OpenJij adapter path and decision_variables_df. |
| docs/ja/tutorial/machine_learning/clustering.md | Removes unused markdown tutorial source (superseded by ipynb). |
| docs/en/tutorial/optimization/number_partition.ipynb | Migrates to JijModeling 2.x API; updates links and decoding to decision_variables_df. |
| docs/en/tutorial/optimization/knapsack.ipynb | Migrates to JijModeling 2.x API; updates links and solution extraction/printing. |
| docs/en/tutorial/machine_learning/qboost.ipynb | Migrates to JijModeling 2.x API; switches to OMMX/OpenJij adapter path and decision_variables_df. |
| docs/en/_toc.yml | Removes the deleted/duplicated EN tutorial notebook entry from the TOC. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
コメントありがとうございます! 以下の2点を修正しました。
|
概要
チュートリアルノートブックを jijmodeling 2.x API に移行します。
変更内容
jijmodeling 2.x API への移行
extract_decision_variables → decision_variables_df
ommx.Solution.extract_decision_variables()は、jijmodeling 2.x が生成するパラメータ付き決定変数に対応しておらずRuntimeError: Decision variable with parameters is not supportedが発生するため、decision_variables_dfを使用する方式に変更しました。LaTeX 数式の修正
\bm{v},\bm{w}等の未定義コマンドを除去(MathJax ではレンダリングされず生テキストとして表示されていた問題を修正)\boldsymbol{v},\boldsymbol{w}も同様に除去し、日英で統一JijModeling ドキュメントリンクの差し替え
https://www.ref.documentation.jijzept.com/jijmodeling/を新しい ReadTheDocs URL に差し替えhttps://jij-inc-jijmodeling-tutorials-en.readthedocs-hosted.com/en/latest/introduction.htmlhttps://jij-inc-jijmodeling-tutorials-ja.readthedocs-hosted.com/ja/latest/introduction.htmljij-inc.github.io/JijModeling-Tutorials/...) も同様に差し替え不要ファイルの削除
docs/en/tutorial/007-Machine_Learning_by_QA.ipynbを削除clustering.ipynb,qboost.ipynb)と完全に重複していたためjm.Placeholder,jm.Binary,to_pyqubo,oj.SASampler)のまま残っていたdocs/ja/tutorial/optimization/*.md(5ファイル)、docs/ja/tutorial/machine_learning/*.md(2ファイル)を削除.ipynbが存在し、_toc.ymlは拡張子なしで参照するため.ipynbが優先され、これらの.mdはビルド時に使用されていない依存関係の更新 (docs/pyproject.toml)
ommx>=2.3.6ommx-openjij-adapter>=2.3.6openjij>=0.11.6対象ノートブック(移行済み)
docs/ja/tutorial/optimization/number_partition.ipynbdocs/en/tutorial/optimization/number_partition.ipynbdocs/ja/tutorial/optimization/knapsack.ipynbdocs/en/tutorial/optimization/knapsack.ipynbdocs/ja/tutorial/optimization/graph_coloring.ipynbdocs/en/tutorial/optimization/graph_coloring.ipynbdocs/ja/tutorial/optimization/clique_cover.ipynbdocs/en/tutorial/optimization/clique_cover.ipynbdocs/ja/tutorial/optimization/integer_jobs.ipynbdocs/en/tutorial/optimization/integer_jobs.ipynbdocs/ja/tutorial/machine_learning/clustering.ipynbdocs/en/tutorial/machine_learning/clustering.ipynbdocs/ja/tutorial/machine_learning/qboost.ipynbdocs/en/tutorial/machine_learning/qboost.ipynbdocs/ja/tutorial/004-jijmodeling_openjij_tsp.ipynbdocs/en/tutorial/004-jijmodeling_openjij_tsp.ipynb削除済み
docs/en/tutorial/007-Machine_Learning_by_QA.ipynb(clustering.ipynb / qboost.ipynb と重複)docs/ja/tutorial/optimization/*.md(5ファイル)docs/ja/tutorial/machine_learning/*.md(2ファイル)関連 Issue