diff --git a/Project.toml b/Project.toml index 9f9d5d3..dee6611 100644 --- a/Project.toml +++ b/Project.toml @@ -20,7 +20,7 @@ HerbConstraints = "^0.2.0" HerbCore = "^0.3.0" HerbGrammar = "^0.4.0" HerbInterpret = "^0.1.3" -HerbSpecification = "^0.1.0" +HerbSpecification = "0.2" MLStyle = "^0.4.17" Random = "1.8.0,1.9.0,1.10.0,1.11.0" StatsBase = "^0.34" diff --git a/src/evaluate.jl b/src/evaluate.jl index 6fa4db1..79a160d 100644 --- a/src/evaluate.jl +++ b/src/evaluate.jl @@ -18,7 +18,13 @@ Optional parameters: Returns a score in the interval [0, 1] """ -function evaluate(problem::Problem{Vector{IOExample}}, expr::Any, symboltable::SymbolTable; shortcircuit::Bool=true, allow_evaluation_errors::Bool=false)::Number +function evaluate( + problem::Problem{<:AbstractVector{<:IOExample}}, + expr::Any, + symboltable::SymbolTable; + shortcircuit::Bool=true, + allow_evaluation_errors::Bool=false +)::Number number_of_satisfied_examples = 0 crashed = false diff --git a/src/stochastic_iterator.jl b/src/stochastic_iterator.jl index e678bd3..b8ae243 100644 --- a/src/stochastic_iterator.jl +++ b/src/stochastic_iterator.jl @@ -157,7 +157,7 @@ end Returns the cost of the `program` using the examples and the `cost_function`. It first convert the program to an expression and evaluates it on all the examples. """ -function _calculate_cost(program::Union{RuleNode, StateHole}, cost_function::Function, spec::AbstractVector{IOExample}, grammar::AbstractGrammar, evaluation_function::Function) +function _calculate_cost(program::Union{RuleNode, StateHole}, cost_function::Function, spec::AbstractVector{<:IOExample}, grammar::AbstractGrammar, evaluation_function::Function) results = Tuple{<:Number,<:Number}[] expression = rulenode2expr(program, grammar) diff --git a/test/test_search_procedure.jl b/test/test_search_procedure.jl index 965e231..ec46879 100644 --- a/test/test_search_procedure.jl +++ b/test/test_search_procedure.jl @@ -32,7 +32,7 @@ Index = List[Number] end - problem = Problem([IOExample(Dict(), x) for x ∈ 1:5]) + problem = Problem([IOExample(Dict{Symbol,Any}(), x) for x ∈ 1:5]) iterator = BFSIterator(g₂, :Index, max_depth=2) solution, flag = synth(problem, iterator, allow_evaluation_errors=true) @@ -70,7 +70,7 @@ Index = List[Number] end - problem = Problem([IOExample(Dict(), x) for x ∈ 1:5]) + problem = Problem([IOExample(Dict{Symbol,Any}(), x) for x ∈ 1:5]) iterator = BFSIterator(g₃, :Index, max_depth=2) solution, flag = synth(problem, iterator, allow_evaluation_errors=true)