[2] feat: add support for discrete problems#25
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds discrete optimization support (problems + Iterated Local Search sampler) alongside a refactor/expansion of continuous basin-hopping sampling, with accompanying tests to validate hashing behavior and function-evaluation counting.
Changes:
- Introduce a discrete optimization API (
DiscreteProblem), bitstring problems (OneMax, NumberPartitioning), and anILSSamplerthat produces LON-compatible trace data. - Add/expand continuous
BasinHoppingSamplerimplementation (now underlonkit.continuous.sampling) including solution hashing updates andcompute_lon. - Add tests for discrete problems and continuous hashing +
nfevcounting; update package exports/import paths.
Reviewed changes
Copilot reviewed 9 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/discrete/test_problems.py | Adds unit tests for OneMax and NumberPartitioning behavior. |
| tests/continuous/test_sampling.py | Tests hashing behavior, especially around rounding and -0.0 handling. |
| tests/continuous/test_nfev.py | Verifies nfev tracking via a counting wrapper. |
| src/lonkit/discrete/sampling.py | New ILS sampler + config/result types; emits LON-compatible trace data. |
| src/lonkit/discrete/problems/problem.py | Adds DiscreteProblem ABC (stateless, RNG-injected). |
| src/lonkit/discrete/problems/bitstring.py | Implements bitstring base class + OneMax and NumberPartitioning. |
| src/lonkit/discrete/problems/init.py | Exposes discrete problems API. |
| src/lonkit/discrete/init.py | Exposes discrete public API (problems + ILS sampler). |
| src/lonkit/continuous/step_size.py | Updates import path to the new continuous sampling module. |
| src/lonkit/continuous/sampling.py | Adds/defines basin-hopping sampling, hashing, trace building, and compute_lon. |
| src/lonkit/continuous/init.py | Exposes continuous public API (sampler, step size, compute_lon). |
| src/lonkit/init.py | Re-exports continuous + discrete APIs from top-level package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pFornagiel
reviewed
Mar 19, 2026
pFornagiel
reviewed
Mar 19, 2026
pFornagiel
reviewed
Mar 21, 2026
pFornagiel
reviewed
Mar 21, 2026
pFornagiel
reviewed
Mar 21, 2026
pFornagiel
reviewed
Mar 21, 2026
pFornagiel
approved these changes
Mar 22, 2026
Collaborator
pFornagiel
left a comment
There was a problem hiding this comment.
Some nitpicks, but otherwise looks good 🚀
Make sure to properly resolve conflicts before merging, though
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.
No description provided.