Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probe generialized implementation #98

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open

Probe generialized implementation #98

wants to merge 68 commits into from

Conversation

nicolaefilat
Copy link
Contributor

@nicolaefilat nicolaefilat commented May 13, 2024

We ask for code review to check if the implementation is up to standards.

It requires HerbGrammar to be on branch fix-normalizing to pass tests.

nicolaefilat and others added 30 commits April 29, 2024 21:42
Tests do not pass.
Implementation is also probably to inefficient
Add all 3 selection functions for probe and wrote tests
Co-authored-by: Nicolae Filat,
…tside the if then else

Remove unused `programs` field
function Base.iterate(iter::GuidedSearchIterator, state::GuidedSearchState)::Union{Tuple{RuleNode, GuidedSearchState}, Nothing}
grammar = get_grammar(iter.solver)
start_symbol = get_starting_symbol(iter.solver)
# wrap in while true to optimize for tail call
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not get this. Why would you do this exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be that the code that actually returns the outcome of the iteration never returns a program because the programs are skipped because of observational equivalence.

if return_type(grammar, prog.ind) == start_symbol
    eval_observation, correct_examples = evaluate_program(prog, grammar, iter.spec, iter.symboltable)

    if eval_observation in state.eval_cache # program already cached
        continue # maybe this skips all programs...
    end
    prog._val = (eval_observation, correct_examples)
    
    push!(state.eval_cache, eval_observation) # add result to cache
    push!(state.bank[state.level+1], prog) # add program to bank
    return (prog, state) # return program
end

The while true forces the function to keep executing until a program is returned. We could have called the function recursively but using an iterative approach is better I think.

@nicolaefilat
Copy link
Contributor Author

I did a bit of a hack to add the HerbGrammar fix-normalizing branch to the CI as a dependency to make the CI pass to prove that the code works :)

@nicolaefilat nicolaefilat marked this pull request as ready for review July 14, 2024 12:55
@ReubenJ
Copy link
Member

ReubenJ commented Jul 15, 2024

I did a bit of a hack to add the HerbGrammar fix-normalizing branch to the CI as a dependency to make the CI pass to prove that the code works :)

Please switch this back, @nicolaefilat. We don't want to mess with the CI to make it pass. We'll get the HerbGrammar branch merged and released before merging this.

@nicolaefilat
Copy link
Contributor Author

@ReubenJ I reverted the CI hack :)

Base automatically changed from dev to master October 3, 2024 12:28
@ReubenJ
Copy link
Member

ReubenJ commented Oct 23, 2024

Hackathon Plan

Steps

  • Run a budgeted search
    • Gets an iterator with some limit (the low-level budget)
    • This is a normal iterator
  • Collect (partial) successes
    • Function to define success, which is just % of examples solved by default
    • Function takes any kind of specification
    • Boolean output: should the program be saved or not?
  • Modify the grammar
    • Function to modify the grammar based on the successes
    • Takes the successes (saved programs)
    • Modify the grammar: in place or return a new one, TBD
  • Rinse and repeat
    • Function defining high-level budget
    • For now, just a parameter defining the number of overall runs of budgeted search

Optimization

  • When evaluating a program during search, store the output of a rulenode on the specification in the rulenode's _val field
  • Keep queue across grammar updates to avoid re-enumerating the search space that was already explored earlier

@ReubenJ ReubenJ mentioned this pull request Oct 23, 2024
@THinnerichs THinnerichs self-assigned this Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants