00001 #ifndef OPTFRAME_MOVE_HPP_
00002 #define OPTFRAME_MOVE_HPP_
00003
00004 #include "Solution.hpp"
00005 #include "Evaluation.hpp"
00006
00007 using namespace std;
00008
00009 template<class R, class M = OPTFRAME_DEFAULT_MEMORY>
00010 class Move
00011 {
00012 public:
00013
00014 virtual ~Move()
00015 {
00016 }
00017
00018 bool canBeApplied(const Solution<R>& s)
00019 {
00020 return canBeApplied(s.getR());
00021 }
00022
00023 bool canBeApplied(const Evaluation<M>& e, const Solution<R>& s)
00024 {
00025 return canBeApplied(e.getM(), s.getR());
00026 }
00027
00028 virtual bool canBeApplied(const R&) = 0;
00029
00030 virtual bool canBeApplied(const M& m, const R& r)
00031 {
00032 return canBeApplied(r);
00033 }
00034
00035 Move<R, M>& apply(Solution<R>& s)
00036 {
00037 return apply(s.getR());
00038 }
00039
00040 Move<R, M>& apply(Evaluation<M>& e, Solution<R>& s)
00041 {
00042 return apply(e.getM(), s.getR());
00043 }
00044
00045 virtual Move<R, M>& apply(R& r) = 0;
00046
00047 virtual Move<R, M>& apply(M& m, R& r)
00048 {
00049 return apply(r);
00050 }
00051
00052 virtual bool operator==(const Move<R, M>& m) const = 0;
00053
00054 bool operator!=(const Move<R, M>& m) const
00055 {
00056 return !(*this == m);
00057 }
00058
00059 virtual void print() = 0;
00060 };
00061
00062 #endif