A search algorithm can find a feasible incumbent early in the search and then spend a long time without improving it. The next improvement may be worth the wait, or the remaining computation may be more valuable elsewhere. Deciding when to stop is itself an optimization problem.
For an application that repeatedly solves binary quadratic models, this question deserves the same care as the choice of algorithm. The computation has a cost; the value of an improved solution depends on the decision being made.
What an incumbent tells us
For a maximization problem, the incumbent is the best feasible solution found so far. Its objective value is nondecreasing: it increases when a better feasible solution is accepted and otherwise remains unchanged. A progress curve drawn from incumbents is therefore a nondecreasing step function for a single uninterrupted search with a fixed objective. A minimization curve moves in the opposite direction.
A flat section tells us that the reported incumbent has not improved during that interval. It does not determine the quality of the next solution or the distance to the optimum. An algorithm can be exploring a new region of the search space without finding an improvement that is immediately visible in its incumbent stream.
Compare progress at a common target
A valid bound can quantify how much improvement is still possible. For example, in a minimization problem with incumbent 12 and a valid lower bound of 10, at most two objective units remain to be gained. Without a bound, a best-known reference describes a comparison, rather than certifying the remaining gap.
For time-to-target comparisons, define the objective target before measuring the algorithms. A run that does not reach it within its budget is censored; do not treat its budget as the observed attainment time. Before a feasible result exists, record the elapsed time without assigning an objective value to the curve.
Two identical beginnings
Consider two illustrative search traces with the same early improvement. Both remain flat for a while. In one trace the search ends without another gain; in the other a later improvement is followed by a further improvement. A rule that stops after a fixed number of seconds without a gain makes the same decision for both traces up to the stopping time.
The following example evaluates that rule on these synthetic trajectories. A separate calculation assigns a hypothetical value to each unit of objective improvement and a cost per second of search. Both quantities are in the same arbitrary value units. In practice they need to be chosen for the application, rather than inferred from the solver's objective alone.
Illustration: standalone Python calculation.
flat = [(0,90),(5,100)]
late = [(0,90),(5,100),(22,110),(28,115)]
limit, patience = 30, 10
def value_at(events,t):
return max(v for s,v in events if s <= t)
def stop_time(events,patience,limit):
last = events[0][0]
for t,_ in events[1:]:
if t >= last+patience:
return min(last+patience,limit)
last = t
return min(last+patience,limit)
for trace in (flat,late):
t = stop_time(trace,patience,limit)
assert t == 15 and value_at(trace,t) == 100
assert value_at(flat,limit) == 100
assert value_at(late,limit) == 115
cost = 0.5
for trace in (flat,late):
t = stop_time(trace,patience,limit)
print('Stop vs full net value:', value_at(trace,t)-cost*t,
value_at(trace,limit)-cost*limit) With a cost of 0.5 per second, stopping at 15 seconds gives the better net value for the flat trace (92.5 against 85) and the worse one for the late trace (92.5 against 100). The examples show why a retrospective optimum for the stopping time is not an implementable rule: it uses knowledge of future improvements. A prospective policy can use only information that is available at the time of the decision.
Choose the stopping condition from the application
A hard deadline is often appropriate when another operation must begin by a fixed time. An objective threshold is useful if a feasible solution above that threshold satisfies the application's needs. A mathematical bound can provide a more direct stopping condition when it certifies that the remaining possible improvement is small enough. A fixed period without a gain is another option, but its usefulness depends on how the algorithm behaves on the relevant instance family.
A sensible evaluation uses a set of representative instances and multiple runs. Record incumbent values and their timestamps, the status of each final result and the objective achieved at the selected stopping time. Compare candidate rules on the same complete recorded traces as an initial offline exercise. Test promising rules prospectively on fresh instances, because terminating a job and observing a complete search are different execution paths.
Measure elapsed time and computational cost as separate quantities. Check how result reporting, polling and cancellation affect the timestamps seen by the application. If a bound is available, record it alongside the incumbent. Preserve the actual returned solution so that it can be checked independently before it is used.
Search time as a decision
A search policy can differ by workload. A planning application may prefer an immediate feasible answer followed by improvements while a planner reviews it. A research experiment may prefer a fixed, repeatable budget. In both cases the stopping condition should serve the purpose of the computation.
The 4colors Optimizer for QUBO lets you investigate binary optimization models with a chosen computation budget. Evaluate that budget against the decisions for which you intend to use the results.