Skip to content

Commit 69b955d

Browse files
authored
Merge pull request #146 from Jij-Inc/kory33/egglog-constraint-subscript-eval
Add bugfix (unrelased) notes for the tuple-indexed variables + `constraint_detection=True` issue
2 parents 6dc0792 + a687904 commit 69b955d

4 files changed

Lines changed: 141 additions & 1 deletion

File tree

docs/en/releases/unreleased.ipynb

Lines changed: 42 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/ja/releases/unreleased.ipynb

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

markdowns/en/releases/unreleased.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,35 @@ problem
226226
In previous releases, the `latex` specifications were ignored in the code above, and the bounds were displayed as $L \leq x \leq U$.
227227
Starting with this release, the settings are preserved as shown above, and the bounds are displayed as $\ell \leq x \leq \mathcal{U}$.
228228

229+
### Fixed a bug where problem evaluation with constraint detection crashed when decision variables were subscripted by tuples
230+
231+
We fixed a bug where `eval_problem` crashed when decision variables were subscripted with tuples and constraint detection was enabled (this is the case by default, or when the `constraint_detection` keyword argument was set to something other than `False`). For example, the following code used to crash in previous versions:
232+
233+
```{code-cell} ipython3
234+
import jijmodeling as jm
235+
236+
237+
@jm.Problem.define("dict-keyed binary var with tuple subscripts")
238+
def problem(problem: jm.DecoratedProblem):
239+
N = problem.Natural()
240+
K = problem.Placeholder(ndim=1, dtype=(jm.DataType.NATURAL, jm.DataType.NATURAL))
241+
x = problem.BinaryVar(dict_keys=K)
242+
243+
problem += problem.Constraint(
244+
"sweeps",
245+
(jm.sum(x[k] for k in K if k[0] == i) <= 1 for i in jm.range(N)),
246+
)
247+
248+
249+
instance_data = {
250+
"N": 3,
251+
"K": [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1)],
252+
}
253+
254+
compiler = jm.Compiler.from_problem(problem, instance_data)
255+
instance = compiler.eval_problem(problem, constraint_detection=True)
256+
```
257+
229258
## Other Changes
230259

231260
- Relaxed version bounds to allow installation on any Python 3 version from Python 3.11 onwards.

markdowns/ja/releases/unreleased.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,35 @@ problem
219219

220220
これまでのリリースでは、上記のコードでは `latex` 指定が無視され、$L \leq x \leq U$ のように表示されていましたが、上記のように設定が保たれるようになり、$\ell \leq x \leq \mathcal{U}$ と表示されるようになりました。
221221

222+
### 決定変数がタプルで添字付けされている場合に制約検出付きの問題評価がクラッシュするバグの修正
223+
224+
決定変数がタプル型のキーを持つ辞書で添字付けされている時、制約検出が有効な状態(デフォルトや、 `constraint_detection` キーワード引数が `False` 以外の場合)で `eval_problem` がクラッシュするバグを修正しました。たとえば、以前のバージョンでは以下のコードはクラッシュしていました。
225+
226+
```{code-cell} ipython3
227+
import jijmodeling as jm
228+
229+
230+
@jm.Problem.define("dict-keyed binary var with tuple subscripts")
231+
def problem(problem: jm.DecoratedProblem):
232+
N = problem.Natural()
233+
K = problem.Placeholder(ndim=1, dtype=(jm.DataType.NATURAL, jm.DataType.NATURAL))
234+
x = problem.BinaryVar(dict_keys=K)
235+
236+
problem += problem.Constraint(
237+
"sweeps",
238+
(jm.sum(x[k] for k in K if k[0] == i) <= 1 for i in jm.range(N)),
239+
)
240+
241+
242+
instance_data = {
243+
"N": 3,
244+
"K": [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1)],
245+
}
246+
247+
compiler = jm.Compiler.from_problem(problem, instance_data)
248+
instance = compiler.eval_problem(problem, constraint_detection=True)
249+
```
250+
222251
## その他の変更
223252

224253
- バージョン条件を緩和し、Python 3.11 以降の任意の Python 3 でのインストールを許容しました。

0 commit comments

Comments
 (0)