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