Changeset 99
- Timestamp:
- 02/06/09 00:14:35 (3 years ago)
- Location:
- trunk/samples
- Files:
-
- 2 modified
-
knapsack/src/main.cc (modified) (9 diffs)
-
qap/src/main.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/samples/knapsack/src/main.cc
r91 r99 324 324 { 325 325 public: 326 knapsack_moves( int maxmoves, int maxswaps, int doubleswaps)326 knapsack_moves(mt19937& r, int maxmoves, int maxswaps, int doubleswaps) 327 327 : mets::move_manager(), 328 rng( ), // use predefined seed for results replication328 rng(r), // use predefined seed for results replication 329 329 int_range(0), 330 330 mm(maxmoves), … … 383 383 size() const {return moves_m.size(); } 384 384 protected: 385 mt19937 rng;385 mt19937& rng; 386 386 uniform_int<> int_range; 387 387 int mm; … … 394 394 { 395 395 public: 396 knapsack_all_moves( )397 : mets::move_manager(), rng( ) {}396 knapsack_all_moves(mt19937& r) 397 : mets::move_manager(), rng(r) {} 398 398 399 399 ~knapsack_all_moves() … … 432 432 size() const {return moves_m.size(); } 433 433 protected: 434 mt19937 rng;434 mt19937& rng; 435 435 }; 436 436 … … 538 538 knapsack best(start); 539 539 540 #if 0 540 541 stupid_listener printer(optimal, graph); 541 542 542 543 // 500 set moves max, 1000 swaps and 0 double swaps 543 knapsack_moves km1( min(ks.size(), 500), 1000, 0);544 knapsack_moves km1(rng, min(ks.size(), 500), 1000, 0); 544 545 545 546 // a simple tabu list … … 576 577 } 577 578 578 knapsack_moves km2( min(ks.size(), 1500), 3000, 500);579 knapsack_moves km2(rng, min(ks.size(), 1500), 3000, 500); 579 580 noimprove_termination_criteria nitc2(min(ks.size(), 2000)); 580 581 // resize and keep the same tabu list … … 587 588 cout << "end of TS phase 2: " << -ts2.best().cost_function() << '\n'; 588 589 589 knapsack_moves km3( min(ks.size(), 4000), 7500, 2500);590 knapsack_moves km3(rng, min(ks.size(), 4000), 7500, 2500); 590 591 // resize and keep the same tabu list 591 592 tabus.tenure(7); … … 601 602 solution << dynamic_cast<const knapsack&>(ts3.best()) << endl; 602 603 604 #endif 603 605 //////////////////////////////////////////////////////////////////////// 604 606 // SIMULATED ANNEALING … … 612 614 613 615 // NOTE: SA should use all the neighborhood i.e. knapsack_all_moves 614 knapsack_moves kam( min(ks.size(), 5000), 20000, 10000);615 616 exponential_cooling scs(0.9 992);616 knapsack_moves kam(rng, min(ks.size(), 5000), 20000, 10000); 617 618 exponential_cooling scs(0.98); 617 619 618 620 // This is not strictly SA: 619 // TODO: add a termination criteria based on temperature 620 noimprove_termination_criteria saitc(5000); 621 622 mets::simulated_annealing sa(saks, sabest, kam, saitc, scs, 623 1800*ks.size(), 1e-10); 621 // noimprove_termination_criteria saitc(5000); 622 sa_cooled satc(/*&saitc,*/ 1e-12); 623 mets::simulated_annealing sa(saks, sabest, kam, satc, scs, 624 1800*ks.size(), 1e-23, rng); 624 625 sa.attach(saprinter); 625 626 sa.search(); -
trunk/samples/qap/src/main.cc
r92 r99 46 46 mets::best_ever_criteria aspiration_criteria; 47 47 mets::noimprove_termination_criteria termination_criteria 48 (std::min(N*N*10, 7500));48 (std::min(N*N*10, 15000)); 49 49 50 50 // the search algorithm

