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.
Partial of #9
This adds a solution handler that is called on newly encountered solutions (or improvements in optimization).
The search can not yet be stopped (more details below).
Parallelism
The reference implementation https://github.com/google/or-tools/blob/stable/ortools/sat/docs/solver.md?plain=1#L472 states
As mentioned in the ticket #9, it might be desirable to use
Fn
instead ofFnMut
. As I interpret the above that the search does not work in parallel anyway, it does not seem to matter whether we useFn
orFnMut
. The implementation right now usesFnMut
, but we can easily change that.ControlFlow
Now it gets weird. I have played around with this based on the reference implementation, but something very strange seems to happen with the C++ part.
Diff of potential approach for Control Flow
Problem: completely unrelated code starts to exibit SIGSEGV when
extra_model.GetOrCreate<operations_research::TimeLimit>()
is included.Minimal failing example that completely baffles me
E.g. the
tests/bool_cst.rs
starts to exhibit a SIGSEGV which does not use the newcp_sat_wrapper_solve_with_parameters_and_handler
but the unchangedcp_sat_wrapper_solve
. It seems to fail in theabsl
library inabsl/container/internal/raw_hash_set.h
in line 1562. It does not fail when using e.g.GetOrCreate<bool>()
, but fails usingTimeLimit
as the generic.I have no idea what is going on, how unrelated code can fail just because a (never used) function call is included in another function. Maybe some C++-magic of generics that affects the
Model
globally... Any ideas are appreciated.