debugging
This commit is contained in:
parent
7979d28422
commit
a7ce247eb9
@ -73,11 +73,11 @@ float AbstractionLayer_PoempelPosition::PlaceOfPartGood(coor myCoor, vector<doub
|
|||||||
sum+=abs(comparePosition[5]-myPart[5]);
|
sum+=abs(comparePosition[5]-myPart[5]);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(sum>100)
|
if(sum>500)
|
||||||
return 0;
|
return 0;
|
||||||
if(sum==0)
|
if(sum==0)
|
||||||
return 1;
|
return 1;
|
||||||
sum/=100;
|
sum/=500;
|
||||||
return 1-sum;
|
return 1-sum;
|
||||||
//check vector against negative part, use sad
|
//check vector against negative part, use sad
|
||||||
//return of well it fits within threshold
|
//return of well it fits within threshold
|
||||||
|
@ -72,7 +72,7 @@ coor calculateNextCoor(vector<LogEntry>& log, Puzzle& puzzleMat)
|
|||||||
void solve(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
|
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);
|
//status(log,p_Box,puzzleMat);
|
||||||
//TODO!! Add more layers here
|
//TODO!! Add more layers here
|
||||||
switch(log.back().abstractionLevel)
|
switch(log.back().abstractionLevel)
|
||||||
@ -80,16 +80,21 @@ void solve(vector<LogEntry>& log,Puzzle& puzzleMat)
|
|||||||
case 0://pömpel
|
case 0://pömpel
|
||||||
puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
puzzleMat.a1.EvaluateQuality(log.back().myCoor, log.back().PieceCollector);
|
||||||
break;
|
break;
|
||||||
case 1://histogram
|
case 1://poempelposition
|
||||||
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
|
puzzleMat.a3.EvaluateQuality(log.back().myCoor,log.back().PieceCollector);
|
||||||
break;
|
break;
|
||||||
case -1://random
|
case -1://random
|
||||||
|
cout << endl;
|
||||||
setsolution(log,puzzleMat);
|
setsolution(log,puzzleMat);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
float worth = capLogElements(log);
|
float worth = capLogElements(log);
|
||||||
|
cout << " | " << worth << endl;
|
||||||
|
if(worth && log.back().abstractionLevel)
|
||||||
|
cerr << "removed something!" << endl;
|
||||||
|
|
||||||
calculateTrueDestructionPower(log,puzzleMat, worth);
|
calculateTrueDestructionPower(log,puzzleMat, worth);
|
||||||
CalculateNewCombinedQuality(log, log.back().PieceCollector, puzzleMat.combinedQualityVector);
|
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);
|
puzzleMat.setConstraints(log.back().myCoor,log.back().PieceCollector.begin()->second);
|
||||||
cout << "set:" << log.back().myCoor.col << "," << log.back().myCoor.row << endl;
|
cout << "set:" << log.back().myCoor.col << "," << log.back().myCoor.row << endl;
|
||||||
//cout << "ID: " << log.back().PieceCollector[0].second->GetPartID() << 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)
|
bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
|
||||||
{
|
{
|
||||||
|
cout << "backtrack" << endl;
|
||||||
if(log.empty())
|
if(log.empty())
|
||||||
{
|
{
|
||||||
cout << "Puzzle not solveable!" << endl;
|
cout << "Puzzle not solveable!" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
cout << "Size of Log: " << log.back().PieceCollector.size() << endl;
|
||||||
puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save
|
puzzleMat.combinedQualityVector.clear(); //remove all data from temp quality save
|
||||||
//if more pieces possible, tset piece as not logged
|
//if more pieces possible, tset piece as not logged
|
||||||
if((log.back().PieceCollector.size())>1)
|
if((log.back().PieceCollector.size())>1)
|
||||||
@ -134,16 +141,18 @@ bool backtrack(vector<LogEntry>& log, Puzzle& puzzleMat)
|
|||||||
//remove similar in log
|
//remove similar in log
|
||||||
Part myPart = *log.back().PieceCollector[0].second;//tmpsaves bad part
|
Part myPart = *log.back().PieceCollector[0].second;//tmpsaves bad part
|
||||||
log.back().PieceCollector.erase(log.back().PieceCollector.begin());//removes bad part from log
|
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
|
//TODO reprogram similar removal to allow multilayer tracking
|
||||||
if(log.back().PieceCollector.size()) // this checks if 'removeSimilar' has cleared entire LogElement
|
if(log.back().PieceCollector.size()) // this checks if 'removeSimilar' has cleared entire LogElement
|
||||||
{
|
{
|
||||||
|
cout << "next Piece" << endl;
|
||||||
if(log.back().PieceCollector.size()==1)
|
if(log.back().PieceCollector.size()==1)
|
||||||
log.back().decreaseRandomed();
|
log.back().decreaseRandomed();
|
||||||
setsolution(log,puzzleMat);
|
setsolution(log,puzzleMat);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cout << "more backtrack" << endl;
|
||||||
//else remove log element and backtrack once more
|
//else remove log element and backtrack once more
|
||||||
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())) //unset all
|
if((log.back().PieceCollector.size())) //unset all
|
||||||
@ -219,6 +228,8 @@ float capLogElements(vector<LogEntry>& log)
|
|||||||
|
|
||||||
vectorsizeAfter = log.back().PieceCollector.size();
|
vectorsizeAfter = log.back().PieceCollector.size();
|
||||||
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
|
destroyed = ((double)vectorsizeBefore - (double)vectorsizeAfter) / (double)vectorsizeBefore;
|
||||||
|
if(log.back().abstractionLevel==1 && destroyed)
|
||||||
|
cerr << "destroyed something!" << endl;
|
||||||
return (float)sqrt(destroyed*maxdiff);
|
return (float)sqrt(destroyed*maxdiff);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user