- Main Page
- Classes
- Files

- File List

# OptFrame/Evaluation.hpp

    00001 #ifndef OPTFRAME_EVALUATION_HPP_
    00002 #define OPTFRAME_EVALUATION_HPP_
    00003
    00004 typedef int OPTFRAME_DEFAULT_MEMORY;
    00005
    00006 #include <cstdlib>
    00007 #include <iostream>
    00008
    00009 using namespace std;
    00010
    00011 template<class M = OPTFRAME_DEFAULT_MEMORY>
    00012 class Evaluation
    00013 {
    00014 protected:
    00015         M& m;
    00016         double objFunction;
    00017         double infMeasure;
    00018
    00019 public:
    00020         Evaluation(double obj, double inf, M& mm):
    00021                 objFunction(obj),infMeasure(inf),m(*new M(mm)){};
    00022
    00023         Evaluation(double obj, M& mm):
    00024                 objFunction(obj),m(*new M(mm)){ infMeasure=0; };
    00025
    00026         Evaluation(const Evaluation<M>& e):
    00027                 m(*new M(e.m)),objFunction(e.objFunction),infMeasure(e.infMeasure){};
    00028
    00029         virtual ~Evaluation() { delete &m; }
    00030
    00031         const M& getM() const { return m; }
    00032         M& getM() { return m; }
    00033         double getObjFunction() const { return objFunction; }
    00034         double getInfMeasure() const  { return infMeasure;  }
    00035
    00036         void setM(const M& mm){ m = mm; }
    00037         void setObjFunction(double obj){ objFunction = obj; }
    00038         void setInfMeasure (double inf){ infMeasure = inf;  }
    00039
    00040         virtual double evaluation() const { return objFunction + infMeasure; }
    00041         virtual bool   isFeasible() const { return (infMeasure == 0); }
    00042
    00043         virtual void print() const
    00044         {
    00045                 cout << "Evaluation function value = " << evaluation();
    00046                 cout << (isFeasible()?" ":" (not feasible) ") << endl;
    00047
    00048                 // default - not printing memory
    00049                 // cout << m << endl;
    00050         }
    00051
    00052         virtual Evaluation& operator= (const Evaluation& e)
    00053         {
    00054                 if(&e == this) // auto ref check
    00055                         return *this;
    00056
    00057                 m = e.m;
    00058                 objFunction = e.objFunction;
    00059                 infMeasure = e.infMeasure;
    00060
    00061                 return *this;
    00062         }
    00063
    00064         virtual Evaluation<M>& clone() const
    00065         {
    00066                 return * new Evaluation<M>(*this);
    00067         }
    00068 };
    00069
    00070 #endif /*OPTFRAME_EVALUATION_HPP_*/

All Classes Functions