📄 uofsolution.h
字号:
#ifndef _UOFSOLUTION_
#define _UOFSOULTION_
#include "UOFId.h"
#include "UOFInitializer.h"
#include "UOFEvaluator.h"
#include <ostream>
#include <vector>
#include <iostream>
#include <ctime>
using namespace std;
//! Basic Solution class
/*! Users should overrides this class if you define a new solver*/class UOFSolution : public UOFId
{
public:
UOFIdentity("UOF class",1);
public:
//! A constructor that generates a object with initialization.
/*!
\param init the pointer of initializer.
\param eval the pointer of evaluator.
*/ UOFSolution(UOFInitializer *init, UOFEvaluator *eval);
//! A constructor that generates a object and copy the data from another one.
/*! This constructor generates a object and copy the data from another one.
*/ UOFSolution(const UOFSolution&);
//! Assign operator
/*! This operator overloads the "=" operation
*/ UOFSolution& operator=(const UOFSolution&); virtual ~UOFSolution();
//! Generate a clone
/*! This function return a pointer of a solution that is identical to this solution
*/ virtual UOFSolution* clone() const;
//! copy function
/*! This is an abstract function, User must override this function to work.
This function copy the input solution to this solution
*/ virtual void copy(const UOFSolution&);
//! Returns the evaluated score
/*! This function calls the evaluator to measure a score for this solution.
*/ virtual double score()
{
m_score = (*m_pEval)(this);
return m_score;
}
//! Get the score of this solution
/*! This function return the evaluated score of this solution
*/ double GetScore(){return m_score;} //! Output this solution
/*! This is an virtual function, User must override this function to work.
This function output this solution to the input ostream. Users can override this function to output the
information necessary to be displayed.
*/ virtual void PrintSelf(ostream&){}
//! Get the pointer of the current initializer
/*! This function return the pointer of the current initializer
*/ UOFInitializer* GetInit(){return m_pInit;}
//! Get the pointer of the current evaluator
/*! This function return the pointer of the current evaluator
*/ UOFEvaluator* GetEval(){return m_pEval;}
//! SelfInit initialize this solution through the initializer
/*! This is an virtual function, User must override this function to work.
This function initialize this solution through the initializer
*/ virtual void SelfInit(){}protected: double m_score; /**< the score of this solution */
UOFInitializer *m_pInit; /**< the pointer of the initializer of the parameters */
UOFEvaluator *m_pEval; /**< the pointer of the evaluator of the problem */
};
inline ostream& operator <<(ostream& os, UOFSolution& s){s.PrintSelf(os); return os;}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -