20 #include <boost/shared_ptr.hpp> 27 using boost::filesystem::path;
29 template <
class InstanceType>
40 InstanceType
optimize(InstanceType startInstance)
45 InstanceType selectedInstance = startInstance;
46 InstanceType bestInstance = startInstance;
48 double lowestCost = this->
mCostFunction->calculateCost(bestInstance);
49 bool keepOptimizing =
true;
51 while (keepOptimizing)
53 keepOptimizing =
false;
56 double selectedInstanceCost = this->
mCostFunction->calculateCost(selectedInstance);
64 double nextInstanceCost = this->
mCostFunction->calculateCost(nextInstance);
68 keepOptimizing =
true;
69 selectedInstance = nextInstance;
72 if (nextInstanceCost < lowestCost)
74 bestInstance = nextInstance;
75 lowestCost = nextInstanceCost;
98 template<
class InstanceType>
boost::shared_ptr< RecordHuntAlgorithm< InstanceType >> RecordHuntAlgorithmPtr
boost::shared_ptr< CostFunction< InstanceType >> CostFunctionPtr
boost::shared_ptr< AcceptanceFunction > AcceptanceFunctionPtr
CostFunctionPtr< InstanceType > mCostFunction
NeighbourhoodFunctionPtr< InstanceType > mNeighbourhoodFunction
boost::shared_ptr< NeighbourhoodFunction< InstanceType >> NeighbourhoodFunctionPtr
this namespace contains all generally usable classes.
RecordHuntAlgorithm(NeighbourhoodFunctionPtr< InstanceType > neighbourhoodFunction, CostFunctionPtr< InstanceType > costFunction, AcceptanceFunctionPtr acceptanceFunction)
AcceptanceFunctionPtr mAcceptanceFunction
InstanceType optimize(InstanceType startInstance)