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

Utils: Add A Benchmark to Count the Number of Boolean Operations #18

Closed
5 tasks done
bliutech opened this issue Jul 10, 2024 · 1 comment · Fixed by #37
Closed
5 tasks done

Utils: Add A Benchmark to Count the Number of Boolean Operations #18

bliutech opened this issue Jul 10, 2024 · 1 comment · Fixed by #37
Assignees
Labels

Comments

@bliutech
Copy link
Owner

bliutech commented Jul 10, 2024

Since the goal of our project is to perform boolean simplification, we need a benchmark so we can formally compare various simplifications of a given boolean expression. A working metric we can use is the number of boolean operations (i.e. !, | and &; note that ( and ) do not count since these help precedence but do not act as an operation themselves - this can be discussed and evaluated later). A clean way to implement this metric is to use the visitor design pattern which we implemented in #17. The goal of this component is to write a visitor which traverses the AST and counts the number of boolean operations there are in a given boolean expression ((i.e. !, | and &). An example is shown below.

A | B & ! C -> 3

Action Items

  • create a new file called utils/metrics.py
  • write a new class called OpCounter which inherits from the Visitor class defined in parser.visitor
  • override all the relevant methods within the Visitor class to increment a _count variable
  • write an accessor, getCount, method which returns the _count variable
  • write some test cases using the unittest module inside a new file called tests/test_metrics.py

Resources

See #17 for a reference on how to write a visitor.

For a reference of how to use the visitor, see this example written in one of the test cases. The implementation for this should be fairly similar but only overrides a subset of the methods.

@bliutech
Copy link
Owner Author

bliutech commented Jul 10, 2024

Potentially, another way to benchmark this project is to use the number of leaf nodes within the AST.

Use the definition mentioned above for the number of operations.

@bliutech bliutech added help wanted Extra attention is needed priority labels Jul 17, 2024
@micah-0w0 micah-0w0 assigned micah-0w0 and unassigned micah-0w0 Jul 17, 2024
@timoslater timoslater self-assigned this Jul 17, 2024
@bliutech bliutech removed the help wanted Extra attention is needed label Jul 17, 2024
@timoslater timoslater removed their assignment Jul 17, 2024
@micah-0w0 micah-0w0 self-assigned this Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants