Version 4.0.0
Major version bump because of breaking changes introduced in the WeightScheme
's interface, and its dependents.
Changelog
Issue #57 (PR #70, thanks @leonlan) introduces the optional only_after
keyword argument to ALNS.add_repair_operator
. This keyword argument can be used to indicate that a repair operator only works with a specific set of destroy operators. One can use this argument as follows:
from alns import ALNS
def destroy_op1(current, rnd_state):
pass
def destroy_op2(current, rnd_state):
pass
def repair_op1(destroyed, rnd_state):
pass
def repair_op2(destroyed, rnd_state):
pass
alns = ALNS()
alns.add_destroy_operator(destroy_op1)
alns.add_destroy_operator(destroy_op2)
alns.add_repair_operator(repair_op1, only_after=[destroy_op1])
alns.add_repair_operator(repair_op2)
In this example, repair_op1
will only be selected if destroy_op1
was selected, whereas repair_op2
can be used with both destroy_op1
and destroy_op2
.
This has consequences for the WeightScheme.select_operators
interface: it now takes an additional op_coupling
argument, which is a binary 0/1 matrix indicating which operators can work together. In particular, element (i, j) is 1 if destroy operator i and repair operator j can work together, 0 otherwise. The WeightScheme
has been updated to use this information to select the appropriate operator pairs.
Existing code should not be impacted, unless your code uses a custom weight scheme.