|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Tracks the best solution seen so far according to a comparator. More...
#include <state_search_common.H>
Public Types | |
| using | Solution_Type = Solution |
| Type of stored solutions. | |
| using | Compare_Type = Compare |
| Type of the comparison policy. | |
Public Member Functions | |
| BestSolution ()=default | |
| Build an empty incumbent tracker. | |
| BestSolution (Compare compare) | |
| Build a tracker with a custom comparator. | |
| bool | has_value () const noexcept |
Return true if an incumbent exists. | |
| void | clear () noexcept |
| Remove the stored incumbent, if any. | |
| const Solution & | get () const |
| Read the current incumbent. | |
| Solution & | get () |
| Mutable access to the current incumbent. | |
| const Compare & | compare () const noexcept |
| Access the ordering functor used by this incumbent. | |
| bool | consider (const Solution &candidate) |
| Consider a candidate by copy. | |
| bool | consider (Solution &&candidate) |
| Consider a candidate by move. | |
Private Attributes | |
| Compare | compare_ = {} |
| std::optional< Solution > | current_ |
Tracks the best solution seen so far according to a comparator.
The first candidate is always accepted. Later candidates replace the stored incumbent only if compare(candidate, incumbent) returns true.
| Solution | Type of solution to track. |
| Compare | Binary predicate used to order solutions. |
Definition at line 458 of file state_search_common.H.
| using Aleph::BestSolution< Solution, Compare >::Compare_Type = Compare |
Type of the comparison policy.
Definition at line 464 of file state_search_common.H.
| using Aleph::BestSolution< Solution, Compare >::Solution_Type = Solution |
Type of stored solutions.
Definition at line 462 of file state_search_common.H.
|
default |
Build an empty incumbent tracker.
|
inlineexplicit |
Build a tracker with a custom comparator.
| compare | Functor used to decide which solution is better. |
Definition at line 472 of file state_search_common.H.
|
inlinenoexcept |
Remove the stored incumbent, if any.
Definition at line 484 of file state_search_common.H.
References Aleph::BestSolution< Solution, Compare >::current_.
|
inlinenoexcept |
Access the ordering functor used by this incumbent.
Definition at line 510 of file state_search_common.H.
References Aleph::BestSolution< Solution, Compare >::compare_.
|
inline |
Consider a candidate by copy.
true if the incumbent was updated. Definition at line 518 of file state_search_common.H.
References Aleph::BestSolution< Solution, Compare >::compare_, Aleph::BestSolution< Solution, Compare >::current_, and Aleph::divide_and_conquer_partition_dp().
Referenced by Aleph::ida_star_detail::dfs(), Aleph::Depth_First_Backtracking< Domain >::dfs(), Aleph::Depth_First_Backtracking< Domain >::dfs_visited(), and TEST().
|
inline |
Consider a candidate by move.
true if the incumbent was updated. Definition at line 532 of file state_search_common.H.
References Aleph::BestSolution< Solution, Compare >::compare_, Aleph::BestSolution< Solution, Compare >::current_, and Aleph::divide_and_conquer_partition_dp().
|
inline |
Mutable access to the current incumbent.
| std::runtime_error | if no incumbent has been stored yet. |
Definition at line 502 of file state_search_common.H.
References ah_runtime_error_unless, and Aleph::BestSolution< Solution, Compare >::current_.
|
inline |
Read the current incumbent.
| std::runtime_error | if no incumbent has been stored yet. |
Definition at line 492 of file state_search_common.H.
References ah_runtime_error_unless, and Aleph::BestSolution< Solution, Compare >::current_.
Referenced by TEST().
|
inlinenoexcept |
Return true if an incumbent exists.
Definition at line 478 of file state_search_common.H.
References Aleph::BestSolution< Solution, Compare >::current_.
Referenced by Aleph::SearchResult< Solution, Compare >::found_solution(), and TEST().
|
private |
Definition at line 544 of file state_search_common.H.
Referenced by Aleph::BestSolution< Solution, Compare >::compare(), Aleph::BestSolution< Solution, Compare >::consider(), and Aleph::BestSolution< Solution, Compare >::consider().
|
private |
Definition at line 545 of file state_search_common.H.
Referenced by Aleph::BestSolution< Solution, Compare >::clear(), Aleph::BestSolution< Solution, Compare >::consider(), Aleph::BestSolution< Solution, Compare >::consider(), Aleph::BestSolution< Solution, Compare >::get(), Aleph::BestSolution< Solution, Compare >::get(), and Aleph::BestSolution< Solution, Compare >::has_value().