-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Herb-AI/dev
Checkpoint recent developments
- Loading branch information
Showing
36 changed files
with
1,138 additions
and
1,204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
name = "HerbSearch" | ||
uuid = "3008d8e8-f9aa-438a-92ed-26e9c7b4829f" | ||
authors = ["Sebastijan Dumancic <[email protected]>", "Jaap de Jong <[email protected]>", "Nicolae Filat <[email protected]>", "Piotr Cichoń <[email protected]>", "Tilman Hinnerichs <[email protected]>"] | ||
version = "0.1.1" | ||
version = "0.2.0" | ||
|
||
[deps] | ||
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" | ||
HerbConstraints = "1fa96474-3206-4513-b4fa-23913f296dfc" | ||
HerbCore = "2b23ba43-8213-43cb-b5ea-38c12b45bd45" | ||
HerbData = "495a3ad3-8034-41b3-a087-aacf2fd71098" | ||
HerbGrammar = "4ef9e186-2fe5-4b24-8de7-9f7291f24af7" | ||
HerbInterpret = "5bbddadd-02c5-4713-84b8-97364418cca7" | ||
HerbSpecification = "6d54aada-062f-46d8-85cf-a1ceaf058a06" | ||
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" | ||
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" | ||
|
||
[compat] | ||
DataStructures = "0.17,0.18" | ||
HerbConstraints = "0.1.0" | ||
HerbCore = "0.1.1" | ||
HerbData = "0.1.1" | ||
HerbGrammar = "0.1.0" | ||
HerbInterpret = "0.1.0" | ||
StatsBase = "0.34" | ||
julia = "1.8" | ||
HerbConstraints = "^0.1.0" | ||
HerbCore = "^0.2.0" | ||
HerbGrammar = "^0.2.0" | ||
HerbInterpret = "^0.1.1" | ||
HerbSpecification = "^0.1.0" | ||
StatsBase = "^0.34" | ||
julia = "^1.8" | ||
|
||
[extras] | ||
LegibleLambdas = "f1f30506-32fe-5131-bd72-7c197988f9e5" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
# Search.jl | ||
|
||
[![codecov](https://codecov.io/gh/Herb-AI/HerbSearch.jl/graph/badge.svg?token=VUK6MXLCU4)](https://codecov.io/gh/Herb-AI/HerbSearch.jl) | ||
[![Build Status](https://github.com/Herb-AI/HerbSearch.jl/actions/workflows/CI.yml/badge.svg?branch=master)](https://github.com/Herb-AI/HerbSearch.jl/actions/workflows/CI.yml?query=branch%3Amaster) | ||
[![Dev-Docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://Herb-AI.github.io/Herb.jl/dev) | ||
|
||
# HerbSearch.jl | ||
|
||
This package contains search procedure implementations for the Herb Program Synthesis framework. | ||
|
||
For full documentation please see the `Herb.jl` documentation | ||
For full documentation please see the [`Herb.jl` documentation](https://herb-ai.github.io/Herb.jl/dev/). | ||
|
||
## Getting started | ||
To use this project, initialize the project with | ||
For a quick tutorial on how to get started with using `HerbSearch.jl` have a look at our [introductory tutorial](https://herb-ai.github.io/Herb.jl/dev/get_started/) or [Advanced search procedures](https://herb-ai.github.io/Herb.jl/dev/tutorials/advanced_search/). | ||
|
||
If you want to help developing this project, initialize the project with | ||
```shell | ||
julia --project=. -e 'using Pkg; Pkg.instantiate()' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
""" | ||
count_expressions(grammar::Grammar, max_depth::Int, max_size::Int, sym::Symbol) | ||
count_expressions(grammar::AbstractGrammar, max_depth::Int, max_size::Int, sym::Symbol) | ||
Counts and returns the number of possible expressions of a grammar up to max_depth with start symbol sym. | ||
""" | ||
function count_expressions(grammar::Grammar, max_depth::Int, max_size::Int, sym::Symbol) | ||
function count_expressions(grammar::AbstractGrammar, max_depth::Int, max_size::Int, sym::Symbol) | ||
l = 0 | ||
# Calculate length without storing all expressions | ||
for _ ∈ get_bfs_enumerator(grammar, max_depth, max_size, sym) | ||
for _ ∈ BFSIterator(grammar, sym, max_depth=max_depth, max_size=max_size) | ||
l += 1 | ||
end | ||
return l | ||
end | ||
|
||
""" | ||
count_expressions(iter::ExpressionIterator) | ||
count_expressions(iter::ProgramIterator) | ||
Counts and returns the number of possible expressions in the expression iterator. The Iterator is not modified. | ||
""" | ||
count_expressions(iter::ExpressionIterator) = count_expressions(iter.grammar, iter.max_depth, iter.max_size, iter.sym) | ||
count_expressions(iter::ProgramIterator) = count_expressions(iter.grammar, iter.max_depth, iter.max_size, iter.sym) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
struct EvaluationError <: Exception | ||
expr::Expr | ||
input::Dict{Symbol, Any} | ||
error::Exception | ||
end | ||
|
||
Base.showerror(io::IO, e::EvaluationError) = print(io, "An exception was thrown while evaluating the expression $(e.expr) on input $(e.input): $(e.error)") | ||
|
||
""" | ||
evaluate(problem::Problem{Vector{IOExample}}, expr::Any, tab::SymbolTable; allow_evaluation_errors::Bool=false) | ||
Evaluate the expression on the examples. | ||
Optional parameters: | ||
- `shortcircuit` - Whether to stop evaluating after finding single example fails, to speed up the [synth](@ref) procedure. If true, the returned score is an underapproximation of the actual score. | ||
- `allow_evaluation_errors` - Whether the search should continue if an exception is thrown in the evaluation or throw the error | ||
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 | ||
number_of_satisfied_examples = 0 | ||
|
||
crashed = false | ||
for example ∈ problem.spec | ||
try | ||
output = execute_on_input(symboltable, expr, example.in) | ||
if (output == example.out) | ||
number_of_satisfied_examples += 1 | ||
elseif (shortcircuit) | ||
break; | ||
end | ||
catch e | ||
# You could also decide to handle less severe errors (such as index out of range) differently, | ||
# for example by just increasing the error value and keeping the program as a candidate. | ||
crashed = true | ||
# Throw the error again if evaluation errors aren't allowed | ||
eval_error = EvaluationError(expr, example.in, e) | ||
allow_evaluation_errors || throw(eval_error) | ||
break | ||
end | ||
end | ||
|
||
return number_of_satisfied_examples/length(problem.spec); | ||
end | ||
|
Oops, something went wrong.
183a8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
Release Notes:
search(...)
function replaced bysynth(...)
—this includes a new signature. Please refer to the updated documentation.HerbData
->HerbSpecification
183a8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error while trying to register: Register Failed
@ReubenJ, it looks like you are not a publicly listed member/owner in the parent organization (Herb-AI).
If you are a member/owner, you will need to change your membership to public. See GitHub Help
183a8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
Release Notes:
search(...)
function replaced bysynth(...)
—this includes a new signature. Please refer to the updated documentation.HerbData
->HerbSpecification
183a8b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/102860
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: