|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# JijModeling 1.10.0 Release Notes\n", |
| 8 | + "\n", |
| 9 | + "JijModeling 1.10.0 provides critical bug fixes and feature enhancements to improve the stability and functionality of the library.\n", |
| 10 | + "\n", |
| 11 | + "## Feature Enhancements\n", |
| 12 | + "\n", |
| 13 | + "### `Interpreter` 1-hot Constraint Detection\n", |
| 14 | + "\n", |
| 15 | + "The `Interpreter` now identifies 1-hot constraints during constraint evaluation in the following form:\n", |
| 16 | + "\n", |
| 17 | + "$$\n", |
| 18 | + "\\sum_{i=1}^{n} x_i = 1, \\quad x_i \\in \\{0, 1\\}\n", |
| 19 | + "$$\n", |
| 20 | + "\n", |
| 21 | + "This enhancement provides hints to improve solver performance for compatible solvers. Detected constraints can be accessed via the `constraint_hints` property in `ommx.v1.Instance`." |
| 22 | + ] |
| 23 | + }, |
| 24 | + { |
| 25 | + "cell_type": "code", |
| 26 | + "execution_count": null, |
| 27 | + "metadata": {}, |
| 28 | + "outputs": [], |
| 29 | + "source": [ |
| 30 | + "import jijmodeling as jm\n", |
| 31 | + "\n", |
| 32 | + "n = jm.Placeholder(\"n\")\n", |
| 33 | + "x = jm.BinaryVar(\"x\", shape=(n,))\n", |
| 34 | + "i = jm.Element(\"i\", belong_to=(0,n))\n", |
| 35 | + "\n", |
| 36 | + "problem = jm.Problem(\"problem\")\n", |
| 37 | + "# Add 1-hot constraint\n", |
| 38 | + "problem += jm.Constraint(\"onehot\", jm.sum(i, x[i]) == 1)\n", |
| 39 | + "\n", |
| 40 | + "interpreter = jm.Interpreter({\"n\": 3})\n", |
| 41 | + "instance = interpreter.eval_problem(problem)\n", |
| 42 | + "\n", |
| 43 | + "# Display detected constraint information\n", |
| 44 | + "print(instance.raw.constraint_hints)" |
| 45 | + ] |
| 46 | + }, |
| 47 | + { |
| 48 | + "cell_type": "markdown", |
| 49 | + "metadata": {}, |
| 50 | + "source": [ |
| 51 | + "Future updates will enable the detection of various constraints, including SOS1/SOS2 and n-hot constraints.\n", |
| 52 | + "\n", |
| 53 | + "### Further Improvements in Type Hints\n", |
| 54 | + "\n", |
| 55 | + "Type hinting across submodules has been significantly improved to resolve Pyright errors that previously occurred. This improvement leverages advancements in `pyo3-stub-gen` ([see](https://github.com/Jij-Inc/pyo3-stub-gen/releases/tag/0.6.1)) to ensure seamless type checking in submodules.\n", |
| 56 | + "\n", |
| 57 | + "Prior to this release, type errors were common in submodules:\n", |
| 58 | + "\n", |
| 59 | + "\n", |
| 60 | + "\n", |
| 61 | + "These issues are now resolved, ensuring a more robust developer experience:\n", |
| 62 | + "\n", |
| 63 | + "\n", |
| 64 | + "\n", |
| 65 | + "## Bug Fixes\n", |
| 66 | + "\n", |
| 67 | + "### Fixed `ndim` Calculation for Jagged Arrays\n", |
| 68 | + "\n", |
| 69 | + "This release resolves a logic error in calculating the ndim (number of dimensions) for jagged arrays. The bug caused errors during Interpreter initialization and prevented evaluation of instances loaded through the MIPLIB loader." |
| 70 | + ] |
| 71 | + }, |
| 72 | + { |
| 73 | + "cell_type": "code", |
| 74 | + "execution_count": null, |
| 75 | + "metadata": {}, |
| 76 | + "outputs": [], |
| 77 | + "source": [ |
| 78 | + "import jijmodeling as jm\n", |
| 79 | + "\n", |
| 80 | + "# Load MIPLIB instance \"air05\"\n", |
| 81 | + "dataset = jm.dataset.Miplib()\n", |
| 82 | + "problem, instance_data = dataset.load(\"air05\")\n", |
| 83 | + "\n", |
| 84 | + "try:\n", |
| 85 | + " # In jijmodeling <= 1.9.0, either of these two lines would raise an InterpreterError\n", |
| 86 | + " interpreter = jm.Interpreter(instance_data)\n", |
| 87 | + " interpreter.eval_problem(problem)\n", |
| 88 | + "except jm.InterpreterError as e:\n", |
| 89 | + " print(f\"InterpreterError: {e}\")" |
| 90 | + ] |
| 91 | + }, |
| 92 | + { |
| 93 | + "cell_type": "markdown", |
| 94 | + "metadata": {}, |
| 95 | + "source": [ |
| 96 | + "### Corrected Arithmetic Assignment Operator Behavior (`+=`) for Objective Functions\n", |
| 97 | + "\n", |
| 98 | + "A long-standing issue with the `+=` operator for objective functions has been fixed. Previously, adding to an existing objective would overwrite the original instead of appending to it." |
| 99 | + ] |
| 100 | + }, |
| 101 | + { |
| 102 | + "cell_type": "code", |
| 103 | + "execution_count": null, |
| 104 | + "metadata": {}, |
| 105 | + "outputs": [], |
| 106 | + "source": [ |
| 107 | + "import jijmodeling as jm\n", |
| 108 | + "\n", |
| 109 | + "x = jm.BinaryVar(\"x\")\n", |
| 110 | + "y = jm.BinaryVar(\"y\")\n", |
| 111 | + "\n", |
| 112 | + "problem = jm.Problem(\"problem\")\n", |
| 113 | + "# Add x to objective function\n", |
| 114 | + "problem += x\n", |
| 115 | + "# Add y to objective function\n", |
| 116 | + "problem += y\n", |
| 117 | + "\n", |
| 118 | + "# In jijmodeling <= 1.9.0, the objective function would be y instead of x + y\n", |
| 119 | + "assert jm.is_same(problem.objective, x + y)" |
| 120 | + ] |
| 121 | + }, |
| 122 | + { |
| 123 | + "cell_type": "markdown", |
| 124 | + "metadata": {}, |
| 125 | + "source": [ |
| 126 | + "## Changelog\n", |
| 127 | + "\n", |
| 128 | + "### Bug Fixes\n", |
| 129 | + "\n", |
| 130 | + "- Fixed incorrect `ndim` calculation for jagged arrays, ensuring seamless `Interpreter` initialization and MIPLIB loader evaluation.\n", |
| 131 | + "\n", |
| 132 | + "- Resolved behavior of the `+=` operator to properly append terms to existing objective functions.\n", |
| 133 | + "\n", |
| 134 | + "### Feature Enhancements\n", |
| 135 | + "\n", |
| 136 | + "- 1-Hot Constraint Detection:\n", |
| 137 | + " Supported constraints must adhere to the following form:\n", |
| 138 | + " $\n", |
| 139 | + " \\displaystyle \\sum_{i=1}^{n} x_i = 1, \\quad x_i \\in \\{0, 1\\}\n", |
| 140 | + " $\n", |
| 141 | + " \n", |
| 142 | + " - Left-hand side: exactly one summation symbol.\n", |
| 143 | + " - Summation operand: a single binary variable with an index.\n", |
| 144 | + " - Constraint type: equality.\n", |
| 145 | + " - Right-hand side: a NumberLit with value of 1.\n", |
| 146 | + "- Resolved Pyright errors in submodules by improving type hint support through `pyo3-stub-gen` enhancements." |
| 147 | + ] |
| 148 | + } |
| 149 | + ], |
| 150 | + "metadata": { |
| 151 | + "kernelspec": { |
| 152 | + "display_name": ".venv", |
| 153 | + "language": "python", |
| 154 | + "name": "python3" |
| 155 | + }, |
| 156 | + "language_info": { |
| 157 | + "codemirror_mode": { |
| 158 | + "name": "ipython", |
| 159 | + "version": 3 |
| 160 | + }, |
| 161 | + "file_extension": ".py", |
| 162 | + "mimetype": "text/x-python", |
| 163 | + "name": "python", |
| 164 | + "nbconvert_exporter": "python", |
| 165 | + "pygments_lexer": "ipython3", |
| 166 | + "version": "3.10.12" |
| 167 | + } |
| 168 | + }, |
| 169 | + "nbformat": 4, |
| 170 | + "nbformat_minor": 2 |
| 171 | +} |
0 commit comments