dispatcher funktioniert halb, es fehlt noch 'setflag' und average quality calculation
This commit is contained in:
parent
882737bd30
commit
fc9743a77a
@ -44,16 +44,15 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector<Part*>* partAr
|
|||||||
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
|
||||||
bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector)
|
bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector)
|
||||||
{
|
{
|
||||||
int j=0;
|
|
||||||
for(int i = 0;i<qVector.size();i++)
|
for(int i = 0;i<qVector.size();i++)
|
||||||
{
|
{
|
||||||
j++;
|
|
||||||
cout <<"qVector size: " << qVector.size() << endl;
|
|
||||||
cout << "ID: " << qVector[i].second->GetPartID() << ", rotations: " << (int)qVector[i].second->GetNumOfRotations() << endl;
|
|
||||||
qVector[i].second->print();
|
|
||||||
if(PlaceOfPartGood(constraintCoordinate, qVector[i].second->m_a1.m_connections))
|
if(PlaceOfPartGood(constraintCoordinate, qVector[i].second->m_a1.m_connections))
|
||||||
|
{
|
||||||
|
qVector[i].first=1;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
qVector.erase(qVector.begin()+(i--)); cout << endl << endl;
|
}
|
||||||
|
qVector[i].first=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,3 +87,8 @@ void Puzzle::createBox(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Puzzle::allSet() {
|
||||||
|
//TODO! check if all puzzlepieces are set
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
#include "../../header.h"
|
#include "../../header.h"
|
||||||
void status(vector<LogEntry>& log, vector<Part*>& p_Box);
|
void status(vector<LogEntry>& log, vector<Part*>& p_Box);
|
||||||
bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector* cqVector);
|
bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector& cqVector);
|
||||||
void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth);
|
void calculateTrueDestructionPower(vector<LogEntry>& log, Puzzle& puzzleMat, float Layerworth);
|
||||||
void sort(vector<LogEntry>& log);
|
void sort(vector<LogEntry>& log);
|
||||||
void cut(vector<LogEntry>& log, Part* cutID);
|
void cut(vector<LogEntry>& log, int& cutID);
|
||||||
float capLogElements(vector<LogEntry>& log);
|
float capLogElements(vector<LogEntry>& log);
|
||||||
void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector, qualityVector* cqVector);
|
void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector, qualityVector& cqVector);
|
||||||
|
|
||||||
bool next(vector<LogEntry>& log, vector<Part*>& p_Box,Puzzle& puzzleMat)
|
bool next(vector<LogEntry>& log,Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
//last log element is set, create new log element or log not yet started
|
//last log element is set, create new log element or log not yet started
|
||||||
if(!(log.size()) || log.back().isSet())
|
if(!(log.size()) || log.back().isSet())
|
||||||
{
|
{
|
||||||
if(!(p_Box.size())) return false; //puzzle solved
|
if((puzzleMat.allSet())) return false; //puzzle solved
|
||||||
else createNextLogElement(log,p_Box,puzzleMat);
|
else createNextLogElement(log,puzzleMat);
|
||||||
}
|
}
|
||||||
//last log element is empty, backtrack
|
//last log element is empty, backtrack
|
||||||
else if(!(log.back().PieceCollector.size())) backtrack(log,p_Box,puzzleMat);
|
else if(!(log.back().PieceCollector.size())) backtrack(log,puzzleMat);
|
||||||
//case last log element has multiple entries
|
//case last log element has multiple entries
|
||||||
else if(log.back().PieceCollector.size() > 1)
|
else if(log.back().PieceCollector.size() > 1)
|
||||||
{
|
{
|
||||||
//moreLayers is 0, setbest is 1
|
//moreLayers is 0, setbest is 1
|
||||||
if (SetBestOrMoreLayersArithmetical(log, &puzzleMat.combinedQualityVector)) setsolution(log, p_Box, puzzleMat);
|
if (SetBestOrMoreLayersArithmetical(log, puzzleMat.combinedQualityVector)) setsolution(log, puzzleMat);
|
||||||
else solve(log, p_Box, puzzleMat);
|
else solve(log, puzzleMat);
|
||||||
}
|
}
|
||||||
//case last log exactly one solution
|
//case last log exactly one solution
|
||||||
else if(log.back().PieceCollector.size() == 1)
|
else if(log.back().PieceCollector.size() == 1)
|
||||||
@ -32,31 +32,31 @@ bool next(vector<LogEntry>& log, vector<Part*>& p_Box,Puzzle& puzzleMat)
|
|||||||
if(log.back().abstractionLevel < 2)//do 2 at least two best abstractions to check if part is okay
|
if(log.back().abstractionLevel < 2)//do 2 at least two best abstractions to check if part is okay
|
||||||
{
|
{
|
||||||
log.back().advance();
|
log.back().advance();
|
||||||
solve(log,p_Box,puzzleMat);
|
solve(log,puzzleMat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setsolution(log,p_Box,puzzleMat);
|
setsolution(log,puzzleMat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
setsolution(log,p_Box,puzzleMat);
|
setsolution(log,puzzleMat);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
void createNextLogElement(vector<LogEntry>& log, Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
log.emplace_back(LogEntry(coor(0, 0)));
|
log.emplace_back(LogEntry(coor(0, 0)));
|
||||||
log.back().myCoor = calculateNextCoor(log, p_Box,puzzleMat);
|
log.back().myCoor = calculateNextCoor(log, puzzleMat);
|
||||||
puzzleMat.dp.DestructionOfSurrounding(log.back().myCoor);//calculate dp from surrounding
|
puzzleMat.dp.DestructionOfSurrounding(log.back().myCoor);//calculate dp from surrounding
|
||||||
for(auto it:p_Box)
|
for(auto it:puzzleMat.p_myBox)
|
||||||
log.back().PieceCollector.emplace_back(pair<float,Part*>(0,it));
|
log.back().PieceCollector.emplace_back(pair<float,Part*>(0,it));
|
||||||
cout << p_Box.size() << endl;
|
cout << puzzleMat.p_myBox.size() << endl;
|
||||||
cout << log.back().PieceCollector.size() << endl;
|
cout << log.back().PieceCollector.size() << endl;
|
||||||
solve(log, p_Box,puzzleMat);
|
solve(log,puzzleMat);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
coor calculateNextCoor(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
coor calculateNextCoor(vector<LogEntry>& log, Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
//level 1:
|
//level 1:
|
||||||
//go left to right, then increase current row
|
//go left to right, then increase current row
|
||||||
@ -88,23 +88,22 @@ void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
capLogElements(log);
|
|
||||||
float worth = capLogElements(log);
|
float worth = capLogElements(log);
|
||||||
calculateTrueDestructionPower(log,puzzleMat, worth);
|
calculateTrueDestructionPower(log,puzzleMat, worth);
|
||||||
CalculateNewCombinedQuality(log, log.back().PieceCollector, &puzzleMat.combinedQualityVector);
|
CalculateNewCombinedQuality(log, log.back().PieceCollector, puzzleMat.combinedQualityVector);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//removes from box and makes log "set"
|
//removes from box and makes log "set"
|
||||||
void setsolution(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
void setsolution(vector<LogEntry>& log, Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
//advance number of randomed part count
|
//advance number of randomed part count
|
||||||
if(log.back().PieceCollector.size()>1) log.back().advanceRandomed();
|
if(log.back().PieceCollector.size()>1) log.back().advanceRandomed();
|
||||||
|
|
||||||
//remove first element in last logelement from box
|
//remove first element in last logelement from box
|
||||||
for(int i=0;i<p_Box.size();)
|
for(int i=0;i<puzzleMat.p_myBox.size();)
|
||||||
if(p_Box[i]==log.back().PieceCollector.begin()->second)//mach ich das richtig so?!
|
if(puzzleMat.p_myBox[i]==log.back().PieceCollector.begin()->second)//mach ich das richtig so?!
|
||||||
p_Box.erase(p_Box.begin()+i);
|
puzzleMat.p_myBox.erase(puzzleMat.p_myBox.begin()+i);
|
||||||
else
|
else
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
@ -112,18 +111,18 @@ void setsolution(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
|||||||
log.back().Set();
|
log.back().Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool backtrack(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
//if more pieces possible, take next piece
|
//if more pieces possible, take next piece
|
||||||
if((log.back().PieceCollector.size())>1)
|
if((log.back().PieceCollector.size())>1)
|
||||||
{
|
{
|
||||||
p_Box.push_back(log.back().PieceCollector.begin()->second);
|
puzzleMat.p_myBox.push_back(log.back().PieceCollector.begin()->second);
|
||||||
log.back().PieceCollector.erase(log.back().PieceCollector.begin());
|
log.back().PieceCollector.erase(log.back().PieceCollector.begin());
|
||||||
|
|
||||||
if(log.back().PieceCollector.size()==1)
|
if(log.back().PieceCollector.size()==1)
|
||||||
log.back().decreaseRandomed();
|
log.back().decreaseRandomed();
|
||||||
|
|
||||||
setsolution(log,p_Box,puzzleMat);
|
setsolution(log,puzzleMat);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -132,13 +131,13 @@ bool backtrack(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
|||||||
{
|
{
|
||||||
puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers
|
puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers
|
||||||
if((log.back().PieceCollector.size()))
|
if((log.back().PieceCollector.size()))
|
||||||
p_Box.emplace_back(log.back().PieceCollector.begin()->second);
|
puzzleMat.p_myBox.emplace_back(log.back().PieceCollector.begin()->second);
|
||||||
log.pop_back();
|
log.pop_back();
|
||||||
backtrack(log,p_Box,puzzleMat);
|
backtrack(log,puzzleMat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void status(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
void status(vector<LogEntry>& log, Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
cout << "----------------------------" << endl;
|
cout << "----------------------------" << endl;
|
||||||
cout << "status:" << endl;
|
cout << "status:" << endl;
|
||||||
@ -156,7 +155,7 @@ void status(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat)
|
|||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
cout << "Box:" << endl;
|
cout << "Box:" << endl;
|
||||||
cout << "size: " << p_Box.size() << endl;
|
cout << "size: " << puzzleMat.p_myBox.size() << endl;
|
||||||
|
|
||||||
cout << "Puzzle:" << endl;
|
cout << "Puzzle:" << endl;
|
||||||
puzzleMat.printPuzzle();
|
puzzleMat.printPuzzle();
|
||||||
@ -177,86 +176,77 @@ float capLogElements(vector<LogEntry>& log)
|
|||||||
// Till Now only ground structure -> incorrect variable ans vector names
|
// Till Now only ground structure -> incorrect variable ans vector names
|
||||||
double limit = 0.6;
|
double limit = 0.6;
|
||||||
double diff = 0;
|
double diff = 0;
|
||||||
|
|
||||||
|
int id=0;
|
||||||
|
|
||||||
double maxdiff = 0;
|
double maxdiff = 0;
|
||||||
int vectorsizeBefore = 0;
|
int vectorsizeBefore = 0;
|
||||||
int vectorsizeAfter = 0;
|
int vectorsizeAfter = 0;
|
||||||
double destroyed = 0; // destroyed parts in %
|
double destroyed = 0; // destroyed parts in %
|
||||||
double worth = 0;
|
|
||||||
|
|
||||||
vectorsizeBefore = log.back().PieceCollector.size();
|
vectorsizeBefore = log.back().PieceCollector.size();
|
||||||
|
|
||||||
sort(log); // Sort the vector after probabilities
|
sort(log.back().PieceCollector.begin(),log.back().PieceCollector.end()); // Sort the vector after probabilities
|
||||||
qualityVector::const_iterator idxcut =log.back().PieceCollector.begin();
|
reverse(log.back().PieceCollector.begin(),log.back().PieceCollector.end());
|
||||||
for(;idxcut !=log.back().PieceCollector.end();idxcut++)
|
for(;id<log.back().PieceCollector.size();id++)
|
||||||
if(idxcut->first < limit)
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
auto newidxcut = idxcut;
|
|
||||||
|
|
||||||
|
|
||||||
while(idxcut != log.back().PieceCollector.end())
|
|
||||||
{
|
{
|
||||||
diff = idxcut->second - (++idxcut)->second;
|
if(log.back().PieceCollector[id].first < limit)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int newid = --id; //set to the one just over limit
|
||||||
|
|
||||||
|
|
||||||
|
while(id<log.back().PieceCollector.size()-1) //find maximum difference in function
|
||||||
|
{
|
||||||
|
|
||||||
|
diff = log.back().PieceCollector[id].first - log.back().PieceCollector[++id].first;
|
||||||
if(diff > maxdiff)
|
if(diff > maxdiff)
|
||||||
{
|
{
|
||||||
maxdiff = diff;
|
maxdiff = diff;
|
||||||
newidxcut = idxcut;
|
newid = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cut(log,newidxcut->second);
|
cut(log,newid);
|
||||||
|
|
||||||
vectorsizeAfter = log.back().PieceCollector.size();
|
vectorsizeAfter = log.back().PieceCollector.size();
|
||||||
|
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
|
||||||
destroyed = (vectorsizeBefore - vectorsizeAfter) / vectorsizeBefore;
|
|
||||||
|
|
||||||
return (float)sqrt(destroyed*maxdiff);
|
return (float)sqrt(destroyed*maxdiff);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sort(vector<LogEntry>& log)
|
|
||||||
{
|
|
||||||
//this does all the sorting that needs to happen
|
|
||||||
//saddly this is a false statement
|
|
||||||
//the monkey desperately tried to hold on to the flying dorm room.
|
|
||||||
}
|
|
||||||
|
|
||||||
qualityVector::iterator FindPartInLog(vector<LogEntry>& log, Part* wishedPartPointer)
|
qualityVector::iterator FindPartInLog(vector<LogEntry>& log, Part* wishedPartPointer)
|
||||||
{
|
{
|
||||||
qualityVector::iterator partOnPositionIterator = log.back().PieceCollector.begin();
|
qualityVector::iterator partOnPositionIterator = log.back().PieceCollector.begin();
|
||||||
|
|
||||||
while (partOnPositionIterator != log.back().PieceCollector.end())
|
while (partOnPositionIterator != log.back().PieceCollector.end())
|
||||||
{
|
{
|
||||||
if(partOnPositionIterator.base()->second == wishedPartPointer)
|
if(partOnPositionIterator->second == wishedPartPointer)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
partOnPositionIterator++;
|
partOnPositionIterator++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return partOnPositionIterator;
|
return partOnPositionIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cut(vector<LogEntry>& log, Part* cutID)
|
void cut(vector<LogEntry>& log, int& cutID)
|
||||||
{
|
{
|
||||||
auto it = FindPartInLog(log, cutID);
|
while(cutID<log.back().PieceCollector.size())
|
||||||
while(it != log.back().PieceCollector.end())
|
log.back().PieceCollector.erase(log.back().PieceCollector.begin()+cutID);
|
||||||
log.back().PieceCollector.erase(it++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------- Part David: SetBest and CalculateCombinedQuality --------------------
|
// -------------------- Part David: SetBest and CalculateCombinedQuality --------------------
|
||||||
// pruefen, ob mehr als X combinedQualities ueber dem Grenzwert sind. Wenn nur noch Y Pieces ueber bleiben, dann setBest!
|
// 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
|
// geeignete Threshold values muessen noch getestet werden
|
||||||
bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector* cqVector)
|
bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector& cqVector)
|
||||||
{
|
{
|
||||||
float threshold = 1.0, tempBest = 0.0;
|
float threshold = 1.0, tempBest = 0.0;
|
||||||
unsigned int countHigherThreshold = 0;
|
unsigned int countHigherThreshold = 0;
|
||||||
|
|
||||||
if(cqVector->empty())
|
if(cqVector.empty())
|
||||||
{
|
{
|
||||||
cerr << "combinedQualityVector is empty." << endl; // should not be empty => backtrack?
|
cerr << "combinedQualityVector is empty." << endl; // should not be empty => backtrack?
|
||||||
return false; // Warning: can only return true or false. What return for error?
|
return false; // Warning: can only return true or false. What return for error?
|
||||||
@ -274,18 +264,18 @@ bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector* cqVec
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check Quality of current Puzzle Piece in combinedQualityVector with Threshold value
|
// check Quality of current Puzzle Piece in combinedQualityVector with Threshold value
|
||||||
for (qualityVector::iterator it = cqVector->begin(); it != cqVector->end(); it++)
|
for (qualityVector::iterator it = cqVector.begin(); it != cqVector.end(); it++)
|
||||||
{
|
{
|
||||||
if ((cqVector->back().first / log.back().abstractionLevel) >= threshold) // const threshold values
|
if ((cqVector.back().first / log.back().abstractionLevel) >= threshold) // const threshold values
|
||||||
{
|
{
|
||||||
// count how many Pieces are greater than the threshold value
|
// count how many Pieces are greater than the threshold value
|
||||||
countHigherThreshold++;
|
countHigherThreshold++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((cqVector->back().first / log.back().abstractionLevel) > tempBest)
|
if ((cqVector.back().first / log.back().abstractionLevel) > tempBest)
|
||||||
{
|
{
|
||||||
tempBest = cqVector->back().first; // could be used, for additional constraints
|
tempBest = cqVector.back().first; // could be used, for additional constraints
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,7 +294,7 @@ bool SetBestOrMoreLayersArithmetical(vector<LogEntry>& log, qualityVector* cqVec
|
|||||||
|
|
||||||
// jede Quality vom Piececollector zu einer combinedQuality aufsummieren (von jedem bereits verwendetem Layer)
|
// jede Quality vom Piececollector zu einer combinedQuality aufsummieren (von jedem bereits verwendetem Layer)
|
||||||
// Achtung: Es muss noch der Mittelwert gebildet werden => SetBestOrMoreLayersArithmetical
|
// Achtung: Es muss noch der Mittelwert gebildet werden => SetBestOrMoreLayersArithmetical
|
||||||
void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector, qualityVector* cqVector)
|
void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector, qualityVector& cqVector)
|
||||||
{
|
{
|
||||||
bool summarizedVectors = false;
|
bool summarizedVectors = false;
|
||||||
int countSummarizedVectors = 0;
|
int countSummarizedVectors = 0;
|
||||||
@ -315,24 +305,24 @@ void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector,
|
|||||||
cerr << "qualityVector is empty." << endl; // should not be empty => backtrack?
|
cerr << "qualityVector is empty." << endl; // should not be empty => backtrack?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(cqVector->empty())
|
else if(cqVector.empty())
|
||||||
{
|
{
|
||||||
cerr << "combinedQualityVector is empty." << endl; // should not be empty => backtrack?
|
cerr << "combinedQualityVector is empty." << endl; // should not be empty => backtrack?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < cqVector->size(); i++)
|
for (unsigned int i = 0; i < cqVector.size(); i++)
|
||||||
{
|
{
|
||||||
summarizedVectors = false;
|
summarizedVectors = false;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < qVector.size(); j++)
|
for (unsigned int j = 0; j < qVector.size(); j++)
|
||||||
{
|
{
|
||||||
// search same PuzzlePart of qualityVector and combinedQualityVector
|
// search same PuzzlePart of qualityVector and combinedQualityVector
|
||||||
if (&cqVector->at(i).second == &qVector.at(j).second)
|
if (&cqVector.at(i).second == &qVector.at(j).second)
|
||||||
{
|
{
|
||||||
// sum Quality of PieceCollector (qualityVector) to combinedQualityVector
|
// sum Quality of PieceCollector (qualityVector) to combinedQualityVector
|
||||||
cqVector->at(j).first += qVector.at(i).first;
|
cqVector.at(j).first += qVector.at(i).first;
|
||||||
countSummarizedVectors++;
|
countSummarizedVectors++;
|
||||||
summarizedVectors = true;
|
summarizedVectors = true;
|
||||||
continue; // skip remaining for loop => save time!
|
continue; // skip remaining for loop => save time!
|
||||||
@ -346,16 +336,16 @@ void CalculateNewCombinedQuality(vector<LogEntry>& log, qualityVector& qVector,
|
|||||||
//cqVector->erase(cqVector->begin()+i);
|
//cqVector->erase(cqVector->begin()+i);
|
||||||
|
|
||||||
// efficient way, but no sorted cqVector => wayne
|
// efficient way, but no sorted cqVector => wayne
|
||||||
swap(cqVector->at(i), cqVector->back());
|
swap(cqVector.at(i), cqVector.back());
|
||||||
cqVector->pop_back();
|
cqVector.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cqVector should have the same size now as newest qVector
|
// cqVector should have the same size now as newest qVector
|
||||||
if (cqVector->size() != qVector.size())
|
if (cqVector.size() != qVector.size())
|
||||||
{
|
{
|
||||||
cerr << "Size of combinedQualityVector doenst match with size of qualityVector!" << endl;
|
cerr << "Size of combinedQualityVector doenst match with size of qualityVector!" << endl;
|
||||||
cout << "Size of combinedQualityVector: " << cqVector->size() << endl;
|
cout << "Size of combinedQualityVector: " << cqVector.size() << endl;
|
||||||
cout << "Size of qualityVector: " << qVector.size() << endl;
|
cout << "Size of qualityVector: " << qVector.size() << endl;
|
||||||
cout << "Size of countSummarizedVectors: " << countSummarizedVectors << endl;
|
cout << "Size of countSummarizedVectors: " << countSummarizedVectors << endl;
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ public:
|
|||||||
void createBox();
|
void createBox();
|
||||||
void createp_box();
|
void createp_box();
|
||||||
|
|
||||||
|
bool allSet();
|
||||||
|
|
||||||
vector<Part> myBox;
|
vector<Part> myBox;
|
||||||
vector<Part*> p_myBox;
|
vector<Part*> p_myBox;
|
||||||
|
|
||||||
@ -76,11 +78,11 @@ private:
|
|||||||
unsigned int cols;
|
unsigned int cols;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool next(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
bool next(vector<LogEntry>& log,Puzzle& puzzleMat);
|
||||||
coor calculateNextCoor(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
coor calculateNextCoor(vector<LogEntry>& log, Puzzle& puzzleMat);
|
||||||
void solve(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
void solve(vector<LogEntry>& log, Puzzle& puzzleMat);
|
||||||
void setsolution(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
void setsolution(vector<LogEntry>& log, Puzzle& puzzleMat);
|
||||||
bool backtrack(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
bool backtrack(vector<LogEntry>& log,Puzzle& puzzleMat);
|
||||||
|
|
||||||
void createNextLogElement(vector<LogEntry>& log, vector<Part*>& p_Box, Puzzle& puzzleMat);
|
void createNextLogElement(vector<LogEntry>& log,Puzzle& puzzleMat);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ int main()
|
|||||||
//puzzleMat.createRandomBox();
|
//puzzleMat.createRandomBox();
|
||||||
puzzleMat.a1.printConstraintMatrix();
|
puzzleMat.a1.printConstraintMatrix();
|
||||||
|
|
||||||
while(next(log, puzzleMat.p_myBox,puzzleMat));
|
while(next(log, puzzleMat));
|
||||||
|
|
||||||
puzzleMat.printPuzzle();
|
puzzleMat.printPuzzle();
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user