1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/akos/simann_test.cc Wed Sep 29 10:35:35 2004 +0000
1.3 @@ -0,0 +1,39 @@
1.4 +#include "SimAnn.h"
1.5 +#include <cstdlib>
1.6 +#include <cmath>
1.7 +#include <iostream>
1.8 +
1.9 +class MyController : public SimAnnBase::Controller {
1.10 +public:
1.11 + long MaxIter, MaxNoImpr;
1.12 + double af;
1.13 + MyController() {
1.14 + MaxIter = 500000;
1.15 + MaxNoImpr = 20000;
1.16 + af = 0.9999;
1.17 + T = 1000;
1.18 + }
1.19 + bool next() {
1.20 + T *= af;
1.21 + std::cout << T << std::endl;
1.22 + return !((sab->getIter() > MaxIter) || (sab->getIter() - sab->getLastImpr() > MaxNoImpr));
1.23 + }
1.24 + bool accept(double cost) {
1.25 + return (drand48() <= exp(cost / T));
1.26 + }
1.27 +};
1.28 +
1.29 +class MyEntity {
1.30 +public:
1.31 + void init() {}
1.32 + double mutate() { return 10.0; }
1.33 +};
1.34 +
1.35 +int main() {
1.36 + SimAnn<MyEntity> sa;
1.37 + MyController c;
1.38 + sa.setController(c);
1.39 + MyEntity ent;
1.40 + sa.setEnt(ent);
1.41 + sa.run();
1.42 +}