JijModeling 1.12.1 Release Notes#
Feature Enhancements#
Human Readable Errors in Interpreters#
Now Interpreter
fails with more human-readable error message. For example:
import jijmodeling as jm
D = jm.Placeholder("D", dtype=jm.DataType.INTEGER)
T = jm.Placeholder("T", dtype=jm.DataType.INTEGER)
N = jm.Placeholder("N", dtype=jm.DataType.INTEGER)
H = jm.Placeholder("H", shape=(D, T, N))
R = jm.Placeholder("R", shape=(D, N))
x = jm.BinaryVar("x", shape=(D, T, N))
d = jm.Element("d", belong_to=(0, D))
t = jm.Element("t", belong_to=(0, T))
i = jm.Element("i", belong_to=(0, N))
problem = jm.Problem(name="shift_optimization")
problem += jm.Constraint("night_shift", R[d+1, i] <= x[d, T-1, i], forall=[d, i])
problem += jm.sum([d, t, i], x[d, t, i])
problem
\[\begin{split}\begin{array}{cccc}\text{Problem:} & \text{shift\_optimization} & & \\& & \min \quad \displaystyle \sum_{d = 0}^{D - 1} \sum_{t = 0}^{T - 1} \sum_{i = 0}^{N - 1} x_{d, t, i} & \\\text{{s.t.}} & & & \\ & \text{night\_shift} & \displaystyle R_{d + 1, i} \leq x_{d, T - 1, i} & \forall d \in \left\{0,\ldots,D - 1\right\} \forall i \in \left\{0,\ldots,N - 1\right\} \\\text{{where}} & & & \\& x & 3\text{-dim binary variable}\\\end{array}\end{split}\]
num_days = 7
num_times = 3
num_people = 5
data = problem.generate_random_dataset(
options={
"D": {"value": num_days},
"T": {"value": num_times},
"N": {"value": num_people},
}
)
interp = jm.Interpreter(data)
try:
interp.eval_problem(problem)
except Exception as e:
print(e)
Traceback (most recent last):
while evaluating Problem `shift_optimization',
defeind at File "/tmp/ipykernel_2122/2988517098.py", line 14, col 11-48
while evaluating constraint: `night_shift',
defeind at File "/tmp/ipykernel_2122/2988517098.py", line 15, col 12-82
while evaluating expression `R[d + 1, i] - x[d, T - 1, i]',
defeind at File "/tmp/ipykernel_2122/2988517098.py", line 15, col 41-66
while evaluating expression `R[d + 1, i]',
defeind at File "/tmp/ipykernel_2122/2988517098.py", line 15, col 41-50
File "/tmp/ipykernel_2122/2988517098.py", line 15, col 41-50:
15 | problem += jm.Constraint("night_shift", R[d+1, i] <= x[d, T-1, i], forall=[d, i])
^^^^^^^^^
IndexError: Index (7,0) is out of range for shape (7,5)
Bugfixes#
Fixes the Performance Bug in Interpreter.eval_*
.#
Previously, evaluating expressions with Interpreter
takes much more times than intended.
This was due to the direct call to the arithmetic operations on OMMX Function
s, which goes through conversion between intermediate expressions and re-allocates memory from the ground up. This results in quadratic performance degradation in some summation operations.
Now JijModeling uses dedicated intermediate form of functions, so the overhead of conversion should be greatly tamed now.