alpar@1956: /* -*- C++ -*- alpar@1956: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@2553: * Copyright (C) 2003-2008 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1956: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@1956: * alpar@1956: * Permission to use, modify and distribute this software is granted alpar@1956: * provided that this copyright notice appears in all copies. For alpar@1956: * precise terms see the accompanying LICENSE file. alpar@1956: * alpar@1956: * This software is provided "AS IS" with no warranty of any kind, alpar@1956: * express or implied, and with no claim as to its suitability for any alpar@1956: * purpose. alpar@1956: * alpar@1956: */ alpar@1956: ladanyi@1921: #include ladanyi@1921: ladanyi@1921: using namespace lemon; ladanyi@1921: ladanyi@1921: class MyEntity : public EntityBase { ladanyi@1921: public: ladanyi@1921: double d, prev_d; deba@2242: MyEntity() : d(100000.0) {} ladanyi@1921: double mutate() { ladanyi@1921: prev_d = d; deba@2242: if (rnd.boolean(0.8)) { d += 1.0; } ladanyi@1921: else { d -= 1.0; } ladanyi@1921: return d; ladanyi@1921: } ladanyi@1921: void revert() { d = prev_d; } ladanyi@1921: MyEntity* clone() { return new MyEntity (*this); } ladanyi@1921: void randomize() {} ladanyi@1921: }; ladanyi@1921: ladanyi@1921: int main() { ladanyi@1921: SimAnn simann; ladanyi@1921: SimpleController ctrl; ladanyi@1921: simann.setController(ctrl); ladanyi@1921: MyEntity ent; ladanyi@1921: simann.setEntity(ent); ladanyi@1921: simann.run(); ladanyi@1921: ladanyi@1921: //MyEntity *best_ent = (MyEntity *) simann.getBestEntity(); ladanyi@1921: //std::cout << best_ent->d << std::endl; ladanyi@1921: ladanyi@1921: SimAnn simann2; ladanyi@1921: AdvancedController ctrl2(2.0); ladanyi@1921: simann2.setController(ctrl2); ladanyi@1921: MyEntity ent2; ladanyi@1921: simann2.setEntity(ent2); ladanyi@1921: simann2.run(); ladanyi@1921: ladanyi@1921: //MyEntity *best_ent2 = (MyEntity *) simann2.getBestEntity(); ladanyi@1921: //std::cout << best_ent2->d << std::endl; ladanyi@1921: ladanyi@1921: return 0; ladanyi@1921: }