1 /*
2 * valuation.cpp
3 *
4 * Created on: Jun 24, 2010
5 * Author: Brandon Dutra and Gregory Pinto
6 */
7
8 #include "valuation.h"
9 #include <iomanip>
10
11 //defines the input file/string.
12
13 /**
14 * Computes the volume of the polytope.
15 * The triangulation method will not change the org. polytope, but the
16 * lawrence method will dilate it.
17 */
computeVolume(Polyhedron * poly,BarvinokParameters & myParameters,const IntegrationInput & intInput,const char * print)18 Valuation::ValuationContainer Valuation::computeVolume(Polyhedron * poly,
19 BarvinokParameters &myParameters, const IntegrationInput &intInput,
20 const char * print)
21 {
22 ValuationContainer ans;
23 RationalNTL ans1, ans2;
24 Polyhedron * poly2;
25
26 if ( intInput.volumeCone && intInput.volumeTriangulation)
27 poly2 = new Polyhedron(*poly);
28 else
29 poly2 = poly;
30
31 if (intInput.volumeTriangulation)
32 {
33 ValuationData timer_and_result;
34 PolytopeValuation polytopeValuation(poly, myParameters);
35 timer_and_result.timer.start();
36 ans1 = polytopeValuation.findVolume(
37 PolytopeValuation::volumeTriangulation);
38 timer_and_result.timer.stop();
39
40 timer_and_result.valuationType = PolytopeValuation::volumeTriangulation;
41 timer_and_result.answer = ans1;
42 ans.add(timer_and_result);
43 }//if triangulate. origional polytope should not have changed.
44
45 if (intInput.volumeCone)
46 {
47 ValuationData timer_and_result;
48 PolytopeValuation polytopeValuation(poly2, myParameters);
49 timer_and_result.timer.start();
50 ans2 = polytopeValuation.findVolume(PolytopeValuation::volumeCone);
51 timer_and_result.timer.stop();
52
53 if (*print == 'y')
54 polytopeValuation.printLawrenceVolumeFunction(); //print the lawrence rational function.
55
56 timer_and_result.valuationType = PolytopeValuation::volumeCone;
57 timer_and_result.answer = ans2;
58 ans.add(timer_and_result);
59 }//if lawrence. Origional polytope is now dilated.
60
61 if (intInput.volumeCone && intInput.volumeTriangulation && ans1 != ans2)
62 {
63 cerr << "valuation.cpp: the two volume methods are different." << endl;
64 cerr << "Cone-decompose: " << ans2 << endl;
65 cerr << "Triangulation: " << ans1 << endl;
66 THROW_LATTE_MSG( LattException::bug_Unknown, 1, "volume computed by both methods are different. Please send bug report" );
67 }//if error.
68 else if (intInput.volumeCone && intInput.volumeTriangulation)
69 delete poly2;
70
71 return ans;
72 }//computeVolume
73
74 /**
75 * Computes the integral over the polytope.
76 *
77 * Both the triangulation and lawrence methods will dilate/change the org. polytope.
78 */
computeIntegral(Polyhedron * poly,BarvinokParameters & myParameters,const IntegrationInput & intInput)79 Valuation::ValuationContainer Valuation::computeIntegral(Polyhedron *poly,
80 BarvinokParameters &myParameters, const IntegrationInput & intInput)
81 {
82 if ( intInput.integrandType == IntegrationInput::inputPolynomial)
83 {
84 return computeIntegralPolynomial(poly, myParameters, intInput);
85 } else if ( intInput.integrandType == IntegrationInput::inputLinearForm)
86 {
87 return computeIntegralLinearForm(poly, myParameters, intInput);
88 } else if ( intInput.integrandType == IntegrationInput::inputProductLinearForm)
89 {
90 return computeIntegralProductLinearForm(poly, myParameters, intInput);
91 }
92 else
93 {
94 THROW_LATTE_MSG(LattException::bug_Unknown, 1, "integrand type not supported.");
95 }
96 }
computeIntegralPolynomial(Polyhedron * poly,BarvinokParameters & myParameters,const IntegrationInput & intInput)97 Valuation::ValuationContainer Valuation::computeIntegralPolynomial(Polyhedron *poly,
98 BarvinokParameters &myParameters, const IntegrationInput & intInput)
99 {
100 ValuationContainer answer;
101 ValuationData tiangulate_timer_and_result;
102 ValuationData lawrence_timer_and_result;
103 ValuationData plf_time_and_result;
104 RationalNTL ans1, ans2, ans3, ans4;
105 Polyhedron *polyCopy;//if doing more than 1 method, make a deep copy of the original polytope
106
107 assert(intInput.integrandType == IntegrationInput::inputPolynomial);
108
109
110 if (intInput.integratePolynomialAsLinearFormTriangulation)
111 {
112 if(intInput.integratePolynomial)
113 polyCopy = new Polyhedron(*poly);
114 else
115 polyCopy = poly;
116 cerr << "Going to run the triangulation integration method" << endl;
117 PolytopeValuation polytopeValuation(polyCopy, myParameters);
118
119 monomialSum originalPolynomial;// polynomial without the updated coefficients.
120 loadMonomials(originalPolynomial, intInput.integrand); //get the polynomial from the string.
121
122 tiangulate_timer_and_result.timer.start();
123 ans1 = polytopeValuation.findIntegral(originalPolynomial,
124 PolytopeValuation::integratePolynomialAsLinearFormTriangulation);
125 tiangulate_timer_and_result.timer.stop();
126
127 tiangulate_timer_and_result.valuationType
128 = PolytopeValuation::integratePolynomialAsLinearFormTriangulation;
129 tiangulate_timer_and_result.answer = ans1;
130 answer.add(tiangulate_timer_and_result);
131
132 destroyMonomials(originalPolynomial);
133
134 if (intInput.integratePolynomial)
135 delete polyCopy;
136 }//if doing triangulation method.
137
138
139 if (intInput.integratePolynomialAsLinearFormCone)
140 {
141 cerr << "Going to run the cone-decomposition integration method" << endl;
142
143 if(intInput.integratePolynomial)
144 polyCopy = new Polyhedron(*poly);
145 else
146 polyCopy = poly;
147
148 monomialSum originalPolynomial;// polynomial without the updated coefficients.
149 PolytopeValuation polytopeValuation(polyCopy, myParameters);
150
151 loadMonomials(originalPolynomial, intInput.integrand); //get the polynomial from the string.
152 lawrence_timer_and_result.timer.start();
153 ans2 = polytopeValuation.findIntegral(originalPolynomial,
154 PolytopeValuation::integratePolynomialAsLinearFormCone);
155 lawrence_timer_and_result.timer.stop();
156
157 lawrence_timer_and_result.valuationType
158 = PolytopeValuation::integratePolynomialAsLinearFormCone;
159 lawrence_timer_and_result.answer = ans2;
160 answer.add(lawrence_timer_and_result);
161
162 destroyMonomials(originalPolynomial);
163
164 if(intInput.integratePolynomial)
165 delete polyCopy;
166 }
167
168 if ( intInput.integratePolynomialAsPLFTriangulation )
169 {
170 cerr << "Going to run the polynomial to PLF method" << endl;
171
172 if(intInput.integratePolynomial)
173 polyCopy = new Polyhedron(*poly);
174 else
175 polyCopy = poly;
176
177 monomialSum originalPolynomial;// polynomial without the updated coefficients.
178 PolytopeValuation polytopeValuation(polyCopy, myParameters);
179
180 loadMonomials(originalPolynomial, intInput.integrand); //get the polynomial from the string.
181 plf_time_and_result.timer.start();
182 ans3 = polytopeValuation.findIntegral(originalPolynomial,
183 PolytopeValuation::integratePolynomialAsPLFTriangulation);
184 plf_time_and_result.timer.stop();
185
186 plf_time_and_result.valuationType
187 = PolytopeValuation::integratePolynomialAsPLFTriangulation;
188 plf_time_and_result.answer = ans3;
189 answer.add(plf_time_and_result);
190
191 destroyMonomials(originalPolynomial);
192
193 if(intInput.integratePolynomial)
194 delete polyCopy;
195 }//polynomial to PLF.
196
197
198 if (intInput.integratePolynomial && (ans1 != ans2 || ans1 != ans3 ) )
199 {
200 cerr << "Valuation.cpp: the methods are different.\n"
201 << "triangulateion : " << ans1 << "\n"
202 << "cone-decomposition: " << ans2 << "\n"
203 << "prod linear form : " << ans3 << "\n"
204 << endl;
205 THROW_LATTE_MSG(LattException::bug_Unknown, 1, "The integrals are different. Please send bug report.");
206 }//if error.
207
208
209 return answer;
210 }//computeIntegral
211
212
213
computeIntegralLinearForm(Polyhedron * poly,BarvinokParameters & myParameters,const IntegrationInput & intInput)214 Valuation::ValuationContainer Valuation::computeIntegralLinearForm(Polyhedron *poly,
215 BarvinokParameters &myParameters, const IntegrationInput & intInput)
216 {
217 ValuationContainer answer;
218 ValuationData tiangulate_timer_and_result;
219 ValuationData lawrence_timer_and_result;
220 ValuationData product_time_and_result;
221 RationalNTL ans1, ans2;
222 Polyhedron *poly2 = poly;//if doing both methods, make a deep copy of the origional polytopel.
223
224 assert(intInput.integrandType == IntegrationInput::inputLinearForm);
225
226 if (intInput.integrateLinearFormCone && intInput.integrateLinearFormTriangulation)
227 {
228 poly2 = new Polyhedron(*poly); //copy org. polytope, because it will be dilated.
229 }
230
231 if (intInput.integrateLinearFormTriangulation)
232 {
233 cerr << "Going to run the triangulation integration method on linear forms" << endl;
234 PolytopeValuation polytopeValuation(poly, myParameters);
235
236
237 linFormSum originalLinearForm;
238 loadLinForms(originalLinearForm, intInput.integrand);
239
240 tiangulate_timer_and_result.timer.start();
241 ans1 = polytopeValuation.findIntegral(originalLinearForm,
242 PolytopeValuation::integrateLinearFormTriangulation);
243 tiangulate_timer_and_result.timer.stop();
244
245 tiangulate_timer_and_result.valuationType
246 = PolytopeValuation::integrateLinearFormTriangulation;
247 tiangulate_timer_and_result.answer = ans1;
248 answer.add(tiangulate_timer_and_result);
249
250 destroyLinForms(originalLinearForm);
251 }//if doing triangulation method.
252
253
254 if (intInput.integrateLinearFormCone)
255 {
256 cerr << "Going to run the cone-decomposition integration method on linear forms" << endl;
257
258 linFormSum originalLinearForm;// polynomial without the updated coefficients.
259 PolytopeValuation polytopeValuation(poly2, myParameters);
260
261 loadLinForms(originalLinearForm, intInput.integrand); //get the polynomial from the string.
262 lawrence_timer_and_result.timer.start();
263 ans2 = polytopeValuation.findIntegral(originalLinearForm,
264 PolytopeValuation::integrateLinearFormCone);
265 lawrence_timer_and_result.timer.stop();
266
267 lawrence_timer_and_result.valuationType
268 = PolytopeValuation::integrateLinearFormCone;
269 lawrence_timer_and_result.answer = ans2;
270 answer.add(lawrence_timer_and_result);
271
272 destroyLinForms(originalLinearForm);
273 }
274
275 if (intInput.integrateLinearFormTriangulation && intInput.integrateLinearFormCone && ans1 != ans2)
276 {
277 cerr << "computeIntegralLinearForm(): the two methods are different.\n"
278 << "triangulation: " << ans1 << "\nlawrence " << ans2
279 << endl;
280 THROW_LATTE_MSG(LattException::bug_Unknown, 1, "The integrals are different. Please send bug report");
281 }//if error.
282 if (intInput.integrateLinearFormTriangulation && intInput.integrateLinearFormCone)
283 {
284 delete poly2;
285 }//delete the copy we made.
286
287 return answer;
288 }//computeIntegralLinearForm
289
computeIntegralProductLinearForm(Polyhedron * poly,BarvinokParameters & myParameters,const IntegrationInput & intInput)290 Valuation::ValuationContainer Valuation::computeIntegralProductLinearForm(Polyhedron *poly,
291 BarvinokParameters &myParameters, const IntegrationInput & intInput)
292 {
293 ValuationContainer answer;
294 ValuationData product_time_and_result;
295 RationalNTL ans1;
296
297
298 assert(intInput.integrandType == IntegrationInput::inputProductLinearForm);
299
300 cerr << "Going to run the product of linear forms method" << endl;
301 PolytopeValuation polytopeValuation(poly, myParameters);
302
303 linFormProductSum originalProducts;
304 loadLinFormProducts(originalProducts, intInput.integrand);
305
306
307 //cout << "integrand string:" << intInput.integrand.c_str() << endl;
308 //cout << "integrand load :" << printLinFormProducts(originalProducts).c_str();
309 //exit(1);
310
311
312
313
314 product_time_and_result.timer.start();
315 ans1 = polytopeValuation.findIntegral(originalProducts, PolytopeValuation::integrateProductLinearFormsTriangulation);
316 product_time_and_result.timer.stop();
317
318 product_time_and_result.valuationType = PolytopeValuation::integrateProductLinearFormsTriangulation;
319 product_time_and_result.answer = ans1;
320 answer.add(product_time_and_result);
321
322 destroyLinFormProducts(originalProducts);
323 return answer;
324 }//computeIntegralProductLinearForm
325
computeTopEhrhart(Polyhedron * poly,BarvinokParameters & myParameters,const IntegrationInput & intInput)326 void Valuation::computeTopEhrhart(Polyhedron *poly,
327 BarvinokParameters &myParameters, const IntegrationInput & intInput)
328 {
329 ValuationContainer answer;
330 ValuationData timer_and_result;
331 RationalNTL ans;
332
333
334 if (intInput.integrandType == IntegrationInput::inputPolynomial)
335 {
336 TopEhrhart topEhrhart(poly, myParameters, intInput.numEhrhartCoefficients, intInput.realDilations, intInput.saveTopEhrhartPolynomial);
337
338 monomialSum originalPolynomial;// polynomial without the updated coefficients.
339 loadMonomials(originalPolynomial, intInput.integrand); //get the polynomial from the string.
340 topEhrhart.computeTopEhrhartPolynomial(originalPolynomial);
341
342 destroyMonomials(originalPolynomial);
343 }//the weight is a polynomial
344 else if ( intInput.integrandType == IntegrationInput::inputLinearForm)
345 {
346 linFormSum originalLinearForm;// polynomial without the updated coefficients.
347
348 TopEhrhart topEhrhart(poly, myParameters, intInput.numEhrhartCoefficients, intInput.realDilations, intInput.saveTopEhrhartPolynomial);
349
350 loadLinForms(originalLinearForm, intInput.integrand); //get the polynomial from the string.
351
352 topEhrhart.computeTopEhrhartPolynomial(originalLinearForm);
353
354 destroyLinForms(originalLinearForm);
355 }//the weight is a power of a linear form.
356 else if (intInput.unweightedCounting == true)
357 {
358 TopEhrhart topEhrhart(poly, myParameters, intInput.numEhrhartCoefficients, intInput.realDilations, intInput.saveTopEhrhartPolynomial);
359 topEhrhart.computeTopEhrhartPolynomial();
360 }
361 else
362 {
363 THROW_LATTE_MSG(LattException::bug_NotImplementedHere, 1, "integrand type not supported");
364 }
365
366 }//computeTopEhrhart
367
368
usage(const char * progname)369 static void Valuation::usage(const char *progname)
370 {
371 cerr << "usage: " << progname << " [OPTIONS...] " << "INPUTFILE" << endl;
372 cerr << "Type `" << progname << " --help' "
373 << "for a list of options and input specifications." << endl;
374 }
375
376 /**
377 * The main function and reads in the polytope and computes a valuation.
378 */
mainValuationDriver(const char * argv[],int argc)379 Valuation::ValuationContainer Valuation::mainValuationDriver(
380 const char *argv[], int argc)
381 {
382 ValuationContainer valuationAnswers;
383 IntegrationInput integrationInput;
384 set_program_name(argv[0]);
385
386 int i;
387 unsigned int flags = 0, print_flag = 0, output_cone = 0;
388 char printfile[127], Save_Tri[127], Load_Tri[127], Print[127],
389 removeFiles[127];
390 char printLawrence[127];
391 bool approx;
392 bool ehrhart_polynomial, ehrhart_series, ehrhart_taylor;
393 bool triangulation_specified = false;
394 bool useStokes = false;
395 double sampling_factor = 1.0;
396 long int num_samples = -1;
397
398 //options used by top ehrhart
399 bool interactiveLatte = false; //only in the case of top ehrhart do we look at this value.
400
401 ReadPolyhedronData read_polyhedron_data;
402
403 struct BarvinokParameters *params = new BarvinokParameters;
404
405 latte_banner(cerr);
406
407 if (argc < 2)
408 {
409 usage(argv[0]);
410 THROW_LATTE( LattException::ue_BadCommandLineOption, 0);
411 }
412
413 //setbuf(stdout,0);
414
415 cerr << "Invocation: ";
416 for (i = 0; i < argc; i++)
417 {
418 cerr << argv[i] << " ";
419 }
420 cerr << endl;
421
422 strcpy(removeFiles, "yes");
423 strcpy(printfile, "no");
424 strcpy(Save_Tri, "no");
425 strcpy(Load_Tri, "no");
426 strcpy(Print, "no");
427 strcpy(printLawrence, "no");
428 approx = false;
429 ehrhart_polynomial = false;
430 params->substitution = BarvinokParameters::PolynomialSubstitution;
431 //params->decomposition = BarvinokParameters::DualDecomposition;
432 params->decomposition
433 = BarvinokParameters::IrrationalAllPrimalDecomposition;
434 // params->triangulation = BarvinokParameters::RegularTriangulationWithCdd;
435 params->max_determinant = 1;
436
437 for (i = 1; i < argc; i++)
438 {
439 //cout << "currently doing " << argv[i] << "." << endl;
440 if (strncmp(argv[i], "nodecom", 3) == 0 || strncmp(argv[i],
441 "--nodecomposition", 5) == 0 || strncmp(argv[i],
442 "--no-decomposition", 7) == 0)
443 params->max_determinant = 0;
444 else if (strncmp(argv[i], "uni", 3) == 0)
445 strcpy(read_polyhedron_data.assumeUnimodularCones, "yes");
446 //else if(strncmp(argv[i],"simp",4)==0) {strcpy(printfile,"yes"); flags |= PRINT;}
447 else if (strncmp(argv[i], "file", 4) == 0)
448 strcpy(read_polyhedron_data.Memory_Save, "no");
449 //else if(strncmp(argv[i],"single",6)==0) strcpy(Singlecone,"yes");
450 //else if(strncmp(argv[i],"ehrhartsimp",3)==0) strcpy(rationalCone,"yes");
451 else if (strncmp(argv[i], "memsave", 7) == 0)
452 strcpy(read_polyhedron_data.Memory_Save, "yes");
453 else if (strncmp(argv[i], "printcones", 3) == 0)
454 strcpy(Print, "yes");
455 //else if(strncmp(argv[i],"hull",3)==0) strcpy (inthull, "yes");
456 else if (strncmp(argv[i], "rem", 3) == 0)
457 {
458 strcpy(removeFiles, "no");
459 strcpy(read_polyhedron_data.Memory_Save, "no");
460 } else if (strncmp(argv[i], "trisave", 7) == 0)
461 {
462 strcpy(Save_Tri, "yes");
463 flags |= SAVE;
464 } else if (strncmp(argv[i], "triload", 7) == 0)
465 {
466 strcpy(Load_Tri, "yes");
467 flags |= LOAD;
468 } else if (strncmp(argv[i], "--exponential", 5) == 0)
469 params->substitution = BarvinokParameters::ExponentialSubstitution;
470 else if (strcmp(argv[i], "--polynomial") == 0)
471 params->substitution = BarvinokParameters::PolynomialSubstitution;
472 else if (strncmp(argv[i], "--maxdet=", 9) == 0)
473 params->max_determinant = atoi(argv[i] + 9);
474 else if (strncmp(argv[i], "--irrational-all-primal", 14) == 0
475 || strncmp(argv[i], "--all-primal", 5) == 0)
476 params->decomposition
477 = BarvinokParameters::IrrationalAllPrimalDecomposition;
478 else if (strncmp(argv[i], "--irrational-primal", 5) == 0)
479 params->decomposition
480 = BarvinokParameters::IrrationalPrimalDecomposition;
481 else if (strcmp(argv[i], "--dual") == 0) // Don't use strncmp to
482 // avoid clash with --dualization=...
483 params->decomposition = BarvinokParameters::DualDecomposition;
484 else if (strncmp(argv[i], "--count-lattice-points", 7) == 0)
485 {
486 // Default.
487 } else if (strncmp(argv[i], "--multivariate-generating-function", 7)
488 == 0)
489 {
490 params->substitution = BarvinokParameters::NoSubstitution;
491 } else if (strncmp(argv[i], "--ehrhart-polynomial", 11) == 0)
492 {
493 ehrhart_polynomial = true;
494 params->substitution = BarvinokParameters::ExponentialSubstitution;
495 } else if (strncmp(argv[i], "--ehrhart-series", 11) == 0)
496 {
497 ehrhart_series = true;
498 strcpy(read_polyhedron_data.dualApproach, "yes");
499 strcpy(printfile, "yes");
500 flags |= PRINT;
501 } else if (strncmp(argv[i], "--simplified-ehrhart-series", 14) == 0)
502 {
503 ehrhart_series = true;
504 strcpy(read_polyhedron_data.dualApproach, "yes");
505 strcpy(read_polyhedron_data.rationalCone, "yes");
506 } else if (strncmp(argv[i], "--ehrhart-taylor=", 17) == 0)
507 {
508 strcpy(read_polyhedron_data.taylor, "yes");
509 read_polyhedron_data.degree = atoi(argv[i] + 17);
510 strcpy(read_polyhedron_data.dualApproach, "yes");
511 } else if (strncmp(argv[i], "--avoid-singularities", 7) == 0)
512 {
513 params->shortvector = BarvinokParameters::SubspaceAvoidingLLL;
514 } else if (parse_standard_triangulation_option(argv[i], params))
515 {
516 if (strncmp(argv[i], "--triangulation=", 16) == 0)
517 triangulation_specified = true;
518 } else if (parse_standard_dualization_option(argv[i], params))
519 {
520 } else if (parse_standard_smith_option(argv[i], params))
521 {
522 } else if (strncmp(argv[i], "--approximate", 7) == 0)
523 approx = true;
524 else if (strncmp(argv[i], "--sampling-factor=", 18) == 0)
525 sampling_factor = atof(argv[i] + 18);
526 else if (strncmp(argv[i], "--num-samples=", 14) == 0)
527 num_samples = atol(argv[i] + 14);
528 else if (strncmp(argv[i], "--random-seed=", 14) == 0)
529 {
530 unsigned int seed = atoi(argv[i] + 14);
531 seed_random_generator(seed);
532 } else if (strcmp(argv[i], "--help") == 0)
533 {
534 read_polyhedron_data.show_options(cerr);
535 cerr << "Options that control what to compute:" << endl
536 << " --valuation=volume Computes the volume\n"
537 << " --valuation=integrate Computes an integral\n"
538 << " --valuation=top-ehrhart Computes the top weighted Ehrhart coefficients\n"
539 << "volume and integration and options:\n"
540 << " --cone-decompose Computes the valuation using tangent cones\n"
541 << " --triangulate Computes the valuation over a triangulation.\n"
542 << " --all Computes the using all the two methods above.\n"
543 << "\n"
544 << "integration and weighted summation options:\n"
545 << " --monomials=FILE Looks at the first line of file for a polynomial\n"
546 << " encoded in maple-syntax: [ [coef, [exponent vector]], ...]\n"
547 << " --linear-forms=FILE Looks at the first line of file for a sum of powers of linear forms\n"
548 << " encoded in maple-syntax: [ [coef, [power, [linear form]]], ...]\n"
549 << " --product-linear-forms=FILE Looks at the first line of file for a product of linear forms\n"
550 << " in maple-syntax: [ [coef, [[power, [linear form]],\n"
551 << " [power, [linear form]], ...]], ...] \n"
552 /// FIXME: Add further options!
553 << " If cannot open file, the line is read from std in.\n"
554 << "top Ehrhart options:\n"
555 << " --num-coefficients=K Number of highest Ehrhart coefficients to compute\n"
556 << " (default: compute all, incrementally)\n"
557 << " --real-dilations Output formulas valid for real dilations also\n"
558 << " --top-ehrhart-save=FILE Writes the Ehrhart polynomial to the file.\n"
559 << " --top-ehrhart-unweighted The weight function is assumed to be 1 (default)\n"
560 << " --interactive-mode Print the screen asking for an integrand type,\n"
561 << " Only polynomials and linear forms are valid.\n"
562 << "Example: " << argv[0]
563 << " --valuation=volume --cone-decompose file.latte\n"
564 << " (will compute the volume using the cone-decomposition method over the polytope in file.latte.)\n"
565 << "Example: " << argv[0]
566 << " --valuation=integrate --monomials=poly.txt file.latte\n"
567 << " (will compute the integral of the polynomial in poly.txt over the polytope in file.latte.)\n"
568 << "Example: " << argv[0]
569 << " --valuation=top-ehrhart --num-coefficients=4 --real-dilations --monomials=poly.txt file.latte\n"
570 << " (will compute the top 4 Ehrhart coefficients with a polynomial weight in poly.txt over the polytope in file.latte.)\n"
571
572 << endl;
573 exit(0);
574 } else if ( strncmp(argv[i], "--valuation=", 11) == 0)
575 {
576 if ( strcmp(argv[i], "--valuation=volume") == 0)
577 integrationInput.valuationVolume = true;
578 else if ( strcmp(argv[i], "--valuation=integrate") == 0)
579 integrationInput.valuationIntegrate = true;
580 else if ( strcmp(argv[i], "--valuation=top-ehrhart") == 0)
581 {
582 integrationInput.valuationEhrhart = true;
583 integrationInput.unweightedCounting = true;
584 }
585 else
586 ; //nothing.
587 }
588 else if (strcmp(argv[i], "--top-ehrhart-unweighted")==0)
589 {
590 integrationInput.unweightedCounting = true;
591 interactiveLatte = false;
592 }
593 else if (strcmp(argv[i], "--interactive-mode") == 0)
594 {
595 interactiveLatte = true; //note, when in
596 }
597 else if (strncmp(argv[i], "--num-coefficients=", 19) == 0) {
598 integrationInput.numEhrhartCoefficients = atoi(argv[i] + 19);
599 }
600 else if (strncmp(argv[i], "--top-ehrhart-save=", 19) == 0)
601 {
602 integrationInput.saveTopEhrhartPolynomial = (argv[i] + 19);
603 }
604 else if (strncmp(argv[i], "--real-dilations", 6) == 0) {
605 integrationInput.realDilations = true;
606 }
607 else if (strcmp(argv[i], "--cone-decompose") == 0)
608 {
609 integrationInput.useTangentCones = true;
610 }
611 else if (strcmp(argv[i], "--triangulate") == 0)
612 {
613 integrationInput.useTriangulation = true;
614 }
615 else if ( strcmp(argv[i], "--polynomial-as-plf") == 0)
616 {
617 integrationInput.polynomialAsPLF = true;
618 }
619 /*
620 // else if (strcmp(argv[i], "--all") == 0)
621 {
622 strcpy(valuationAlg, "all");
623 strcpy(read_polyhedron_data.dualApproach, "no");
624 }
625 else if (strcmp(argv[i], "--print-lawrence-function") == 0 || strcmp(argv[i], "--print-cone-decompose-function") == 0)
626 strcpy(printLawrence, "yes");
627 else if ( strcmp(argv[i], "--stokes") == 0)
628 useStokes = true;
629 //
630 */ else if (strncmp(argv[i], "--monomials=", 12) == 0)
631 {
632 integrationInput.integrandType = IntegrationInput::inputPolynomial;
633 integrationInput.fileName = (argv[i] + 12);
634 } else if ( strncmp(argv[i], "--linear-forms=", 15) == 0 )
635 {
636 integrationInput.integrandType = IntegrationInput::inputLinearForm;
637 integrationInput.fileName = (argv[i] + 15);
638 } else if ( strncmp(argv[i], "--product-linear-forms=", 23) == 0)
639 {
640 integrationInput.integrandType = IntegrationInput::inputProductLinearForm;
641 integrationInput.fileName = (argv[i] + 23);
642 } else if (read_polyhedron_data.parse_option(argv[i]))
643 {
644
645 } else
646 {
647 cerr << "Unknown command/option " << argv[i] << endl;
648 THROW_LATTE(LattException::ue_UnknownCommandLineOption, 0);
649 }
650 }
651
652 if ( ! integrationInput.valuationEhrhart
653 && !integrationInput.valuationIntegrate
654 && !integrationInput.valuationVolume
655 )
656 {
657 cerr << "--valuation=??? missing. Type --help" << endl;
658 THROW_LATTE(LattException::ue_BadCommandLineOption, 0);
659 }
660
661
662 integrationInput.processUserInput(); //sets which algorithms will be used (if the user gave them on the command line)
663
664 if ( integrationInput.volumeCone
665 || integrationInput.integrateLinearFormCone
666 || integrationInput.integratePolynomialAsLinearFormCone
667 || integrationInput.topEhrhart
668 || integrationInput.useTangentCones
669 || (integrationInput.useTangentCones == false && integrationInput.useTriangulation == false)
670 )
671 {
672 strcpy(read_polyhedron_data.dualApproach, "no");
673 }//compute tangent cones.
674 else
675 {
676 strcpy(read_polyhedron_data.dualApproach, "yes");
677 }//compute vertices.
678
679 if (read_polyhedron_data.expect_filename)
680 {
681 cerr << "Filename missing" << endl;
682 THROW_LATTE( LattException::ue_FileNameMissing,0);
683 }
684
685 if (params->shortvector == BarvinokParameters::SubspaceAvoidingLLL)
686 {
687 if (params->decomposition
688 == BarvinokParameters::IrrationalAllPrimalDecomposition)
689 {
690 /* Triangulation will be done in the primal space, so all
691 triangulation methods are fine. */
692 } else
693 {
694 /* Triangulation will be done in the dual space, so we must
695 avoid using facets whose normal vectors lie in the
696 subspace. */
697 if (triangulation_specified)
698 {
699 if (params->triangulation
700 != BarvinokParameters::SubspaceAvoidingBoundaryTriangulation
701 && params->triangulation
702 != BarvinokParameters::SubspaceAvoidingSpecialTriangulation)
703 {
704 cerr
705 << "Warning: The requested triangulation method is not guaranteed to work with --avoid-singularities."
706 << endl;
707 }
708 } else
709 {
710 /* Not specified, so choose one that will work. */
711 cerr << "Choosing SubspaceAvoidingBoundaryTriangulation method"
712 << endl;
713 params->triangulation
714 = BarvinokParameters::SubspaceAvoidingBoundaryTriangulation;
715 }
716 }
717 }
718
719 if (approx)
720 {
721 params->substitution = BarvinokParameters::ExponentialSubstitution;
722 if (params->decomposition == BarvinokParameters::DualDecomposition)
723 {
724 cerr
725 << "Exponential approximation not implemented for dual decomposition; switching to irrational primal decomposition."
726 << endl;
727 params->decomposition
728 = BarvinokParameters::IrrationalPrimalDecomposition;
729 }
730 }
731
732 if (read_polyhedron_data.minimize[0] == 'y')
733 strcpy(read_polyhedron_data.maximum, "yes");
734 if (read_polyhedron_data.grobner[0] == 'y')
735 strcpy(read_polyhedron_data.equationsPresent, "yes");
736 if (read_polyhedron_data.maximum[0] == 'y')
737 strcpy(read_polyhedron_data.Memory_Save, "no");
738 if (printfile[0] == 'y')
739 strcpy(read_polyhedron_data.Memory_Save, "no");
740 if (read_polyhedron_data.rationalCone[0] == 'y')
741 strcpy(read_polyhedron_data.Memory_Save, "no");
742 if (printfile[0] == 'y')
743 print_flag = 1;
744
745 if (read_polyhedron_data.rationalCone[0] == 'y')
746 {
747
748 //HugInt digit(argv[1]);
749 //conv(output_cone, digit.BigInt);
750 // User can use only Mode one
751 output_cone = 3;
752 }
753
754 if (output_cone > 3)
755 output_cone = 0;
756 flags |= (output_cone << 1);
757
758 const char *fileName = read_polyhedron_data.filename.c_str();
759
760 if (read_polyhedron_data.dualApproach[0] == 'y')
761 {
762 flags |= DUAL_APPROACH;
763 }
764
765 /* INPUT HANDLING. */
766
767 if (read_polyhedron_data.grobner[0] == 'y')
768 {
769 CheckGrobner(fileName, read_polyhedron_data.cddstyle);
770 SolveGrobner(fileName, read_polyhedron_data.nonneg,
771 read_polyhedron_data.dualApproach,
772 read_polyhedron_data.grobner,
773 read_polyhedron_data.equationsPresent,
774 read_polyhedron_data.cddstyle);
775 exit(0);
776 }
777
778
779
780 //the stokes recursive method is not finished and experimental.
781 // Users should always enter this if statement.
782 if ( useStokes == false)
783 {
784 Polyhedron *Poly = read_polyhedron_data.read_polyhedron(params);
785
786 params->Flags = flags;
787 params->Number_of_Variables = Poly->numOfVars;
788 params->max_determinant = 1;
789 params->File_Name = (char*) fileName;
790
791 //poly is updated.
792 polyhedronToCones(integrationInput, Poly, params);
793 //now the cones of poly are the tangent cones or the lifted cone of the vertices.
794
795 if (integrationInput.integrandType == IntegrationInput::inputVolume)
796 {
797 valuationAnswers = computeVolume(Poly, *params, integrationInput,
798 printLawrence);
799
800 } else //integration
801 {
802 //read the integrand from the file or from std in.
803 ifstream inFile;
804 istream inStream(cin.rdbuf());
805
806 if (integrationInput.integrandType != IntegrationInput::nothing)
807 {
808 inFile.open(integrationInput.fileName.c_str());
809 if (!inFile.is_open())
810 {
811 cerr << "Error: cannot open " << integrationInput.fileName;
812 THROW_LATTE( LattException::fe_Open, 0);
813 }
814 inStream.rdbuf(inFile.rdbuf());
815 }//set the inStream.
816
817
818 integrationInput.integrand = "";
819
820 //get the integrand from the file or the user.
821 if (inFile.is_open())
822 {
823 cerr << "Reading " << (integrationInput.integrandType == IntegrationInput::inputPolynomial ? "polynomial" : "linear forms" ) << " from file " << integrationInput.fileName.c_str() << endl;
824 getline(inStream, integrationInput.integrand, '\n');
825 inFile.close();
826 } else if (integrationInput.unweightedCounting == true && interactiveLatte == false)
827 {
828 ; //don't ask the user for the integrand.
829 }
830 else
831 {
832 cout << "\nEnter an integrand type: \n"
833 << "1) p (for a polynomial)\n"
834 << "2) l (for powers of linear forms)\n"
835 << "3) d (for products of powers of linear forms)\n"
836 << " :> ";
837 char pl = cin.get();
838 cin.ignore(1000, '\n');
839 cout << "Enter the integrand using "
840 << (Poly->homogenized ? Poly->numOfVars - 1 : Poly->numOfVars)
841 << " variables\n >";
842 if (pl == 'p')
843 {
844 integrationInput.integrandType = IntegrationInput::inputPolynomial;
845 }
846 else if (pl == 'l')
847 {
848 integrationInput.integrandType = IntegrationInput::inputLinearForm;
849 }
850 else if ( pl == 'd' )
851 integrationInput.integrandType = IntegrationInput::inputProductLinearForm;
852 else
853 {
854 cerr << "The character " << pl << " is not a p or l or d" << endl;
855 THROW_LATTE( LattException::ue_BadCommandLineOption, 0);
856 }
857
858 integrationInput.unweightedCounting = false;
859
860 integrationInput.processUserInput();
861 //char integrandLine[150];
862 getline(inStream, integrationInput.integrand, '\n');
863 //integrationInput.integrand = integrandLine;
864 }//user supplied integrand in a file.
865
866
867 if (integrationInput.topEhrhart) {
868 computeTopEhrhart(Poly, *params, integrationInput);
869 }
870 else {
871 valuationAnswers = computeIntegral(Poly, *params, integrationInput);
872 }
873 } //else integration.
874 ValuationData totalValuationTimer;
875 totalValuationTimer.valuationType = PolytopeValuation::entireValuation;
876 params->total_time.stop();
877 totalValuationTimer.timer = params->total_time;
878 valuationAnswers.add(totalValuationTimer);
879
880 freeListVector(read_polyhedron_data.templistVec);
881 freeListVector(read_polyhedron_data.matrix);
882 delete Poly;
883 }
884 else
885 { //use Stokes
886 //NOTE:: THIS RECURSIVE METHOD IS NOT DONE.
887 //THIS SHOULD NOT WORK.
888 THROW_LATTE_MSG( LattException::bug_NotImplementedHere, 1, "The experimental Stokes code has been removed" );
889
890 }//else use stokes.
891
892
893
894
895 if (read_polyhedron_data.rationalCone[0] == 'y')
896 {
897 string new_name = string(argv[argc - 1]) + ".rat";
898 cerr << endl << "Rational function written to `" << new_name << "'" << endl << endl;
899 rename_with_error_check("simplify.sum", new_name);
900 }
901
902 if (printfile[0] == 'y')
903 {
904 string new_name = string(argv[argc - 1]) + ".rat";
905 cerr << endl << "Rational function written to `" << new_name << "'" << endl << endl;
906 rename_with_error_check("func.rat", new_name);
907 }
908 if ((removeFiles[0] == 'y')
909 && (read_polyhedron_data.dualApproach[0] == 'n'))
910 {
911
912 // strcpy(command, "rm -f ");
913 // strcat(command, fileName);
914 // strcat(command, ".ext");
915 // system_with_error_check(command);
916
917 // strcpy(command, "rm -f ");
918 // strcat(command, fileName);
919 // strcat(command, ".cdd");
920 // system_with_error_check(command);
921
922 // if (read_polyhedron_data.Memory_Save[0] == 'n')
923 // {
924 // strcpy(command, "rm -f ");
925 // strcat(command, fileName);
926 // strcat(command, ".maple");
927 // system_with_error_check(command);
928 // }
929
930 // strcpy(command, "rm -f ");
931 // strcat(command, fileName);
932 // strcat(command, ".ead");
933 // system_with_error_check(command);
934
935 }
936
937
938 //cout << params->triangulate_time << endl;
939 //cout << params->dualize_time << endl;
940 valuationAnswers.printResults(cout);
941
942 delete params;
943 return valuationAnswers;
944 }//mainValuationDriver
945
946
polyhedronToCones(const IntegrationInput & intInput,Polyhedron * Poly,BarvinokParameters * params)947 void Valuation::polyhedronToCones(const IntegrationInput &intInput, Polyhedron *Poly, BarvinokParameters * params)
948 {
949 /*
950 cout << "#####valuation.cpp, first printing of the cones" << endl;
951 printListCone(Poly->cones, Poly->numOfVars);
952 cout << "end valuation.cpp, first printing of the cones" << endl;
953 */
954
955 assert(Poly->cones != NULL);
956 // cout << "poly.homogenized:" << Poly->homogenized << endl;
957 // cout << "poly.dualized:" << Poly->dualized << endl;
958 // cout << "read:dualApproach:" << read_polyhedron_data.dualApproach << endl;
959 // cout << "raed.input_dualized" << read_polyhedron_data.input_dualized << endl;
960
961 if (intInput.volumeCone
962 || intInput.integrateLinearFormCone
963 || intInput.integratePolynomialAsLinearFormCone
964 || intInput.topEhrhart
965 || (intInput.useTangentCones == false && intInput.useTriangulation == false) //the user didn't give an integrand nor integration method
966 || (intInput.useTangentCones == true) //the user gave --cone-decompose but didn't gvie an integrand.
967 )
968 {
969 assert(Poly->homogenized == false);
970 if (Poly->dualized)
971 {
972 cerr << "(First dualizing back... ";
973 cerr.flush();
974 dualizeCones(Poly->cones, Poly->numOfVars, params);
975 cerr << "done.) ";
976 cerr.flush();
977 Poly->dualized = false;
978 }
979 if (Poly->cones->rays == NULL)
980 {
981 // dualize twice tocompute the rays.
982 cerr << "(First computing their rays... ";
983 cerr.flush();
984 dualizeCones(Poly->cones, Poly->numOfVars, params);
985 dualizeCones(Poly->cones, Poly->numOfVars, params); // just swaps
986 cerr << "done!) ";
987 cerr.flush();
988 }
989
990 }//find vertex-rays
991 else
992 {
993 assert(Poly->homogenized == true);
994 if (Poly->dualized)
995 {
996 cerr << "(First dualizing back... ";
997 cerr.flush();
998 dualizeCones(Poly->cones, Poly->numOfVars, params);
999 cerr << "done!) ";
1000 cerr.flush();
1001 Poly->dualized = false; // Adjust state
1002 }
1003 }//only need vertices
1004
1005
1006 /*
1007 cout << "#####valuation.cpp, 2nd printing of the cones" << endl;
1008 printListCone(Poly->cones, Poly->numOfVars);
1009 cout << "end valuation.cpp, 2nd printing of the cones" << endl;
1010 */
1011
1012
1013
1014 /* //OLD WAY OF SETTING UP THE POLYTOPE...NEW WAY IS ABOVE.
1015 if ( read_polyhedron_data.Vrepresentation[0] != 'y')
1016 {
1017 switch (params->decomposition)
1018 {
1019 case BarvinokParameters::DualDecomposition:
1020 case BarvinokParameters::IrrationalPrimalDecomposition:
1021 if (not Poly->dualized)
1022 {
1023 if (read_polyhedron_data.Vrepresentation[0] != 'y')
1024 {
1025 // Compute all inequalities tight at the respective vertex.
1026 // Then dualizeCones just needs to swap rays and facets.
1027 computeTightInequalitiesOfCones(Poly->cones,
1028 read_polyhedron_data.matrix, Poly->numOfVars);
1029 }
1030 dualizeCones(Poly->cones, Poly->numOfVars, params);
1031 Poly->dualized = true;
1032 }
1033 break;
1034 case BarvinokParameters::IrrationalAllPrimalDecomposition:
1035 cerr << "Irrationalizing polyhedral cones... ";
1036 cerr.flush();
1037 if (Poly->dualized)
1038 {
1039 cerr << "(First dualizing back... ";
1040 cerr.flush();
1041 dualizeCones(Poly->cones, Poly->numOfVars, params);
1042 cerr << "done; sorry for the interruption.) ";
1043 cerr.flush();
1044 } else if (Poly->cones != NULL)
1045 {
1046
1047 if (Poly->cones->facets == NULL)
1048 {
1049 cerr << "(First computing facets for them... ";
1050 cerr.flush();
1051 dualizeCones(Poly->cones, Poly->numOfVars, params);
1052 dualizeCones(Poly->cones, Poly->numOfVars, params); // just swaps
1053 cerr << "done; sorry for the interruption.) ";
1054 cerr.flush();
1055 } else if (Poly->cones->rays == NULL)
1056 {
1057 // Only facets computed, for instance by using the 4ti2
1058 // method of computing vertex cones. So dualize twice to
1059 // compute the rays.
1060 cerr << "(First computing their rays... ";
1061 cerr.flush();
1062 dualizeCones(Poly->cones, Poly->numOfVars, params);
1063 dualizeCones(Poly->cones, Poly->numOfVars, params); // just swaps
1064 cerr << "done; sorry for the interruption.) ";
1065 cerr.flush();
1066 }
1067 }
1068 params->irrationalize_time.start();
1069 {
1070 listCone *cone;
1071 for (cone = Poly->cones; cone; cone = cone->rest)
1072 assert(lengthListVector(cone->facets) >= Poly->numOfVars);
1073 }
1074 //irrationalizeCones(Poly->cones, Poly->numOfVars);
1075 //params->irrationalize_time.stop();
1076 //cerr << params->irrationalize_time;
1077 break;
1078 default:
1079 cerr << "Unknown BarvinokParameters::decomposition" << endl;
1080 abort();
1081 }//switch
1082 }//if lawrence (or all) and h-rep.
1083 */
1084
1085 /*
1086 cout << "#####valuation.cpp, cones after" << endl;
1087 printListCone(Poly->cones, Poly->numOfVars);
1088 cout << "end valuation.cpp, cones after" << endl;
1089 exit(1);
1090 //*/
1091 }//polyhedronToCones
1092
1093
1094
1095
1096
IntegrationInput()1097 Valuation::IntegrationInput::IntegrationInput()
1098 {
1099 integrandType = nothing;
1100
1101 //volume algorithms
1102 volumeCone = false; //volume using the cone method.
1103 volumeTriangulation = false; //volume using triangulation
1104
1105 //integration algorithms.
1106 integratePolynomial = false;
1107 integratePolynomialAsLinearFormTriangulation = false; //decompose polynomial to LF, use triangulation.
1108 integratePolynomialAsLinearFormCone = false; //decompose polynomial to LF, use cone method.
1109 integratePolynomialAsPLFTriangulation = false; //decompost polynomial to PLF, use triangulation.
1110 integrateLinearFormTriangulation = false; //integrate linear forms using triangulation
1111 integrateLinearFormCone = false; //integrate linear forms using cone method
1112 integrateProductLinearFormsTriangulation = false; //integrate product of linear forms using triangulation.
1113
1114 //Ehrhart algorithms.
1115 topEhrhart = false; //compute top Ehrhart coefficients using cone method only.
1116 numEhrhartCoefficients = -1; // incremental mode
1117 realDilations = false; //formula is only valid for integer dilations, not rational/real ones.
1118 saveTopEhrhartPolynomial = "-1"; //default is to not save the polynomial.
1119
1120 //Command line options. These are used by processUserInput()
1121 // to set up which algorithms will be used.
1122 valuationVolume =false; //--valuation=volume
1123 valuationIntegrate= false; //etc
1124 valuationEhrhart= false;
1125 useTangentCones= false; //--cone-decompose
1126 useTriangulation= false; //--triangulate
1127 polynomialAsPLF= false; //--polynomial-as-plf
1128 }
1129
1130
processUserInput()1131 void Valuation::IntegrationInput::processUserInput()
1132 {
1133 if ( valuationVolume)
1134 {
1135 integrandType = inputVolume; //the integrand is 1
1136 if ( useTangentCones ) volumeCone = true;
1137 else if ( useTriangulation) volumeTriangulation = true;
1138 else
1139 {
1140 volumeCone = true;
1141 volumeTriangulation = true;
1142 }//default, do both.
1143 }//if volume
1144 else if ( valuationIntegrate)
1145 {
1146 if (integrandType == inputLinearForm)
1147 {
1148 if ( useTangentCones ) integrateLinearFormCone = true;
1149 else if ( useTriangulation) integrateLinearFormTriangulation = true;
1150 else
1151 {
1152 integrateLinearFormCone = true;
1153 integrateLinearFormTriangulation = true;
1154 }//default, do both.
1155 }//if linear form
1156 else if ( integrandType == inputProductLinearForm)
1157 {
1158 integrateProductLinearFormsTriangulation = true;
1159 }//if plf
1160 else if ( integrandType == inputPolynomial)
1161 {
1162 if ( useTangentCones ) integratePolynomialAsLinearFormCone = true;
1163 else if ( useTriangulation) integratePolynomialAsLinearFormTriangulation = true;
1164 else if ( polynomialAsPLF) integratePolynomialAsPLFTriangulation = true;
1165 else
1166 {
1167 integratePolynomialAsLinearFormCone = true;
1168 integratePolynomialAsLinearFormTriangulation = true;
1169 integratePolynomialAsPLFTriangulation = true;
1170 integratePolynomial = true; //do all of them.
1171 }//default, do all.
1172 }//if polynomial.
1173 }//else integration
1174 else if (valuationEhrhart)
1175 {
1176 topEhrhart = true;
1177 }
1178 }//processUserInput
1179
ValuationData()1180 Valuation::ValuationData::ValuationData() :
1181 timer(string(""), false)
1182 {
1183 }
1184
add(const ValuationData & d)1185 void Valuation::ValuationContainer::add(const ValuationData & d)
1186 {
1187 answers.push_back(d);
1188 }
1189
printResults(ostream & out) const1190 void Valuation::ValuationContainer::printResults(ostream & out) const
1191 {
1192 out << "\n";
1193 for (size_t i = 0; i < answers.size(); ++i)
1194 {
1195 if (answers[i].valuationType == PolytopeValuation::volumeCone)
1196 out << "Volume (using the cone decomposition method)" << endl;
1197 else if (answers[i].valuationType == PolytopeValuation::volumeTriangulation)
1198 out << "Volume (using the triangulation-determinant method)"
1199 << endl;
1200 else if (answers[i].valuationType
1201 == PolytopeValuation::integrateLinearFormTriangulation)
1202 out << "Integration of linear forms (using the triangulation method)" << endl;
1203 else if (answers[i].valuationType == PolytopeValuation::integrateLinearFormCone)
1204 out << "Integration of linear forms (using the cone method)" << endl;
1205 else if ( answers[i].valuationType == PolytopeValuation::integrateProductLinearFormsTriangulation)
1206 out << "Integration of products of linear forms (using the triangulation method)" << endl;
1207 else if ( answers[i].valuationType == PolytopeValuation::integratePolynomialAsLinearFormCone)
1208 out << "Integration of a polynomial as linear forms (using the cone method)" << endl;
1209 else if ( answers[i].valuationType == PolytopeValuation::integratePolynomialAsLinearFormTriangulation)
1210 out << "Integration of a polynomial as linear forms (using the triangulation method)" << endl;
1211 else if ( answers[i].valuationType == PolytopeValuation::integratePolynomialAsPLFTriangulation)
1212 out << "Integration of a polynomail as products of linear forms (using the triangulation method)" << endl;
1213 else if (answers[i].valuationType == PolytopeValuation::entireValuation)
1214 {
1215 out
1216 << "Computational time (algorithms + processing + program control)"
1217 << endl;
1218 out << " " << answers[i].timer;
1219 continue;
1220 }
1221
1222 RR decimalAns;
1223 decimalAns = answers[i].answer.to_RR();
1224 decimalAns.SetOutputPrecision(32);
1225
1226 out << " Answer: " << answers[i].answer << endl;
1227 out << " Decimal: " << decimalAns << endl;
1228 out << " Time" << answers[i].timer;
1229 }//for each valuation entry.
1230
1231 }//printResults
1232
1233
1234