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

Changed test to match python API and update README to match output #36

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ count = c.count()
print("Approximate count is: %d*2**%d" % (count[0], count[1]))
```

The above will print that `Approximate count is: 88*2**13`. Since the largest variable in the clauses was 20, the system contained 2**20 (i.e. 1048576) potential models. However, some of these models were prohibited by the two clauses, and so only approximately 88*2**13 (i.e. 720896) models remained.
The above will print that `Approximate count is: 11*2**16`. Since the largest variable in the clauses was 20, the system contained 2**20 (i.e. 1048576) potential models. However, some of these models were prohibited by the two clauses, and so only approximately 11*2**16 (i.e. 720896) models remained.

If you want to count over a projection set, you need to call `count(projection_set)`, for example:

Expand All @@ -45,7 +45,7 @@ count = c.count(range(1,10))
print("Approximate count is: %d*2**%d" % (count[0], count[1]))
```

This now prints `Approximate count is: 56*2**3`, which corresponds to the approximate count of models, projected over variables 1..10.
This now prints `Approximate count is: 7*2**6`, which corresponds to the approximate count of models, projected over variables 1..10.

## How to Build a Binary
To build on Linux, you will need the following:
Expand Down
8 changes: 4 additions & 4 deletions python/tests/test_pyapproxmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ def minimal_test():
assert counter.count() == (512, 90)

def sampling_set_test():
counter = Counter(seed=2157, epsilon=0.8, delta=0.2, sampling_set=list(range(1,50)))
counter = Counter(seed=2157, epsilon=0.8, delta=0.2)
counter.add_clause(range(1,100))
assert counter.count() == (64, 43)
assert counter.count(list(range(1,50))) == (64, 43)

def real_example_test():
counter = Counter(seed=120, epsilon=0.8, delta=0.2, sampling_set=list(range(1,21)))
counter = Counter(seed=120, epsilon=0.8, delta=0.2)

with open("test_1.cnf") as test_cnf:
# Pop sampling set and metadata lines
Expand All @@ -22,7 +22,7 @@ def real_example_test():
literals = [int(i) for i in line.split()[:-1]]
counter.add_clause(literals)

assert counter.count() == (64,14)
assert counter.count(list(range(1,21))) == (64,14)

if __name__ == '__main__':
minimal_test()
Expand Down
Loading