Skip to content

feat: Add logging for branchers - #135

Merged
maartenflippo merged 9 commits into
developfrom
feat/brancher-statistics
Apr 9, 2025
Merged

maartenflippo merged 9 commits into
developfrom
feat/brancher-statistics

Conversation

@ImkoMarijnissen

Copy link
Copy Markdown
Contributor

Currently, we only log statistics for propagators; however, it also makes sense to do this for branchers.

This PR proposes to add an additional method to the interface which logs statistics for branchers. A use-case is shown for our implementation of autonomous search.

@maartenflippo maartenflippo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried that the statistics are now overwhelming. Turning on statistics will flood the terminal with stats. Should we consider somehow grouping them to turn on specific statistics?

pub enum IteratedSolution<'a> {
/// A new solution was identified.
Solution(Solution, &'a Solver),
Solution(Solution, &'a Solver, &'a dyn Brancher),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use dyn here? In all the other solve results we are generic over Brancher.

Comment thread pumpkin-solver/src/api/solver.rs Outdated
pub fn optimise<Var: IntegerVariable, Callback: Fn(&Solver, SolutionReference)>(
pub fn optimise<
Var: IntegerVariable,
Callback: Fn(&Solver, SolutionReference, &dyn Brancher),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why dyn here? If we explicitly make a generic for impl Brancher then we can re-use that type in the signature here.

Comment thread pumpkin-solver/src/optimisation/mod.rs Outdated
pub mod linear_unsat_sat;

pub trait OptimisationProcedure<Var: IntegerVariable, Callback: Fn(&Solver, SolutionReference)> {
pub trait OptimisationProcedure<

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the generics here? They do not seem to be used in any of the function signatures.

Comment thread pumpkin-solver/src/api/solver.rs Outdated
/// It returns an [`OptimisationResult`] which can be used to retrieve the optimal solution if
/// it exists.
pub fn optimise<Var: IntegerVariable, Callback: Fn(&Solver, SolutionReference)>(
pub fn optimise<

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to where clause

}

fn solution_callback(
brancher: &dyn Brancher,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not impl Brancher

Some(FlatzincObjective::Minimize(domain_id)) => {
(OptimisationDirection::Minimise, domain_id)
Some(objective) => {
let result: (OptimisationDirection, DomainId) = objective.into();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can trait bound be moved to variable?


impl<Var: IntegerVariable, Callback: Fn(&Solver, SolutionReference)>
OptimisationProcedure<Var, Callback> for LinearUnsatSat<Var, Callback>
impl<Var: IntegerVariable, B: Brancher, Callback: Fn(&Solver, SolutionReference, &B)>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to where clause

@ImkoMarijnissen

Copy link
Copy Markdown
Contributor Author

Create a SolutionCallback class; we have a blanket implementation for Fn (and Option<T> where T: SolutionCallback

@maartenflippo maartenflippo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments from our discussion

@maartenflippo
maartenflippo force-pushed the feat/brancher-statistics branch from b6de828 to 130df6c Compare April 9, 2025 12:16
@maartenflippo
maartenflippo merged commit 58285e8 into develop Apr 9, 2025
@maartenflippo
maartenflippo deleted the feat/brancher-statistics branch April 9, 2025 12:34
maartenflippo added a commit that referenced this pull request Apr 11, 2025
Currently, we only log statistics for propagators; however, it also
makes sense to do this for branchers.

This PR proposes to add an additional method to the interface which logs
statistics for branchers. A use-case is shown for our implementation of
autonomous search.

---------

Co-authored-by: Maarten Flippo <[email protected]>
maartenflippo added a commit that referenced this pull request Apr 11, 2025
Currently, we only log statistics for propagators; however, it also
makes sense to do this for branchers.

This PR proposes to add an additional method to the interface which logs
statistics for branchers. A use-case is shown for our implementation of
autonomous search.

---------

Co-authored-by: Maarten Flippo <[email protected]>
ImkoMarijnissen added a commit that referenced this pull request Apr 11, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.2.0](pumpkin-solver-v0.1.4...pumpkin-solver-v0.2.0)
(2025-04-11)


### Features

* Add logging for branchers
([#135](#135))
([d8814f1](d8814f1))
* Add method for retrieving relevant brancher events
([#138](#138))
([8253580](8253580))
* Adding lower-bounding search to the solver
([#132](#132))
([57bde78](57bde78))
* Adding random variable selector + sparse_set fixes
([#139](#139))
([1c4b85f](1c4b85f))
* Debug clone does not synchronise at level 0 + random splitter edge
cases ([#146](#146))
([bba1abb](bba1abb))
* Enable proof logging in appropriate test cases
([#154](#154))
([914f1bc](914f1bc))
* Expose the optimisation API in the python wrapper
([#148](#148))
([ab9a463](ab9a463))
* Flatzinc parse boolean & negative int arrays as well
([#142](#142))
([68aef75](68aef75))
* Improve element propagator
([#140](#140))
([b9bcfd3](b9bcfd3))
* Lazy explanation context
([#123](#123))
([0781357](0781357))
* No additional variables during constraint construction
([#131](#131))
([19dd45b](19dd45b))
* Nemove explicit literals
([#115](#115))
([ab74e20](ab74e20))
* Stateful integer
([#125](#125))
([eb01ed3](eb01ed3))


### Bug Fixes

* Addressing clippy warnings
([#143](#143))
([20c76bb](20c76bb))
* Allow reification of lazy reasons
([#152](#152))
([c7418ec](c7418ec))
* Also log the inference that led to an empty domain
([#165](#165))
([7799119](7799119))
* Alternating brancher did not call the methods correctly
([#128](#128))
([6019d86](6019d86))
* Disjunctive scheduling example had incorrect negation constraint
([#114](#114))
([fd007a0](fd007a0))
* Don't debug propagate deleted nogoods
([#147](#147))
([e3a6527](e3a6527))
* Explain root-level assignments in the proof log during conflict
analysis ([#163](#163))
([c877b06](c877b06))
* Fixing erronous conflict check when using incrementality
([#137](#137))
([07c253f](07c253f))
* Give reason to root-level propagation in nogood propagator
([#124](#124))
([14868d5](14868d5))
* Identify more places where root-level facts need to be logged to the
proof ([#153](#153))
([3ac5019](3ac5019))
* Issue with integer multiplication + correct path in msc file
([#117](#117))
([ce25710](ce25710))
* Post process new domain
([#129](#129))
([26a3b46](26a3b46))
* Print statistics at the end of solving process + make pumpkin-solver
default bin ([#162](#162))
([7d30ac8](7d30ac8))
* Remove paste dependency
([#159](#159))
([ea53fed](ea53fed))
* Root level assignments are properly explained in the proof when
logging inferences
([#158](#158))
([857f84c](857f84c)),
closes [#118](#118)
[#119](#119)
[#156](#156)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: ImkoMarijnissen <[email protected]>
@lmmx lmmx mentioned this pull request Apr 11, 2025
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