diff --git a/README b/README index 0c5b86c6b..68802aed8 100644 --- a/README +++ b/README @@ -1,3 +1,10 @@ +Approximate computation of volume of convex bodies. + +By Vissarion Fisikopoulos, N.K. Univ. Athens, Greece, 2012-2016. +Main algorithm based on: I.Z. Emiris and V. Fisikopoulos, "Efficient random-walk methods for approximating polytope volume", In Proc. ACM Symposium on Computational Geometry 2014, pages 318-325. + +You may redistribute or modify the software under the GNU Lesser General Public License as published by Free Software Foundation, either version 3 of the License, or (at your option) any later version. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, see vol.cpp. + This is an open-source C++ software for computing an approximation of the volume of a polytope given as an intersection of halfspaces. @@ -13,7 +20,6 @@ Follow the CGAL installation manual. It states that CGAL requires the Boost libr $ cmake . $ make - ------------------ 2. Compile sources ------------------ @@ -52,14 +58,14 @@ After successful compilation you can use the software by command line. ./vol -h -will display a help message about the program's available options. +will display a help message about the program's available options. ***Example*** -To estimate the volume of the 10-dimensional hypercube first prepare the file cube.ine as follows: +To estimate the volume of the 10-dimensional hypercube first prepare the file cube10.ine as follows: ====================== -cube_10.ine +cube10.ine H-representation begin 20 11 real @@ -87,9 +93,13 @@ end input_incidence ======================= -The run the following command: +Then run the following command: ./vol -f1 polytope_examples/cube10.ine + +which returns 17 numbers: + +d m #experiments exactvolOr-1 approx [.,.] #randPoints walkLength meanVol [minVol,maxVol] stdDev errorVsExact maxminDivergence time timeChebyshevBall -------------------- 5. Linear extensions @@ -117,5 +127,5 @@ Then running ./vol -fle simple_poset.txt -will give an estimation of the number of linear extensions which is 3. +will give an estimation of the number of linear extensions, which is 3. diff --git a/examples/polytope_examples/cube10.ine b/examples/polytope_examples/cube10.ine index 1a446a4c4..1f035f33c 100644 --- a/examples/polytope_examples/cube10.ine +++ b/examples/polytope_examples/cube10.ine @@ -1,4 +1,4 @@ -cube_10.ine +cube10.ine H-representation begin 20 11 real diff --git a/examples/vol.cpp b/examples/vol.cpp index e5793e4c0..ada1619dd 100644 --- a/examples/vol.cpp +++ b/examples/vol.cpp @@ -36,20 +36,20 @@ int factorial(int n) // oracles. int main(const int argc, const char** argv) -{ +{ //Deafault values - int n, nexp=1, n_threads=1; + int n, nexp=1, n_threads=1; int walk_len;//to be defined after n - double e=1; - double exactvol(-1.0); - bool verbose=false, - rand_only=false, - round_only=false, - file=false, - round=false, - NN=false, - user_walk_len=false, - linear_extensions=false, + double e=1; + double exactvol(-1.0); + bool verbose=false, + rand_only=false, + round_only=false, + file=false, + round=false, + NN=false, + user_walk_len=false, + linear_extensions=false, birk=false, rotate=false, experiments=true, @@ -63,27 +63,28 @@ int main(const int argc, const char** argv) exit(-2); } - //parse command line input vars - for(int i=1;i=0] [epsilon] [walk length] [threads] [num of experiments]\n"<< + "-f1, --file1 [filename_type_Ax<=b] [epsilon] [walk_length] [threads] [num_of_experiments]\n"<< + //"-f2, --file2 [filename_type_Ax=b,x>=0] [epsilon] [walk_length] [threads] [num_of_experiments]\n"<< "-fle, --filele : counting linear extensions of a poset\n"<< - //"-c, --cube [dimension] [epsilon] [walk length] [threads] [num of experiments]\n"<< + //"-c, --cube [dimension] [epsilon] [walk length] [threads] [num_of_experiments]\n"<< "--exact : the exact volume\n"<< "--cube : input polytope is a cube\n"<< "-r, --round : enables rounding of the polytope as a preprocess\n"<< "-ro, --round_only : does only rounding to the polytope\n"<< - "-e, --error [epsilon] : the goal error of approximation\n"<< + "-e, --error epsilon : the goal error of approximation\n"<< "-w, --walk_len [walk_len] : the random walk length (default 10)\n"<< "-exp [#exps] : number of experiments (default 1)\n"<< - "-t, --threads [#threads] : the number of threads to be used\n"<< + "-t, --threads #threads : the number of threads to be used\n"<< "-ΝΝ : use Nearest Neighbor search to compute the boundary oracles\n"<< "-birk_sym : use symmetry to compute more random points (only for Birkhoff polytopes)\n"<< std::endl; @@ -93,12 +94,12 @@ int main(const int argc, const char** argv) exactvol = std::pow(2,n); //exactvol = std::pow(2,n)/std::tgamma(n+1);//factorial of a natural number n is gamma(n+1) correct=true; - } + } if(!strcmp(argv[i],"--exact")){ exactvol = atof(argv[++i]); correct=true; - } - if(!strcmp(argv[i],"-v")||!strcmp(argv[i],"--verbose")){ + } + if(!strcmp(argv[i],"-v")||!strcmp(argv[i],"--verbose")){ verbose=true; std::cout<<"Verbose mode\n"; correct=true; @@ -124,7 +125,7 @@ int main(const int argc, const char** argv) n = Pin[0][1]-1; P.init(Pin); if (verbose && P.num_of_hyperplanes()<100){ - std::cout<<"Input polytope: "<max) max=v1; - if(v1max) max=v1; + if(v1::iterator vit=vs.begin(); vit!=vs.end(); ++vit){ + //Compute Statistics + average=sum/(i+1); + std_dev=0; + for(std::vector::iterator vit=vs.begin(); vit!=vs.end(); ++vit){ std_dev += std::pow(*vit - average,2); - } - std_dev = std::sqrt(std_dev/(i+1)); + } + std_dev = std::sqrt(std_dev/(i+1)); - std::cout.precision(7); + std::cout.precision(7); - //MEMORY USAGE - //struct proc_t usage; - //look_up_our_self(&usage); + //MEMORY USAGE + //struct proc_t usage; + //look_up_our_self(&usage); - //Print statistics - //std::cout<<"\nSTATISTICS:"<begin(); litend() ; ++lit) + std::cout<<" "<<_A.size()<<" "<<_d+1<<" float"<begin(); litend() ; ++lit) std::cout<<*lit<<" "; std::cout< #include +#ifndef BOOST_MATH_CONSTANTS_CONSTANTS_INCLUDED +#include +#endif // Ioannis Emiris + #include //#include @@ -83,23 +87,23 @@ typedef boost::variate_generator< RNGType, boost::normal_distribution<> > gener struct vars{ public: vars( int m, - int n, - int walk_steps, - int n_threads, - const double err, - const double err_opt, - const int lw, - double up, - const int L, - RNGType &rng, - generator - &get_snd_rand, - boost::random::uniform_real_distribution<> urdist, - boost::random::uniform_real_distribution<> urdist1, - bool verbose, - bool rand_only, - bool round, - bool NN, + int n, + int walk_steps, + int n_threads, + const double err, + const double err_opt, + const int lw, + double up, + const int L, + RNGType &rng, + generator + &get_snd_rand, + boost::random::uniform_real_distribution<> urdist, + boost::random::uniform_real_distribution<> urdist1, + bool verbose, + bool rand_only, + bool round, + bool NN, bool birk, bool coordinate ) : @@ -781,10 +785,6 @@ NT volume1_reuse_test(T &P, } - - - - /************************************************* /* VOLUME with random COORDINATES hit and run * Here we reuse the random points we generate @@ -1247,8 +1247,7 @@ template NT volume2(T &P, vars &var) { - typedef BallIntersectPolytope BallPoly; - + typedef BallIntersectPolytope BallPoly; int n = var.n; int rnum = var.m; int walk_len = var.walk_steps;