00001 #ifndef EVALUATEMODULE_HPP_
00002 #define EVALUATEMODULE_HPP_
00003
00004 #include "../OptFrameModule.hpp"
00005
00006 template<class R, class M>
00007 class EvaluateModule: public OptFrameModule<R, M>
00008 {
00009 public:
00010 string id()
00011 {
00012 return "evaluate";
00013 }
00014 string usage()
00015 {
00016 string u = "evaluate ev id loadsol id";
00017 return u;
00018 }
00019
00020 void run(vector<OptFrameModule<R, M>*> all_modules, HeuristicFactory<R, M>* factory, map<string, string>* dictionary, string input)
00021 {
00022 cout << "evaluate: " << input << endl;
00023 Scanner scanner(input);
00024
00025 if (!scanner.hasNext())
00026 {
00027 cout << "Usage: " << usage() << endl;
00028 return;
00029 }
00030
00031 Evaluator<R, M>* eval = factory->read_ev(&scanner);
00032
00033 string sol = scanner.next();
00034
00035 if (sol != "loadsol")
00036 {
00037 cout << "Second parameter must be a 'loadsol'!" << endl;
00038 cout << "Usage: " << usage() << endl;
00039 return;
00040 }
00041
00042 string id = scanner.next();
00043
00044 Scanner s2(sol + " " + id);
00045 Solution<R>* s = factory->read_loadsol(&s2);
00046
00047 Evaluation<M>* e = &eval->evaluate(*s);
00048 e->print();
00049
00050 delete e;
00051 }
00052
00053 };
00054
00055 #endif