Commit c029470a authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[lto_rao] Computed the costs between all the files

parent c13af0b6
......@@ -46,6 +46,10 @@ FilePositionInfos RAOFile::getFilePositionInfos() const{
return m_filePositionInfos;
}
void RAOFile::addDistanceToFile(const double distance, const RAOFile& file){
m_distancesWithOtherFiles.push_back(std::make_pair(distance,file.getIndex()));
}
RAOFile::~RAOFile() {
}
......
......@@ -18,6 +18,9 @@
#pragma once
#include <utility>
#include <list>
#include "FilePositionInfos.hpp"
namespace castor { namespace tape { namespace tapeserver { namespace rao {
......@@ -29,10 +32,13 @@ public:
RAOFile &operator=(const RAOFile & other);
uint64_t getIndex() const;
FilePositionInfos getFilePositionInfos() const;
void addDistanceToFile(const double distance, const RAOFile & file);
virtual ~RAOFile();
typedef std::pair<double,uint64_t> DistanceToFile;
private:
uint64_t m_index;
FilePositionInfos m_filePositionInfos;
std::list<DistanceToFile> m_distancesWithOtherFiles;
};
}}}}
......@@ -20,7 +20,6 @@
#include "InterpolationFilePositionEstimator.hpp"
#include "RAOHelpers.hpp"
#include "CTACostHeuristic.hpp"
#include "RAOFile.hpp"
namespace castor { namespace tape { namespace tapeserver { namespace rao {
......@@ -29,11 +28,9 @@ SLTFRAOAlgorithm::SLTFRAOAlgorithm() {}
std::vector<uint64_t> SLTFRAOAlgorithm::performRAO(const std::vector<std::unique_ptr<cta::RetrieveJob> >& jobs) {
std::vector<uint64_t> ret;
//Determine all the files position
std::vector<RAOFile> files;
for(uint64_t i = 0; i < jobs.size(); ++i){
files.push_back(RAOFile(i,m_filePositionEstimator->getFilePosition(*(jobs.at(i)))));
}
//Determine the matrix of the costs between each file
std::vector<RAOFile> files = computeAllFilesPosition(jobs);
computeCostBetweenAllFiles(files);
return ret;
}
......@@ -80,6 +77,31 @@ void SLTFRAOAlgorithm::Builder::initializeCostHeuristic() {
}
}
std::vector<RAOFile> SLTFRAOAlgorithm::computeAllFilesPosition(const std::vector<std::unique_ptr<cta::RetrieveJob> >& jobs) const {
std::vector<RAOFile> files;
for(uint64_t i = 0; i < jobs.size(); ++i){
files.push_back(RAOFile(i,m_filePositionEstimator->getFilePosition(*(jobs.at(i)))));
}
return files;
}
void SLTFRAOAlgorithm::computeCostBetweenAllFiles(std::vector<RAOFile> & files) const {
for(uint64_t i = 0; i < files.size(); ++i){
auto & sourceFile = files.at(i);
for(uint64_t j = 0; j < files.size(); ++j){
//We don't want the distance between the same file
if(i != j){
auto & destinationFile = files.at(j);
double distanceToFileJ = m_costHeuristic->getCost(sourceFile.getFilePositionInfos(),destinationFile.getFilePositionInfos());
files.at(i).addDistanceToFile(distanceToFileJ,destinationFile);
}
}
}
}
std::vector<uint64_t> SLTFRAOAlgorithm::performSLTF(const std::vector<RAOFile>& files) const {
//TODO
return std::vector<uint64_t>();
}
}}}}
\ No newline at end of file
......@@ -23,6 +23,7 @@
#include "CostHeuristic.hpp"
#include "FilePositionEstimator.hpp"
#include "castor/tape/tapeserver/drive/DriveInterface.hpp"
#include "RAOFile.hpp"
namespace castor { namespace tape { namespace tapeserver { namespace rao {
......@@ -48,6 +49,11 @@ private:
SLTFRAOAlgorithm();
std::unique_ptr<FilePositionEstimator> m_filePositionEstimator;
std::unique_ptr<CostHeuristic> m_costHeuristic;
std::vector<RAOFile> computeAllFilesPosition(const std::vector<std::unique_ptr<cta::RetrieveJob> > & jobs) const;
void computeCostBetweenAllFiles(std::vector<RAOFile> & files) const;
std::vector<uint64_t> performSLTF(const std::vector<RAOFile> & files) const;
};
}}}}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment