2017-12-06 16:25:13 +01:00
|
|
|
#include "../../header.h"
|
2017-12-20 18:23:39 +01:00
|
|
|
void status(vector<LogEntry>& log, vector<Part*>& p_Box);
|
2018-01-07 14:16:57 +01:00
|
|
|
bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector& cqVector);
|
2017-12-22 22:55:55 +01:00
|
|
|
void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth);
|
2017-12-23 21:46:41 +01:00
|
|
|
void sort(vector<LogEntry>& log);
|
2018-01-07 14:16:57 +01:00
|
|
|
void cut(vector<LogEntry>& log, int& cutID);
|
2017-12-23 21:46:41 +01:00
|
|
|
float capLogElements(vector<LogEntry>& log);
|
2018-01-07 14:16:57 +01:00
|
|
|
void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector, qualityVector& cqVector);
|
2017-11-18 08:16:05 +01:00
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
bool next(vector<LogEntry>& log,Puzzle& puzzleMat)
|
2017-11-18 08:16:05 +01:00
|
|
|
{
|
2017-12-12 11:42:31 +01:00
|
|
|
//last log element is set, create new log element or log not yet started
|
2017-12-03 20:12:32 +01:00
|
|
|
if(!(log.size()) || log.back().isSet())
|
2017-11-19 22:53:00 +01:00
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
if((puzzleMat.allSet())) return false; //puzzle solved
|
|
|
|
else createNextLogElement(log,puzzleMat);
|
2017-11-19 22:53:00 +01:00
|
|
|
}
|
|
|
|
//last log element is empty, backtrack
|
2018-01-07 14:16:57 +01:00
|
|
|
else if(!(log.back().PieceCollector.size())) backtrack(log,puzzleMat);
|
2017-11-19 22:53:00 +01:00
|
|
|
//case last log element has multiple entries
|
2017-11-18 22:48:40 +01:00
|
|
|
else if(log.back().PieceCollector.size() > 1)
|
|
|
|
{
|
2017-12-22 22:55:55 +01:00
|
|
|
//moreLayers is 0, setbest is 1
|
2018-01-07 14:16:57 +01:00
|
|
|
if (SetBestOrMoreLayersArithmetical(log, puzzleMat.combinedQualityVector)) setsolution(log, puzzleMat);
|
|
|
|
else solve(log, puzzleMat);
|
2017-11-18 22:48:40 +01:00
|
|
|
}
|
|
|
|
//case last log exactly one solution
|
|
|
|
else if(log.back().PieceCollector.size() == 1)
|
2017-12-03 20:12:32 +01:00
|
|
|
{
|
2017-11-19 22:53:00 +01:00
|
|
|
if(log.back().hasRandomed())
|
|
|
|
{
|
2017-12-21 12:20:57 +01:00
|
|
|
if(log.back().abstractionLevel < 2)//do 2 at least two best abstractions to check if part is okay
|
2017-11-19 22:53:00 +01:00
|
|
|
{
|
2017-11-28 21:35:49 +01:00
|
|
|
log.back().advance();
|
2018-01-07 14:16:57 +01:00
|
|
|
solve(log,puzzleMat);
|
2017-11-19 22:53:00 +01:00
|
|
|
}
|
|
|
|
else
|
2018-01-07 14:16:57 +01:00
|
|
|
setsolution(log,puzzleMat);
|
2017-11-19 22:53:00 +01:00
|
|
|
}
|
2017-12-13 10:47:15 +01:00
|
|
|
else
|
2018-01-07 14:16:57 +01:00
|
|
|
setsolution(log,puzzleMat);
|
2017-11-21 16:05:38 +01:00
|
|
|
}
|
2017-12-13 10:47:15 +01:00
|
|
|
return true;
|
2017-11-18 22:48:40 +01:00
|
|
|
}
|
2017-11-18 08:16:05 +01:00
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
void createNextLogElement(vector<LogEntry>& log, Puzzle& puzzleMat)
|
2017-12-12 11:42:31 +01:00
|
|
|
{
|
2017-12-21 12:43:31 +01:00
|
|
|
log.emplace_back(LogEntry(coor(0, 0)));
|
2018-01-07 14:16:57 +01:00
|
|
|
log.back().myCoor = calculateNextCoor(log, puzzleMat);
|
2017-12-22 23:09:23 +01:00
|
|
|
puzzleMat.dp.DestructionOfSurrounding(log.back().myCoor);//calculate dp from surrounding
|
2018-01-07 14:16:57 +01:00
|
|
|
for(auto it:puzzleMat.p_myBox)
|
2018-01-06 23:23:42 +01:00
|
|
|
log.back().PieceCollector.emplace_back(pair<float,Part*>(0,it));
|
2018-01-07 14:16:57 +01:00
|
|
|
cout << puzzleMat.p_myBox.size() << endl;
|
2018-01-06 23:23:42 +01:00
|
|
|
cout << log.back().PieceCollector.size() << endl;
|
2018-01-07 14:16:57 +01:00
|
|
|
solve(log,puzzleMat);
|
2017-12-12 11:42:31 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
coor calculateNextCoor(vector<LogEntry>& log, Puzzle& puzzleMat)
|
2017-11-18 08:16:05 +01:00
|
|
|
{
|
2017-11-18 22:48:40 +01:00
|
|
|
//level 1:
|
|
|
|
//go left to right, then increase current row
|
2017-12-03 20:12:32 +01:00
|
|
|
|
|
|
|
if (log.size() == 1)
|
2017-12-13 10:47:15 +01:00
|
|
|
return {0,0};
|
2017-12-03 20:12:32 +01:00
|
|
|
|
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
unsigned int m= log.rbegin()[1].myCoor.col;
|
|
|
|
unsigned int n= log.rbegin()[1].myCoor.row;
|
2017-12-03 20:12:32 +01:00
|
|
|
|
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
if(m<puzzleMat.getSizeAsCoor().col-1) m++;
|
|
|
|
else if(n<puzzleMat.getSizeAsCoor().row-1){ m=0; n++;}
|
2017-12-13 10:47:15 +01:00
|
|
|
return {m,n};
|
2017-11-18 22:48:40 +01:00
|
|
|
}
|
|
|
|
|
2017-12-21 12:20:57 +01:00
|
|
|
void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
2017-11-18 22:48:40 +01:00
|
|
|
{
|
2018-01-06 23:23:42 +01:00
|
|
|
log.back().abstractionLevel = puzzleMat.dp.getNextAbstractionLayer(log.back().myCoor,log.back().abstractionLevel); //sets in abstractionLevel
|
2017-11-19 22:53:00 +01:00
|
|
|
//status(log,p_Box,puzzleMat);
|
2017-11-19 17:52:02 +01:00
|
|
|
switch(log.back().abstractionLevel)
|
2017-11-18 22:48:40 +01:00
|
|
|
{
|
2018-01-06 23:23:42 +01:00
|
|
|
case 0:
|
2017-12-22 22:47:14 +01:00
|
|
|
puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
2017-11-19 17:52:02 +01:00
|
|
|
break;
|
2017-11-21 15:07:15 +01:00
|
|
|
|
2017-11-19 17:52:02 +01:00
|
|
|
default:
|
2017-11-18 22:48:40 +01:00
|
|
|
break;
|
|
|
|
}
|
2017-12-12 11:42:31 +01:00
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
float worth = capLogElements(log);
|
|
|
|
calculateTrueDestructionPower(log,puzzleMat, worth);
|
2018-01-07 14:16:57 +01:00
|
|
|
CalculateNewCombinedQuality(log, log.back().PieceCollector, puzzleMat.combinedQualityVector);
|
2017-12-12 11:42:31 +01:00
|
|
|
|
2017-11-18 08:16:05 +01:00
|
|
|
}
|
|
|
|
|
2017-12-20 18:23:39 +01:00
|
|
|
//removes from box and makes log "set"
|
2018-01-07 14:16:57 +01:00
|
|
|
void setsolution(vector<LogEntry>& log, Puzzle& puzzleMat)
|
2017-11-18 08:16:05 +01:00
|
|
|
{
|
2017-12-12 11:42:31 +01:00
|
|
|
//advance number of randomed part count
|
|
|
|
if(log.back().PieceCollector.size()>1) log.back().advanceRandomed();
|
|
|
|
|
2017-11-19 17:52:02 +01:00
|
|
|
//remove first element in last logelement from box
|
2018-01-07 14:16:57 +01:00
|
|
|
for(int i=0;i<puzzleMat.p_myBox.size();)
|
|
|
|
if(puzzleMat.p_myBox[i]==log.back().PieceCollector.begin()->second)//mach ich das richtig so?!
|
|
|
|
puzzleMat.p_myBox.erase(puzzleMat.p_myBox.begin()+i);
|
2017-12-03 20:12:32 +01:00
|
|
|
else
|
2017-11-19 22:53:00 +01:00
|
|
|
i++;
|
2017-12-03 20:12:32 +01:00
|
|
|
|
2017-11-19 22:53:00 +01:00
|
|
|
//tell log entry that it is set
|
|
|
|
log.back().Set();
|
2017-12-03 20:12:32 +01:00
|
|
|
}
|
2017-11-18 08:16:05 +01:00
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
|
2017-11-18 08:16:05 +01:00
|
|
|
{
|
2017-12-20 18:23:39 +01:00
|
|
|
//if more pieces possible, take next piece
|
|
|
|
if((log.back().PieceCollector.size())>1)
|
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
puzzleMat.p_myBox.push_back(log.back().PieceCollector.begin()->second);
|
2017-12-03 20:12:32 +01:00
|
|
|
log.back().PieceCollector.erase(log.back().PieceCollector.begin());
|
|
|
|
|
2017-11-28 21:35:49 +01:00
|
|
|
if(log.back().PieceCollector.size()==1)
|
|
|
|
log.back().decreaseRandomed();
|
2017-12-03 20:12:32 +01:00
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
setsolution(log,puzzleMat);
|
2017-11-28 21:35:49 +01:00
|
|
|
|
2017-12-20 18:23:39 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//else remove log element and backtrack once more
|
|
|
|
else
|
|
|
|
{
|
2017-12-21 12:20:57 +01:00
|
|
|
puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers
|
|
|
|
if((log.back().PieceCollector.size()))
|
2018-01-07 14:16:57 +01:00
|
|
|
puzzleMat.p_myBox.emplace_back(log.back().PieceCollector.begin()->second);
|
2017-12-20 18:23:39 +01:00
|
|
|
log.pop_back();
|
2018-01-07 14:16:57 +01:00
|
|
|
backtrack(log,puzzleMat);
|
2017-12-20 18:23:39 +01:00
|
|
|
}
|
2017-11-19 22:53:00 +01:00
|
|
|
}
|
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
void status(vector<LogEntry>& log, Puzzle& puzzleMat)
|
2017-11-19 22:53:00 +01:00
|
|
|
{
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
cout << "status:" << endl;
|
|
|
|
cout << "hasrandomed: " << log[0].hasRandomed() << endl;
|
|
|
|
for(int i=0;i<log.size();i++)
|
|
|
|
{
|
|
|
|
cout << "log #" << i << ":" << endl;
|
|
|
|
cout << "piecenr " << log[i].PieceCollector.size() << endl;
|
|
|
|
if(log[i].isSet())
|
|
|
|
cout << "isset: 1" << endl;
|
|
|
|
else
|
|
|
|
cout << "isset: 0" << endl;
|
2017-12-16 00:10:52 +01:00
|
|
|
cout << "col: " << log[i].myCoor.col<< " row: " << log[i].myCoor.row << endl;
|
2017-11-19 22:53:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cout << endl;
|
|
|
|
cout << "Box:" << endl;
|
2018-01-07 14:16:57 +01:00
|
|
|
cout << "size: " << puzzleMat.p_myBox.size() << endl;
|
2017-11-19 22:53:00 +01:00
|
|
|
|
|
|
|
cout << "Puzzle:" << endl;
|
|
|
|
puzzleMat.printPuzzle();
|
|
|
|
cout << "----------------------------" << endl;
|
2017-12-13 10:47:15 +01:00
|
|
|
}
|
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
//this is addon stuff that should later all be extracted into a sererate cpp as it is not core dispatcher functionality
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth) {
|
|
|
|
float destructionPower = sqrt(
|
|
|
|
Layerworth * puzzleMat.dp.m_constraintMatrix[0][0].SpeedTable[log.back().abstractionLevel]);
|
|
|
|
puzzleMat.dp.setDestructionPower(log.back().myCoor, log.back().abstractionLevel, destructionPower);
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
// PART RAUER_WEIDINGER
|
|
|
|
float capLogElements(vector<LogEntry>& log)
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
|
|
|
// Till Now only ground structure -> incorrect variable ans vector names
|
|
|
|
double limit = 0.6;
|
|
|
|
double diff = 0;
|
2018-01-07 14:16:57 +01:00
|
|
|
|
|
|
|
int id=0;
|
|
|
|
|
2017-12-22 22:55:55 +01:00
|
|
|
double maxdiff = 0;
|
|
|
|
int vectorsizeBefore = 0;
|
|
|
|
int vectorsizeAfter = 0;
|
|
|
|
double destroyed = 0; // destroyed parts in %
|
|
|
|
|
|
|
|
vectorsizeBefore = log.back().PieceCollector.size();
|
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
sort(log.back().PieceCollector.begin(),log.back().PieceCollector.end()); // Sort the vector after probabilities
|
|
|
|
reverse(log.back().PieceCollector.begin(),log.back().PieceCollector.end());
|
|
|
|
for(;id<log.back().PieceCollector.size();id++)
|
|
|
|
{
|
|
|
|
if(log.back().PieceCollector[id].first < limit)
|
2017-12-22 22:55:55 +01:00
|
|
|
break;
|
2018-01-07 14:16:57 +01:00
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
int newid = --id; //set to the one just over limit
|
2017-12-23 21:46:41 +01:00
|
|
|
|
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
while(id<log.back().PieceCollector.size()-1) //find maximum difference in function
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
|
|
|
|
diff = log.back().PieceCollector[id].first - log.back().PieceCollector[++id].first;
|
2017-12-22 22:55:55 +01:00
|
|
|
if(diff > maxdiff)
|
|
|
|
{
|
|
|
|
maxdiff = diff;
|
2018-01-07 14:16:57 +01:00
|
|
|
newid = id;
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-07 14:16:57 +01:00
|
|
|
cut(log,newid);
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
vectorsizeAfter = log.back().PieceCollector.size();
|
2018-01-07 14:16:57 +01:00
|
|
|
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
|
2017-12-23 21:46:41 +01:00
|
|
|
return (float)sqrt(destroyed*maxdiff);
|
2017-12-22 22:55:55 +01:00
|
|
|
|
|
|
|
|
2017-12-23 21:46:41 +01:00
|
|
|
}
|
|
|
|
|
2018-01-02 13:59:16 +01:00
|
|
|
qualityVector::iterator FindPartInLog(vector<LogEntry>& log, Part* wishedPartPointer)
|
|
|
|
{
|
|
|
|
qualityVector::iterator partOnPositionIterator = log.back().PieceCollector.begin();
|
|
|
|
|
|
|
|
while (partOnPositionIterator != log.back().PieceCollector.end())
|
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
if(partOnPositionIterator->second == wishedPartPointer)
|
2018-01-02 13:59:16 +01:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
partOnPositionIterator++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return partOnPositionIterator;
|
|
|
|
}
|
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
void cut(vector<LogEntry>& log, int& cutID)
|
2017-12-23 21:46:41 +01:00
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
while(cutID<log.back().PieceCollector.size())
|
|
|
|
log.back().PieceCollector.erase(log.back().PieceCollector.begin()+cutID);
|
2017-12-23 21:46:41 +01:00
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2018-01-05 01:18:23 +01:00
|
|
|
// -------------------- Part David: SetBest and CalculateCombinedQuality --------------------
|
|
|
|
// pruefen, ob mehr als X combinedQualities ueber dem Grenzwert sind. Wenn nur noch Y Pieces ueber bleiben, dann setBest!
|
|
|
|
// geeignete Threshold values muessen noch getestet werden
|
2018-01-07 14:16:57 +01:00
|
|
|
bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector& cqVector)
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
float threshold = 1.0, tempBest = 0.0;
|
|
|
|
unsigned int countHigherThreshold = 0;
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2018-01-07 14:16:57 +01:00
|
|
|
if(cqVector.empty())
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
cerr << "combinedQualityVector is empty." << endl; // should not be empty => backtrack?
|
|
|
|
return false; // Warning: can only return true or false. What return for error?
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
switch(log.back().abstractionLevel)
|
|
|
|
{
|
|
|
|
case 1: threshold = 0.90; break;
|
|
|
|
case 2: threshold = 0.80; break;
|
|
|
|
case 3: threshold = 0.75; break;
|
|
|
|
case 4: threshold = 0.66; break;
|
|
|
|
case 5: threshold = 0.60; break;
|
|
|
|
default: threshold = 0.5; break;
|
|
|
|
}
|
2017-12-23 21:46:41 +01:00
|
|
|
|
2018-01-05 01:18:23 +01:00
|
|
|
// check Quality of current Puzzle Piece in combinedQualityVector with Threshold value
|
2018-01-07 14:16:57 +01:00
|
|
|
for (qualityVector::iterator it = cqVector.begin(); it != cqVector.end(); it++)
|
2018-01-05 01:18:23 +01:00
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
if ((cqVector.back().first / log.back().abstractionLevel) >= threshold) // const threshold values
|
2018-01-05 01:18:23 +01:00
|
|
|
{
|
|
|
|
// count how many Pieces are greater than the threshold value
|
|
|
|
countHigherThreshold++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
if ((cqVector.back().first / log.back().abstractionLevel) > tempBest)
|
2018-01-05 01:18:23 +01:00
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
tempBest = cqVector.back().first; // could be used, for additional constraints
|
2018-01-05 01:18:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2018-01-05 01:18:23 +01:00
|
|
|
// return true if only one piece is left
|
|
|
|
if (1 == countHigherThreshold)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
|
|
|
|
2018-01-05 01:18:23 +01:00
|
|
|
// jede Quality vom Piececollector zu einer combinedQuality aufsummieren (von jedem bereits verwendetem Layer)
|
|
|
|
// Achtung: Es muss noch der Mittelwert gebildet werden => SetBestOrMoreLayersArithmetical
|
2018-01-07 14:16:57 +01:00
|
|
|
void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector, qualityVector& cqVector)
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
bool summarizedVectors = false;
|
|
|
|
int countSummarizedVectors = 0;
|
2017-12-22 22:55:55 +01:00
|
|
|
|
2018-01-05 01:18:23 +01:00
|
|
|
// check if both qualityVectors are not empty
|
|
|
|
if(qVector.empty())
|
|
|
|
{
|
|
|
|
cerr << "qualityVector is empty." << endl; // should not be empty => backtrack?
|
|
|
|
return;
|
|
|
|
}
|
2018-01-07 14:16:57 +01:00
|
|
|
else if(cqVector.empty())
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
cerr << "combinedQualityVector is empty." << endl; // should not be empty => backtrack?
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-07 14:16:57 +01:00
|
|
|
for (unsigned int i = 0; i < cqVector.size(); i++)
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
summarizedVectors = false;
|
|
|
|
|
|
|
|
for (unsigned int j = 0; j < qVector.size(); j++)
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
// search same PuzzlePart of qualityVector and combinedQualityVector
|
2018-01-07 14:16:57 +01:00
|
|
|
if (&cqVector.at(i).second == &qVector.at(j).second)
|
2018-01-05 01:18:23 +01:00
|
|
|
{
|
|
|
|
// sum Quality of PieceCollector (qualityVector) to combinedQualityVector
|
2018-01-07 14:16:57 +01:00
|
|
|
cqVector.at(j).first += qVector.at(i).first;
|
2018-01-05 01:18:23 +01:00
|
|
|
countSummarizedVectors++;
|
|
|
|
summarizedVectors = true;
|
|
|
|
continue; // skip remaining for loop => save time!
|
|
|
|
}
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
2018-01-05 01:18:23 +01:00
|
|
|
|
|
|
|
// remove element at poisition X in combinedQualityVector, because it was not summarized
|
|
|
|
if (!summarizedVectors)
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
// inefficient way to delete element X
|
|
|
|
//cqVector->erase(cqVector->begin()+i);
|
|
|
|
|
|
|
|
// efficient way, but no sorted cqVector => wayne
|
2018-01-07 14:16:57 +01:00
|
|
|
swap(cqVector.at(i), cqVector.back());
|
|
|
|
cqVector.pop_back();
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-05 01:18:23 +01:00
|
|
|
// cqVector should have the same size now as newest qVector
|
2018-01-07 14:16:57 +01:00
|
|
|
if (cqVector.size() != qVector.size())
|
2017-12-22 22:55:55 +01:00
|
|
|
{
|
2018-01-05 01:18:23 +01:00
|
|
|
cerr << "Size of combinedQualityVector doenst match with size of qualityVector!" << endl;
|
2018-01-07 14:16:57 +01:00
|
|
|
cout << "Size of combinedQualityVector: " << cqVector.size() << endl;
|
2018-01-05 01:18:23 +01:00
|
|
|
cout << "Size of qualityVector: " << qVector.size() << endl;
|
|
|
|
cout << "Size of countSummarizedVectors: " << countSummarizedVectors << endl;
|
2017-12-22 22:55:55 +01:00
|
|
|
}
|
|
|
|
}
|
2018-01-05 01:18:23 +01:00
|
|
|
}
|