Skip to content

Commit

Permalink
Rename according to HerbCore 3, bump version for HerbCore=0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
THinnerichs committed Apr 16, 2024
1 parent 983cfa1 commit b3fdd02
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/fixed_shaped_iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/heuristics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/random_iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Revise
using HerbCore
using HerbSearch
using HerbGrammar
Expand Down
4 changes: 2 additions & 2 deletions test/test_forbidden.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/test_sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
Expand Down

0 comments on commit b3fdd02

Please sign in to comment.