Herb-AI / HerbConstraints.jl

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

Implement `rulenode2expr` for `StateFixedShapedHole` #26

Open Whebon opened 3 months ago

Whebon commented 3 months ago

The FixedShapedSolver produces solutions by manipulated a fixed shaped tree. Such fixed shaped trees are a hybrid of two types:

When next_solution! is called, the previous solution is lost and re-manipulated into a new solution. This is intended behavior as this approach to reduce the number of allocations: trees are never copied but reused.

In the current version of Herb, it is not possible to interpret a StateFixedShapedHole directly. So after finding a solution, the tree is converted to rule nodes using statefixedshapedhole2rulenode.

Why is this needed

To reduce to number memory allocations, stop using statefixedshapedhole2rulenode

Target implementation

Implementing rulenode2expr(hole::StateFixedShapedHole, grammar::Grammar) should be straight forward: