Skip to content

Commit 65e455e

Browse files
committed
Tighten solution comparison documentation
1 parent 08b56e6 commit 65e455e

4 files changed

Lines changed: 31 additions & 38 deletions

File tree

‎changelog.in‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,14 @@ Module: search
101101
What: change
102102
Rank: major
103103
[DESCRIPTION]
104-
Best-solution search now uses Space::compare() when choosing between
105-
independently produced solutions, including external incumbents and portfolio
106-
assets. Optimization spaces with a custom objective must override compare() as
107-
well as constrain(). compare() ranks solutions without changing them;
108-
constrain() still posts improvement restrictions. Comparability is defined by
109-
the model. The built-in floating-point models compare their documented
110-
objective bounds, independently of the improvement step. Current exact engines
111-
reject incomparable incoming solutions. A future best-effort policy could
112-
instead make an incomparable incoming solution current best, without changing
113-
the comparison interface, but that would not by itself guarantee completeness
114-
or maximality. Adding the virtual comparison function changes the C++ ABI of
104+
Best-solution search uses Space::compare() to choose between independently
105+
produced solutions, including external incumbents and portfolio assets.
106+
Optimization spaces with a custom objective must override compare() as well as
107+
constrain(). compare() ranks solutions without changing them; constrain() posts
108+
improvement restrictions. The model defines comparability. Built-in
109+
floating-point models compare their documented objective bounds independently
110+
of the improvement step. Current exact engines reject incomparable incoming
111+
solutions. Adding the virtual comparison function changes the C++ ABI of
115112
Space.
116113

117114
[RELEASE]

‎gecode/flatzinc.hh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,10 @@ namespace Gecode { namespace FlatZinc {
630630
* \brief Compare compatible optimization objectives
631631
*
632632
* Integer objectives compare assigned values. Float objectives require
633-
* the same direction and step, and assigned (possibly adjacent-endpoint)
634-
* intervals. Float minimization ranks lower endpoints and maximization
635-
* ranks upper endpoints, independently of the step used by constrain().
633+
* the same direction and step, and assigned intervals, which may span
634+
* adjacent float values. Float minimization ranks lower endpoints and
635+
* maximization ranks upper endpoints, independently of the step used by
636+
* constrain().
636637
*/
637638
virtual SpaceComparison compare(const Space& s) const;
638639
/// Compare this space with space \a s and print the differences on

‎gecode/kernel/core.hpp‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ namespace Gecode {
5656
/**
5757
* \brief Result of comparing two spaces according to their objectives
5858
*
59-
* Adding Space::compare changes the ordinary C++ ABI of Space by extending
60-
* its virtual function table.
59+
* Space::compare extends Space's virtual function table and changes its
60+
* C++ ABI.
6161
*/
6262
enum SpaceComparison {
6363
SC_BETTER, ///< The receiver has a better objective
@@ -2102,19 +2102,16 @@ namespace Gecode {
21022102
/**
21032103
* \brief Compare this space's objective with \a other
21042104
*
2105-
* The comparison is read-only and receiver-relative. Implementations may
2106-
* require objective information sufficient for the relation they report.
2107-
* The model owns this readiness rule: comparison does not require every
2108-
* objective variable to be assigned when the model can establish a sound
2109-
* result from the available information.
2105+
* The comparison is read-only and receiver-relative. The model defines
2106+
* the objective information needed for a sound result; not every objective
2107+
* variable must be assigned.
21102108
* The default implementation throws SpaceNoComparison.
21112109
* SC_INCOMPARABLE is a model-defined ordering result, not missing
21122110
* information. Current exact best-solution engines reject it.
21132111
*
21142112
* Optimization models overriding constrain with a different objective
2115-
* must also override compare.
2116-
* constrain remains responsible for posting improvement restrictions;
2117-
* search does not use it to rank two solutions.
2113+
* must also override compare. constrain posts improvement restrictions;
2114+
* search uses compare to rank solutions.
21182115
*
21192116
* Exact best-solution search requires SC_BETTER to be irreflexive and
21202117
* transitive, SC_WORSE to be its reverse, and SC_EQUIVALENT to be
@@ -2130,13 +2127,13 @@ namespace Gecode {
21302127
* float optimization spaces compare the incumbent bound used by their
21312128
* cuts: the upper bound for minimization and lower bound for maximization.
21322129
* This ranking is independent of the step used for approximate cuts.
2133-
* FlatZinc retains its interval-valued cuts and instead ranks the lower
2134-
* bound for minimization and upper bound for maximization.
2130+
* FlatZinc uses interval-valued cuts and ranks the lower bound for
2131+
* minimization and upper bound for maximization.
21352132
*
21362133
* After compare throws during BAB, PBS, or RBS search, destroy and
21372134
* recreate the public search engine. An internal engine interface that
21382135
* explicitly supports reset can establish a new search after failure;
2139-
* other post-exception use has no recovery guarantee.
2136+
* other use after an exception has no recovery guarantee.
21402137
*/
21412138
GECODE_KERNEL_EXPORT virtual SpaceComparison
21422139
compare(const Space& other) const;

‎gecode/search.hh‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,11 +1157,10 @@ namespace Gecode {
11571157
/**
11581158
* \brief Depth-first branch-and-bound search engine
11591159
*
1160-
* Additionally, \a s must implement Space::constrain and Space::compare.
1161-
* Whenever exploration requires to add a constraint
1162-
* to the space \a c currently being explored, the engine
1163-
* executes \c c.constrain(t) where \a t is the so-far
1164-
* best solution.
1160+
* Space \a s must implement Space::constrain and Space::compare.
1161+
* When exploration needs an improvement constraint, the engine calls
1162+
* \c c.constrain(t) on the current space \a c, where \a t is the best
1163+
* solution found so far.
11651164
* See Space::compare for the ordering and pruning requirements. If objective
11661165
* comparison throws, destroy the engine; only an internal engine interface
11671166
* that explicitly supports reset can establish a new search after failure.
@@ -1179,13 +1178,12 @@ namespace Gecode {
11791178
/**
11801179
* \brief Perform depth-first branch-and-bound search for subclass \a T of space \a s and options \a o
11811180
*
1182-
* Additionally, \a s must implement Space::constrain and Space::compare.
1183-
* Whenever exploration requires to add a constraint
1184-
* to the space \a c currently being explored, the engine
1185-
* executes \c c.constrain(t) where \a t is the so-far
1186-
* best solution.
1181+
* Space \a s must implement Space::constrain and Space::compare.
1182+
* When exploration needs an improvement constraint, the engine calls
1183+
* \c c.constrain(t) on the current space \a c, where \a t is the best
1184+
* solution found so far.
11871185
* See Space::compare for the ordering and pruning requirements. If objective
1188-
* comparison throws, destroy the engine rather than continuing to use it.
1186+
* comparison throws, destroy and recreate the engine.
11891187
*
11901188
* \ingroup TaskModelSearch
11911189
*/

0 commit comments

Comments
 (0)