Skip to content

fix(problem): initialize Knapsack and ZDT5 bit storage - #190

Merged
cbarba merged 3 commits into
jMetal:mainfrom
sehejjain:fix/binary-initialization
Oct 20, 2026
Merged

cbarba merged 3 commits into
jMetal:mainfrom
sehejjain:fix/binary-initialization

Conversation

@sehejjain

Copy link
Copy Markdown
Contributor

Knapsack and ZDT5 generate random bits but write them into copies returned by BinarySolution.variables, leaving the stored bits false. Assign the sampled vectors through the existing setters so returned solutions contain the generated values, preserving the existing random sources and sampling calls.

Add six parameterized regression cases covering stored values through both RNG paths, the ZDT5 < 0.5 threshold, and zero-item Knapsack. The latter now returns an empty vector instead of raising IndexError. Record the correction under Unreleased in the changelog.

Validation on Python 3.12.15:

  • make lint passes.
  • make test: 1,119 passed.
  • All six new cases fail against unchanged production code and pass with the fix.

@cbarba
cbarba merged commit 8a4c1af into jMetal:main Oct 20, 2026
7 checks passed
@sehejjain
sehejjain deleted the fix/binary-initialization branch October 21, 2026 04:42
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