Skip to content

Commit 4d18503

Browse files
authored
Merge pull request #139 from Jij-Inc/konn/randgen-bugfix
Random generation-related changes
2 parents 8ec9b93 + 880c9fa commit 4d18503

4 files changed

Lines changed: 388 additions & 4 deletions

File tree

docs/en/releases/unreleased.ipynb

Lines changed: 149 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: 148 additions & 1 deletion
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: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,52 @@ kernelspec:
2727

2828
+++
2929

30-
### Bugfix 1
30+
### Bugfixes in random instance data generation
31+
32+
We fixed the following two bugs in random instance data generation:
33+
34+
#### Placeholders that depend on `NamedExpr` were not handled correctly
35+
36+
We fixed a bug where placeholders whose shape (length) or key set depends on `NamedExpr` were not handled correctly.
37+
For example, consider the following problem:
38+
39+
```{code-cell} ipython3
40+
import jijmodeling as jm
41+
42+
43+
@jm.Problem.define("My Problem")
44+
def problem(problem: jm.DecoratedProblem):
45+
a = problem.Float(ndim=1)
46+
N = problem.NamedExpr(a.len_at(0))
47+
b = problem.Natural(shape=(N, None))
48+
M = problem.NamedExpr(b.len_at(1))
49+
problem += jm.sum(a[i] * b[i, j] for i in N for j in M)
50+
51+
52+
problem
53+
```
54+
55+
In previous versions, calling `generate_random_dataset()` on this `problem` raised an exception. Starting with this release, the data is generated correctly.
56+
57+
```{code-cell} ipython3
58+
problem.generate_random_dataset(seed=17)
59+
```
60+
61+
#### Fixed a bug where generation failed when unused placeholders were present
62+
63+
Data generation failed when there were unused placeholders not included in `used_placeholder()`.
64+
For example, in the following code, `N` is defined but never used, and previous versions raised a runtime exception.
65+
66+
```{code-cell} ipython3
67+
import jijmodeling as jm
68+
69+
problem = jm.Problem("My Problem")
70+
N = problem.Natural("N")
71+
72+
problem.generate_random_dataset(seed=17)
73+
```
74+
75+
Starting with this release, data is generated successfully in cases like the example above.
3176

3277

3378
## Other Changes

0 commit comments

Comments
 (0)