Lut generation and schema search#49
Open
srikanth-iyer wants to merge 67 commits into
Open
Conversation
…/srikanth-iyer/CANA into LUT-generation-and-schema-search
Collaborator
Author
|
@fcphysics Can you have a look at this pull request please? I've added Ke for anni_gen rules as well in this |
fxcosta-phd
reviewed
Oct 21, 2024
| """ | ||
| generated_node = None | ||
| closest_node = None | ||
| closest_ke = None |
Contributor
There was a problem hiding this comment.
Are those initial settings of the parameters to "None" necessary? Because it might make debugging more difficult later.
fxcosta-phd
approved these changes
Oct 21, 2024
fxcosta-phd
left a comment
Contributor
There was a problem hiding this comment.
Great job @srikanth-iyer, those are necessary improvements.
Would you mind adding a description/disclaimer on the README file about what is in the automata folder?
This is because "automata" is more general than "boolean_node" in the sense that it could take more states. However, this is not what the code considers. We are still in the "boolean realm", but we are interested in specific features focusing on annihilation and generation.
Generalizes the selection of the middle input for annihilation and generation schemata for all k, instead of the hardcoded k=7 Initializes default xticks in both schemata plots to prevent missing tick errors when no schemata are drawn.
…es to improve clarity
…; add GP function to bools.py and corresponding tests
- Implemented Cython functions for fast computation of input symmetry means in `cboolean_node.pyx`, enhancing performance for boolean node operations. - Added `input_symmetry_mean_fast` and `input_symmetry_mean_annigen_fast` functions to calculate mean number of permutable inputs efficiently. - Introduced `_sum_group_lengths` helper function for summing group lengths in a list of Two-Symbol schemata. - Created `__init__.py` files for `bns` and `cell_collective` datasets, providing module-level documentation for bundled datasets in CANA.
…ath)
Ports the two-symbol coverage optimization to the LUT/schema-search branch.
This branch had already Cython-ized the per-call helpers (_expand_ts_logic,
_pi_covers, _ts_covers), but computes_ts_coverage still carried the core
algorithmic redundancy: it looped over all 2**k states and re-expanded every
schema for each state. The annihilation/generation ("anni_gen") coverage path
(get_anni_gen_coverage / input_symmetry_mean_anni_gen) builds on top of regular
ts_coverage, so it benefits transparently.
Changes (cana/canalization/boolean_canalization.py):
- computes_ts_coverage: invert the loop. Expand each schema once (via the
existing expand_ts_logic_fast Cython helper), enumerate the minterms it covers
directly (new _minterms_of helper), and mark coverage. Output is byte-for-byte
identical (same keys, key order, and per-state covering lists) to the previous
implementation.
- find_two_symbols_v2: memoize results on (k, frozenset(prime_implicants)) so
nodes with identical logic are not recomputed; returns a deep copy to keep the
cache immutable to callers. Fold the same_symbols computation into one pass.
Adds tests/test_ts_coverage.py, which locks computes_ts_coverage to a reference
reimplementation of the original per-state algorithm across arities up to k=9.
Measured ~2.9x faster coverage on a k=9 node (on top of the existing Cython
helpers); full test suite (78 tests) passes, plus 6 new coverage tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EoojjrUJSx3qofcdWyUwNm
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
added schema search rules, sample automata rules, tests, input symmetry for anni_gen in BooleanNode among others.
@fcphysics if you have time, i'll be happy to go through the changes with you. Please let me know if you can review these changes. I need them on the casci repo because some of the functions will be used in the noisy cellular automata GA.
@jcrozum also adding you here. I'm assuming that you're busy settling in, but in case you have time to check the code, please let me know. I'd love your input.
And sorry for the big pull request.