diff --git a/Project.toml b/Project.toml index 13fe3c5..4da9b7d 100644 --- a/Project.toml +++ b/Project.toml @@ -18,7 +18,7 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" [compat] DataStructures = "0.17,0.18" HerbConstraints = "^0.2.0" -HerbCore = "^0.2.0" +HerbCore = "^0.3.0" HerbGrammar = "^0.2.1" HerbInterpret = "0.1.2" HerbSpecification = "^0.1.0" diff --git a/src/fixed_shaped_iterator.jl b/src/fixed_shaped_iterator.jl index 2290c6c..78da2b5 100644 --- a/src/fixed_shaped_iterator.jl +++ b/src/fixed_shaped_iterator.jl @@ -2,7 +2,7 @@ Base.@doc """ @programiterator FixedShapedIterator() Enumerates all programs that extend from the provided fixed shaped tree. -The [Solver](@ref) is required to be in a state without any [VariableShapedHole](@ref)s. +The [Solver](@ref) is required to be in a state without any [Hole](@ref)s. !!! warning: this iterator is used as a baseline for the constraint propagation thesis. After the thesis, this iterator can (and should) be deleted. """ FixedShapedIterator @@ -42,7 +42,7 @@ function Base.iterate(iter::FixedShapedIterator) pq :: PriorityQueue{SolverState, Union{Real, Tuple{Vararg{Real}}}} = PriorityQueue() solver = iter.solver - @assert !contains_variable_shaped_hole(get_tree(iter.solver)) "A FixedShapedIterator cannot iterate partial programs with VariableShapedHoles" + @assert !contains_variable_shaped_hole(get_tree(iter.solver)) "A FixedShapedIterator cannot iterate partial programs with Holes" if isfeasible(solver) enqueue!(pq, get_state(solver), priority_function(iter, get_grammar(solver), get_tree(solver), 0)) @@ -83,7 +83,7 @@ function _find_next_complete_tree( # The maximum depth is reached continue elseif hole_res isa HoleReference - # Fixed Shaped Hole was found + # UniformHole was found # TODO: problem. this 'hole' is tied to a target state. it should be state independent (; hole, path) = hole_res diff --git a/src/heuristics.jl b/src/heuristics.jl index 13be9a0..68a6580 100644 --- a/src/heuristics.jl +++ b/src/heuristics.jl @@ -20,8 +20,8 @@ function heuristic_leftmost_fixed_shaped_hole(node::AbstractRuleNode, max_depth: return already_complete end - #TODO: refactor this. this method should be merged with `heuristic_leftmost`. The only difference is the `FixedShapedHole` typing in the signature below: - function leftmost(hole::FixedShapedHole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} + #TODO: refactor this. this method should be merged with `heuristic_leftmost`. The only difference is the `UniformHole` typing in the signature below: + function leftmost(hole::UniformHole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} if max_depth == 0 return limit_reached end return HoleReference(hole, path) end @@ -50,7 +50,7 @@ function heuristic_leftmost(node::AbstractRuleNode, max_depth::Int)::Union{Expan return already_complete end - function leftmost(hole::VariableShapedHole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} + function leftmost(hole::Hole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} if max_depth == 0 return limit_reached end return HoleReference(hole, path) end @@ -78,7 +78,7 @@ function heuristic_rightmost(node::AbstractRuleNode, max_depth::Int)::Union{Expa return already_complete end - function rightmost(hole::VariableShapedHole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} + function rightmost(hole::Hole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} if max_depth == 0 return limit_reached end return HoleReference(hole, path) end @@ -107,7 +107,7 @@ function heuristic_random(node::AbstractRuleNode, max_depth::Int)::Union{ExpandF return already_complete end - function random(hole::VariableShapedHole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} + function random(hole::Hole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} if max_depth == 0 return limit_reached end return HoleReference(hole, path) end @@ -148,7 +148,7 @@ function heuristic_smallest_domain(node::AbstractRuleNode, max_depth::Int)::Unio return smallest_result end - function smallest_domain(hole::VariableShapedHole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} + function smallest_domain(hole::Hole, max_depth::Int, path::Vector{Int})::Union{ExpandFailureReason, HoleReference} if max_depth == 0 return limit_reached end return HoleReference(hole, path) end diff --git a/src/random_iterator.jl b/src/random_iterator.jl index c2666e3..6e51977 100644 --- a/src/random_iterator.jl +++ b/src/random_iterator.jl @@ -16,7 +16,7 @@ function _rand_with_constraints!(skeleton::RuleNode,solver::Solver,path::Vector{ return get_tree(solver) end -function _rand_with_constraints!(hole::Hole,solver::Solver,path::Vector{Int},dmap::AbstractVector{Int}, remaining_depth::Int=10) +function _rand_with_constraints!(hole::AbstractHole,solver::Solver,path::Vector{Int},dmap::AbstractVector{Int}, remaining_depth::Int=10) @info "The depth hole left: $remaining_depth" hole = get_hole_at_location(solver, path) diff --git a/test/runtests.jl b/test/runtests.jl index 81497e8..94ed929 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,3 @@ -using Revise using HerbCore using HerbSearch using HerbGrammar diff --git a/test/test_forbidden.jl b/test/test_forbidden.jl index cc2904a..bdd8120 100644 --- a/test/test_forbidden.jl +++ b/test/test_forbidden.jl @@ -67,9 +67,9 @@ using HerbCore, HerbGrammar, HerbConstraints RuleNode(1), RuleNode(1) ]), - FixedShapedHole(BitVector((1, 1, 0, 0)), []) + FixedShapedAbstractHole(BitVector((1, 1, 0, 0)), []) ]), - FixedShapedHole(BitVector((0, 0, 1, 1)), [ + FixedShapedAbstractHole(BitVector((0, 0, 1, 1)), [ RuleNode(3, [ RuleNode(1), RuleNode(1) diff --git a/test/test_sampling.jl b/test/test_sampling.jl index 83cfe08..46f0702 100644 --- a/test/test_sampling.jl +++ b/test/test_sampling.jl @@ -76,7 +76,7 @@ using Random end for remaining_depth in 1:10 - skeleton = Hole(BitVector((true,true,true,true,true))) + skeleton = AbstractHole(BitVector((true,true,true,true,true))) rulenode = RuleNode( 5,[RuleNode(1), skeleton] )