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

Cannot find a solution when particular limits are given #23

Merged
merged 2 commits into from
Oct 5, 2021
Merged

Conversation

kotarot
Copy link
Owner

@kotarot kotarot commented Oct 3, 2021

Thanks to Magnus's issue reporting!

To reproduce the issue

problem = rps.Problem(rectangles=[
    {"width": 5, "height": 7, "rotatable": True},
    {"width": 5, "height": 7, "rotatable": True},
    {"width": 5, "height": 7, "rotatable": True},
    {"width": 5, "height": 7, "rotatable": True},
    {"width": 5, "height": 7, "rotatable": True},
])
# when height_limit is less than 19, the issue occurs
solution = rps.Solver().solve(problem=problem, width_limit=17, height_limit=18)

The cause of the issue

A bug in the solver.

At each step of the annealing process, the solution was immediately rejected if it did not satisfy the constraints, and thus the solver was stuck in an infinite loop without reaching a valid solution.

How to resolve the issue

Solutions that does not satisfy the constraints can be allowed in the earlier annealing steps, and the constraints will eventually satisfied in the final step.

I'll release a next version in a few days.

@codecov
Copy link

codecov bot commented Oct 3, 2021

Codecov Report

Merging #23 (4ee8218) into main (32a28f1) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
- Coverage   92.13%   92.10%   -0.03%     
==========================================
  Files           8        8              
  Lines         267      266       -1     
==========================================
- Hits          246      245       -1     
  Misses         21       21              
Flag Coverage Δ
unittests 92.10% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rectangle_packing_solver/solver.py 97.18% <100.00%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32a28f1...4ee8218. Read the comment docs.

@kotarot
Copy link
Owner Author

kotarot commented Oct 5, 2021

Will merge.

@kotarot kotarot merged commit 9d6343a into main Oct 5, 2021
@kotarot kotarot deleted the fix-limits branch October 5, 2021 14:50
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.

None yet

1 participant