diff --git a/CMakeLists.txt b/CMakeLists.txt index c33d144..5be2f98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ # cmake.exe .. -G "Visual Studio 12 2013" # cmake.exe .. -G "Visual Studio 13 2014" # cmake.exe .. -G "Visual Studio 14 2015" +# cmake.exe .. -G "Visual Studio 15 2017" # Recent version of CMake required diff --git a/README.md b/README.md index 7a0fcf4..c5b58b4 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ This project is far from being complete and would benefit greatly from future co ## Credits -Although this project is a joint work, based on the theoretical work in [Barba *et al.*](https://arxiv.org/abs/1208.3663), credits belong to specific authors for part of the implementation. The work covering the implementation of the Stack Algorithm framework, the Comrpessed Stack structure and extras functionalities (```include``` and ```extras``` repositories) has been done by [Jean-Francois Baffier](https://github.com/Azzaarehttps://github.com/Azzaare). All the examples and their generating algorithms, along with all the test have been implemented by [Yago Diez](https://github.com/nicill). +Although this project is a joint work, based on the theoretical work in [Barba *et al.*](https://arxiv.org/abs/1208.3663), credits belong to specific authors for part of the implementation. The work covering the implementation of the Stack Algorithm framework, the Compressed Stack structure and extras functionalities (```include``` and ```extras``` repositories) has been done by [Jean-Francois Baffier](https://github.com/Azzaarehttps://github.com/Azzaare). All the examples and their generating algorithms, along with all the test have been implemented by [Yago Diez](https://github.com/nicill). ## License This project is an open source software under the MIT license. Please check the ```LICENSE``` file for further information. diff --git a/examples/testrun/generateInputTestRun.cpp b/examples/testrun/generateInputTestRun.cpp index cbb85bb..bfec5de 100644 --- a/examples/testrun/generateInputTestRun.cpp +++ b/examples/testrun/generateInputTestRun.cpp @@ -11,6 +11,7 @@ using namespace std; int main(int argc, char *argv[]) { + string fileName = argv[1]; int code = atoi(argv[2]); int stacktype = atoi(argv[3]); @@ -30,9 +31,7 @@ int main(int argc, char *argv[]) { // prob is the // probability to pop - // cout<<":::::::::::::::::::::::::::::::::::::::::::: Going to create file - // with size "< 50) { - if (i % biggest == 0) { - numPops = numPops + pow(5, power + 1); - biggerMultiple = true; - number = 0; - // cerr<<"HEY!!!!!!!!!!!!!!!!!!! setting "< 50) { + if (i % biggest == 0) { + numPops = numPops + pow(5, (float)power + 1); + biggerMultiple = true; + number = 0; + // cerr<<"HEY!!!!!!!!!!!!!!!!!!! setting "< cycle) { + if (i % biggest == 0) { + numPops = numPops + pow(pops, (float) power ); + biggerMultiple = true; + number = 0; + // cerr<<"HEY!!!!!!!!!!!!!!!!!!! setting "<; How to use * argv[1] is the file name * argv[2] is the code of what is to be done - * 0 is a convex hull problem with a compressed stack (with extras) - * 1 is a convex hull problem with a classical stack - * 2 is a convex hull problem with both stacks comparison (check + * 0 is a testrun problem with a compressed stack (with extras) + * 1 is a testrun problem with a classical stack + * 2 is a testrun problem with both stacks comparison (check errors) * argv[3] is the code for the integer size * 8 is for 8 bits integer (or smallest size handling 8 bits) @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { stack.printCompare(); } else { stack.run(); - //stack.println(); + // stack.println(); } break; } @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) { stack.printCompare(); } else { stack.run(); - // stack.println(); + // stack.println(); } break; } @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) { stack.printCompare(); } else { stack.run(); - //stack.println(); + // stack.println(); } break; } @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) { stack.printCompare(); } else { stack.run(); - // stack.println(); + // stack.println(); } } return 0; diff --git a/extras/classicStack.hpp b/extras/classicStack.hpp index a9e7d22..a167a0e 100644 --- a/extras/classicStack.hpp +++ b/extras/classicStack.hpp @@ -51,6 +51,7 @@ class ClassicStack : public Stack { Block getFirstBlock(); I getBufferSize(); I getBufferLength(); + std::vector getReconstructions(); }; /*============================================================================== @@ -129,6 +130,11 @@ Block ClassicStack::getFirstBlock() { return block; } +template +std::vector ClassicStack::getReconstructions() { + return std::vector(0); +} + /*============================================================================== IO : toString ==============================================================================*/ diff --git a/extras/stackAlgoExtras.hpp b/extras/stackAlgoExtras.hpp index 3687a81..b37088b 100644 --- a/extras/stackAlgoExtras.hpp +++ b/extras/stackAlgoExtras.hpp @@ -118,6 +118,9 @@ void StackAlgoExtras::readPushCompare(I iter) { template void StackAlgoExtras::pushStepCompare(D data) { if (pushCondition(data)) { + StackAlgo::mCountPushes++; + StackAlgo::mMaxItems = std::max(StackAlgo::mMaxItems, + StackAlgo::countItems()); Data elt(StackAlgo::mIndex, data); prePush(elt); StackAlgo::push(elt); @@ -141,6 +144,7 @@ template void StackAlgoExtras::popLoopCompare(D data) { while (!StackAlgo::emptystack()) { if (popCondition(data)) { + StackAlgo::mCountPops++; prePop(data); Data elt = StackAlgo::pop(); Data eltNormal = mClassicStack->pop(); diff --git a/include/compressedStack.hpp b/include/compressedStack.hpp index 05f0b36..df73004 100644 --- a/include/compressedStack.hpp +++ b/include/compressedStack.hpp @@ -97,6 +97,7 @@ class CompressedStack : public Stack { SPData getExplicitData(I k); Level getSmartCompress(std::intmax_t lvl); Block getBottomBlock(); + std::vector getReconstructions(); // Structure constraints I mSize; // (Expected) size of the input in #elements @@ -469,6 +470,11 @@ I CompressedStack::getBufferLength() { return mBuffer.mExplicit.size(); } +template +std::vector CompressedStack::getReconstructions() { + return mReconstructions; +} + /*============================================================================== IO : toString ==============================================================================*/ diff --git a/include/stack.hpp b/include/stack.hpp index 329399c..cfeea26 100644 --- a/include/stack.hpp +++ b/include/stack.hpp @@ -38,6 +38,7 @@ template class Stack { virtual Block getFirstBlock() = 0; virtual I getBufferSize() = 0; virtual I getBufferLength() = 0; + virtual std::vector getReconstructions() = 0; // Setters virtual void setContext(std::shared_ptr context) = 0; diff --git a/include/stackAlgo.hpp b/include/stackAlgo.hpp index 8123a64..2385b63 100644 --- a/include/stackAlgo.hpp +++ b/include/stackAlgo.hpp @@ -47,13 +47,17 @@ template class StackAlgo { // Getters T getContext(); - I getIndex(); + I getMaxItems(); + I getPushes(); + I getPops(); + std::vector getReconstructions(); // IO std::string toString(); void print(); void println(); + I countItems(); void readPush(I iter = 1); // protected: @@ -61,6 +65,9 @@ template class StackAlgo { std::vector readLine(); std::vector readHeader(); I mIndex; + I mMaxItems; + I mCountPops; + I mCountPushes; // private: // Input/Ouput @@ -95,7 +102,8 @@ template class StackAlgo { ==============================================================================*/ template StackAlgo::StackAlgo(std::string fileName, bool usecompressed) - : mIndex(0), mContext(nullptr) { + : mIndex(0), mMaxItems(0), mCountPops(0), mCountPushes(0), + mContext(nullptr) { mInput.open(fileName, std::ifstream::in); std::vector parameters = readHeader(); @@ -132,7 +140,10 @@ template std::string StackAlgo::toString() { std::string str; str = "Instance with an actual index of " + std::to_string(mIndex); - str += ", with a stack of type\n"; + str += ", with " + std::to_string(countItems()) + " elements ("; + str += std::to_string(getPushes()) + " - " + std::to_string(getPops()) + ")"; + str += ", a maximum size of " + std::to_string(getMaxItems()) + " elements"; + str += ", and a stack of type\n"; str += mStack->toString(); return str; } @@ -203,6 +214,7 @@ template void StackAlgo::readPush(I iter) { template void StackAlgo::popLoop(D data) { while (!emptystack()) { if (popCondition(data)) { + mCountPops++; prePop(data); Data elt = pop(); postPop(data, elt); @@ -215,6 +227,8 @@ template void StackAlgo::popLoop(D data) { template void StackAlgo::pushStep(D data) { if (pushCondition(data)) { + mCountPushes++; + mMaxItems = std::max(mMaxItems, countItems()); Data elt(mIndex, data); prePush(elt); push(elt); @@ -316,4 +330,25 @@ template I StackAlgo::getIndex() { return mIndex; } +template I StackAlgo::getPops() { + return mCountPops; +} + +template I StackAlgo::getPushes() { + return mCountPushes; +} + +template I StackAlgo::countItems() { + return mCountPushes - mCountPops; +} + +template I StackAlgo::getMaxItems() { + return mMaxItems; +} + +template +std::vector StackAlgo::getReconstructions() { + return mStack.getReconstructions(); +} + #endif /* STACKALGO */