Skip to content

wasm: re-optimize the leftovers of a bin from the web page - #889

Merged
fontanf merged 1 commit into
masterfrom
wasm-reoptimize-leftovers
Nov 25, 2026
Merged

fontanf merged 1 commit into
masterfrom
wasm-reoptimize-leftovers

Conversation

@fontanf

@fontanf fontanf commented Nov 24, 2026

Copy link
Copy Markdown
Owner

The view of a bin of the web page gets a "Re-optimize the leftovers" button (rectangle, box, boxstacks and irregular). It packs the items of the bin again as a single-bin BinPackingWithLeftovers instance (reoptimize_bin_leftovers), and keeps the new solution if it is not worse and if its leftovers are better, as the leftover post-process does. The solution shown is replaced as soon as a better one is found, and the status shows the change of the total leftover value (or of the total staircase leftover value, if the leftover value is the same). The Stop button stops it.

The re-optimization uses the optimization mode and the time limit of the form, but "not-anytime" instead of "anytime": in anytime mode, it would run until the time limit.

Changes:

  • reoptimize_bin_leftovers passes the solutions found during the re-optimization to parameters.new_solution_callback, as solutions of the instance. The leftover post-process of optimize and reoptimize_non_last_bins_leftovers / reoptimize_all_bins_leftovers don't report them.
  • SolutionBuilder::read(std::istream&) (rectangle, box, boxstacks, irregular) reads a certificate from a stream.
  • WebAssembly module: Session.startReoptimizeBinLeftovers(problemType, instance, certificate, binPos, parameters). Its updates are the solutions with better leftovers than the given one and than the previous ones; the result has the solution, its certificate and whether the leftovers are better.
  • Worker: reoptimize-bin-leftovers message, answered with reoptimization-solution updates and a reoptimized message.
  • Viewer: binActions option, buttons in the view of a bin.
  • Fix: the results of the updates are computed when the session is polled, possibly after the end of the optimization, when the instance was already destroyed. The instance is now kept alive until then. It showed up as garbage lengths in the certificates of the re-optimization updates; the updates of the solve were exposed to it too.

The button is only shown when the instance of the solution is known: the projects exported and imported again don't keep it.

Tests: wasm/tests/reoptimize.test.js (a solution with better leftovers and its updates, each problem type, invalid bin, unsupported problem type, worker). The wasm tests and the unit tests of the four problem types pass. Checked in headless Chromium: the solution and the status are updated during the re-optimization.

The view of a bin of the web page gets a "Re-optimize the leftovers"
button (rectangle, box, boxstacks and irregular). It packs the items of
the bin again as a single-bin BinPackingWithLeftovers instance
('reoptimize_bin_leftovers'), and keeps the new solution if it is not
worse and if its leftovers are better, as the leftover post-process does.
The solution shown is replaced as soon as a better one is found.

- 'reoptimize_bin_leftovers' passes the solutions found during the
  re-optimization to 'parameters.new_solution_callback', as solutions of
  the instance. The leftover post-process and
  'reoptimize_non_last_bins_leftovers' / 'reoptimize_all_bins_leftovers'
  don't report them.
- 'SolutionBuilder::read(std::istream&)' reads a certificate from a stream.
- WebAssembly module: 'Session.startReoptimizeBinLeftovers(problemType,
  instance, certificate, binPos, parameters)'. Its updates are the
  solutions with better leftovers than the given one and than the previous
  ones.
- Worker: "reoptimize-bin-leftovers" message, answered with
  "reoptimization-solution" updates and a "reoptimized" message.
- Viewer: 'binActions', buttons in the view of a bin.
- The instance is kept alive until the results of the updates are
  computed: they may be computed after the end of the optimization.
@fontanf
fontanf merged commit 02b53ea into master Nov 25, 2026
8 checks passed
@fontanf
fontanf deleted the wasm-reoptimize-leftovers branch November 25, 2026 06:48
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.

1 participant