If we manage to reach a 0 cost early, stop the annealer, there is no point

looking any further.  This significantly reduces the timeslot scheduling time.
In most cases we reach 0 in a couple thousand iterations, but we need high
effort because some timeslot scheduling problems are hard to assign.
This commit is contained in:
dave 2006-08-12 08:07:02 +00:00
parent c247119663
commit 145c6f88ff

View File

@ -228,7 +228,8 @@ class annealer {
$current_cost += $delta_c; $current_cost += $delta_c;
$n_accepted++; $n_accepted++;
// if($current_cost < $this->cost) // if($current_cost < $this->cost)
$this->cost = $current_cost; $this->cost = $current_cost;
// TRACE("Move accepted, cost=$current_cost\n"); // TRACE("Move accepted, cost=$current_cost\n");
} else { } else {
// TRACE("Move rejected\n"); // TRACE("Move rejected\n");
@ -238,7 +239,16 @@ class annealer {
TRACE(" {$this->iterations} iterations, cost={$this->cost}, temperature=$temperature\n"); TRACE(" {$this->iterations} iterations, cost={$this->cost}, temperature=$temperature\n");
// $this->print_buckets(); // $this->print_buckets();
} }
if($this->cost == 0) {
/* If we manage to get to a 0 cost
* solution, don't look any more */
break;
}
} }
if($this->cost == 0) break;
if($this->cost == $last_cost) { if($this->cost == $last_cost) {
$last_cost_count ++; $last_cost_count ++;
} else { } else {