debugging

This commit is contained in:
Raphael Maenle 2018-01-22 20:09:57 +01:00
parent 7979d28422
commit a7ce247eb9
2 changed files with 17 additions and 6 deletions

View File

@ -73,11 +73,11 @@ float AbstractionLayer_PoempelPosition::PlaceOfPartGood(coor myCoor, vector<doub
sum+=abs(comparePosition[5]-myPart[5]);
}
if(sum>100)
if(sum>500)
return 0;
if(sum==0)
return 1;
sum/=100;
sum/=500;
return 1-sum;
//check vector against negative part, use sad
//return of well it fits within threshold

View File

@ -72,7 +72,7 @@ coor calculateNextCoor(vector<LogEntry>& log, Puzzle& puzzleMat)
void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
{
log.back().abstractionLevel = puzzleMat.dp.getNextAbstractionLayer(log.back().myCoor,log.back().abstractionLevel); //sets in abstractionLevel
cout << "abs: " << log.back().abstractionLevel << endl;
cout << "abs: " << log.back().abstractionLevel;
//status(log,p_Box,puzzleMat);
//TODO!! Add more layers here
switch(log.back().abstractionLevel)
@ -80,16 +80,21 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
case 0://pömpel
puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
break;
case 1://histogram
case 1://poempelposition
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
break;
case -1://random
cout << endl;
setsolution(log,puzzleMat);
return;
default:
break;
}
float worth = capLogElements(log);
cout << " | " << worth << endl;
if(worth && log.back().abstractionLevel)
cerr << "removed something!" << endl;
calculateTrueDestructionPower(log,puzzleMat, worth);
CalculateNewCombinedQuality(log, log.back().PieceCollector, puzzleMat.combinedQualityVector);
@ -112,16 +117,18 @@ void setsolution(vector<LogEntry>& log, Puzzle& puzzleMat)
puzzleMat.setConstraints(log.back().myCoor,log.back().PieceCollector.begin()->second);
cout << "set:" << log.back().myCoor.col << "," << log.back().myCoor.row << endl;
//cout << "ID: " << log.back().PieceCollector[0].second->GetPartID() << endl;
cout << "Size of Log: " << log.back().PieceCollector.size() << endl;
}
bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
{
cout << "backtrack" << endl;
if(log.empty())
{
cout << "Puzzle not solveable!" << endl;
return false;
}
cout << "Size of Log: " << log.back().PieceCollector.size() << endl;
puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save
//if more pieces possible, tset piece as not logged
if((log.back().PieceCollector.size())>1)
@ -134,16 +141,18 @@ bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
//remove similar in log
Part myPart = *log.back().PieceCollector[0].second;//tmpsaves bad part
log.back().PieceCollector.erase(log.back().PieceCollector.begin());//removes bad part from log
puzzleMat.removeSimilar(log.back().PieceCollector,myPart); //removes all pieces from log that are similar to bad part
//puzzleMat.removeSimilar(log.back().PieceCollector,myPart); //removes all pieces from log that are similar to bad part
//TODO reprogram similar removal to allow multilayer tracking
if(log.back().PieceCollector.size()) // this checks if 'removeSimilar' has cleared entire LogElement
{
cout << "next Piece" << endl;
if(log.back().PieceCollector.size()==1)
log.back().decreaseRandomed();
setsolution(log,puzzleMat);
return true;
}
}
cout << "more backtrack" << endl;
//else remove log element and backtrack once more
puzzleMat.removeConstrains(log.back().myCoor); //this should remove constraints from all layers
if((log.back().PieceCollector.size())) //unset all
@ -219,6 +228,8 @@ float capLogElements(vector<LogEntry>& log)
vectorsizeAfter = log.back().PieceCollector.size();
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
if(log.back().abstractionLevel==1 && destroyed)
cerr << "destroyed something!" << endl;
return (float)sqrt(destroyed*maxdiff);