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

Add function get_solution_count. #72

Merged
merged 25 commits into from
Dec 1, 2023
Merged

Add function get_solution_count. #72

merged 25 commits into from
Dec 1, 2023

Conversation

jwg4
Copy link
Owner

@jwg4 jwg4 commented Nov 14, 2023

No description provided.

@jwg4
Copy link
Owner Author

jwg4 commented Nov 14, 2023

to fix #17

two functions to add:

  • get_solution_count
  • get_all_solutions

The first just returns an integer. The second returns an array of all the solutions. The second must be harder than the first. Let's do the first first.

  • add the function to the Python module written in C
  • add the function to dlx.c
  • (probably) modify the basic algo code so that we can keep going after finding one solution
  • add code in the Python wrapper to call get_solution_count
  • add and run simple Python test
  • add and run more complex Python tests
  • C tests

@jwg4
Copy link
Owner Author

jwg4 commented Nov 14, 2023

@parmentelat
Let me know if you have different opinions about the suggested ways of proceeding above.

I believe that based on my last push:

  1. it will be possible to call the function get_solution_count from Python (in exact_cover_impl) module
  2. it won't crash(?)
  3. but it also won't give the right answer

so the next step is maybe to add a Python test

@jwg4
Copy link
Owner Author

jwg4 commented Nov 15, 2023

added some tests based on a very simple ec problem

parmentelat and others added 5 commits November 15, 2023 13:43
renamed data.py into problems.py
add tests/bruteforce.py to compute brute force solutions
3 more problems with 2, 9 and 16 solutions
test solution_count on small_trimino problem
@jwg4
Copy link
Owner Author

jwg4 commented Nov 15, 2023

the current function doesn't crash but clearly doesn't give the right answer. we have a good selection of tests.

@jwg4
Copy link
Owner Author

jwg4 commented Nov 18, 2023

current function looks like it gives the right answer, next steps are to add C tests and clean up the C code a bit

I think it makes sense to merge this funcitonality when it's in a good state and then open a second PR for a function which returns an array of all the solutions.

@jwg4
Copy link
Owner Author

jwg4 commented Nov 18, 2023

We need to figure out how the solution count should handle the following cases:

  1. presence of blank rows. the number of solutions could be multiplied by 2^(number of blank rows) to represent all the possibilities of including them or not including them
  2. presence of duplicate rows. the number of solutions could be multiplied by product(number of copies of each row in the solution) to represent all the possibilities

my guess is that the first will not happen (blank rows will be ignored) but that the second will happen (two rows the same means all the solutions that include one of them are counted twice). This also kind of seems like what one wants.

@jwg4
Copy link
Owner Author

jwg4 commented Nov 18, 2023

this is published to pypi as 1.4.0a0

I think this probably can be merged with only documentation added, and then get_all_solutions which fills an array with solution vectors will be a separate PR. no point in cleaning up the C code until the second part has been done.

  • mention how to use this in main README
  • show how to use this in examples.md

@jwg4 jwg4 merged commit 56be1f4 into main Dec 1, 2023
48 checks passed
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.

2 participants