From a7ce247eb928046335133b47cf7401b7912686f1 Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Mon, 22 Jan 2018 20:09:57 +0100 Subject: [PATCH] debugging --- .../AbstractionLayer_PoempelPosition.cpp | 4 ++-- Source/functions/solve/structure.cpp | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Source/functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.cpp b/Source/functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.cpp index dd2daff..f1edfc8 100644 --- a/Source/functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.cpp +++ b/Source/functions/AbstractionLayers/Layer3_PoempelPosition/AbstractionLayer_PoempelPosition.cpp @@ -73,11 +73,11 @@ float AbstractionLayer_PoempelPosition::PlaceOfPartGood(coor myCoor, vector100) + 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 diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index 84db395..a583e01 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -72,7 +72,7 @@ coor calculateNextCoor(vector& log, Puzzle& puzzleMat) void solve(vector& 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& 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& 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& 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& 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& 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);