Herb-AI / HerbConstraints.jl

Constraints for Herb.jl
https://herb-ai.github.io/
MIT License
0 stars 0 forks source link

Cache list of nodes in `LocalForbiddenSequence` #51

Open Whebon opened 1 month ago

Whebon commented 1 month ago

The propagate method of LocalForbiddenSequence starts by collecting a list of nodes:

function propagate!(solver::Solver, c::LocalForbiddenSequence)
    nodes = get_nodes_on_path(get_tree(solver), c.path)
    #...
end

This is the bottleneck of this propagate method. Furthermore, in a uniform tree, this list will always be the same. So re-computing the list is unnecessary.

Why is this not here yet?

In the GenericSolver, hole instances can be replaced during search. So references might become invalid. Additionally, constraints cannot be stateful in the GenericSolver because the constraints are shared by reference among different active solver states.

This optimization will only be valid in the UniformSolver. So it may require a new type of local constraint: StateLocalForbiddenSequence.