JijModeling 2.3.1 Release Notes#
Feature Enhancements#
Added jm.range()#
With the jijmodeling.range() function you can now represent sequences by using Expressions. Its usage is similar to python’s built-in range().
Example usage:
import jijmodeling as jm
@jm.Problem.define("RangeProblem")
def problem(problem: jm.DecoratedProblem):
S = problem.Natural()
F = problem.Natural()
N = problem.Natural()
x = problem.BinaryVar(shape=(10,))
problem += jm.sum(x[i] for i in jm.range(S, F, N))
Support -= operator to update a Problem’s objective function#
You can now use -= to add subtracted terms from a Problem’s objective function.
Unlike +=, -= does not support removing constraints.
problem = jm.Problem("problem")
x = problem.ContinuousVar("x", lower_bound=0, upper_bound=5)
y = problem.ContinuousVar("y", lower_bound=0, upper_bound=5)
problem += x
problem -= y
assert jm.is_same(problem.objective, x - y)
DependentVar becomes NamedExpr#
Before JijModeling 2.3, there was a DependentVar class for representing dependent variables.
Despite the name, this feature could also be used to define values that do not depend on decision variables, such as the length of a Placeholder.
Because this could be confusing, the DependentVar class has been replaced by the NamedExpr class, which provides the same functionality. Use NamedExpr instead.
For details, see Naming Expressions and Saving Them in Instances.
Bugfixes#
Bugfix: Proper handling of bound variables in slice notation#
The handling of bound variables in slice notation has been fixed, ensuring that variables bound in comprehensions or constraint indices are correctly handled within slice notation.
Bugfix: LaTeX output for sums and membership relations over natural numbers in indexed constraints#
In previous versions, when the domain of an indexed constraint or the range of a summation was over natural numbers, the membership relation was output using \(\in\), for example:
Starting in this release, the output is made natural in the same way as objective functions and standalone constraints:
problem = jm.Problem("P")
N = problem.Natural("N", shape=2)
x = problem.BinaryVar("x", shape=(N[0], N[1]))
problem.Constraint("c1", lambda i: jm.sum(N[1], lambda j: x[i, j]) == 1, domain=N[0])
Bugfix: Fixes unrecoverable error in random instance generation under unused placeholder#
We have fixed the bug where the random instance generation panics under the presence of an unused placeholder in the problem definition.