File: app_normalfancleanup.cpp

package info (click to toggle)
gfan 0.5%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,348 kB
  • ctags: 5,683
  • sloc: cpp: 39,675; makefile: 454; sh: 1
file content (142 lines) | stat: -rw-r--r-- 3,244 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <iostream>
#include "parser.h"
#include "printer.h"
#include "polynomial.h"
#include "division.h"
#include "buchberger.h"
#include "wallideal.h"
#include "lp.h"
#include "reversesearch.h"
#include "termorder.h"
#include "ep_standard.h"
#include "ep_xfig.h"
#include "gfanapplication.h"
#include "polyhedralcone.h"
#include "polyhedralfan.h"
#include "tropical.h"
#include "tropical2.h"
#include "symmetry.h"
#include "halfopencone.h"
#include "log.h"


class NormalFanCleanUpApplication : public GFanApplication
{
  SimpleOption optionPreprocess;

public:
  bool includeInDefaultInstallation()
  {
    return false;
  }
  const char *helpText()
  {
    return "This program takes a list of polynomials and outputs a subcomplex of its normalfan. After the polynomial list follows a generating set for the symmetry group and then a list of vectors. The cones which are output are the ones picked by the list of vectors. The output is symmetric with respect to the symmetry group.\n";
  }
  NormalFanCleanUpApplication():
    optionPreprocess("-pre","Preprocess cones before building polyhedral fan - that is find representatives for each orbit first.\n")
  {
    registerOptions();
  }

  const char *name()
  {
    return "_normalfancleanup";
  }
  int main()
  {
    FileParser P(Stdin);

    PolynomialSet g=P.parsePolynomialSetWithRing();
    int n=g.numberOfVariablesInRing();

    SymmetryGroup sym(n);
    sym.computeClosure(P.parseIntegerVectorList());

    IntegerVectorList l=P.parseIntegerVectorList();

    cerr<<"Number of input rays: " << l.size() <<"\n";

    if(optionPreprocess.getValue())
      {
	set<IntegerVector> l2;
	for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++)
	  {
	    {
	      static int a;
	      if(!((++a)&255))
		{
		  cerr<<a<<"\n";

		  FILE *f=fopen("iteraTIon","w");
		  if(f)
		    {
		      fprintf(f,"%i:%lu\n",a,l2.size());
		      fclose(f);
		    }
		}
	    }
	    {
	      static int a;
	      if(!((++a)&2047))
		{
		  FILE *f=fopen("parTialOutPUt","w");
		  if(f)
		    {
		      IntegerVectorList l3;
		      for(set<IntegerVector>::const_iterator i=l2.begin();i!=l2.end();i++)l3.push_back(*i);
		      AsciiPrinter(f)<<l3;
		      fclose(f);
		    }
		}
	    }
	    PolyhedralCone c=normalConeOfMinkowskiSum(g,*i);
	    c.canonicalize();
	    cerr << "Dim " <<c.dimension()<<endl;
	    l2.insert(sym.orbitRepresentative(c.getUniquePoint()));
	  }

	cerr<<"Number of input cones up to symmetry: " << l2.size() <<"\n";


	IntegerVectorList l3;
	for(set<IntegerVector>::const_iterator i=l2.begin();i!=l2.end();i++)l3.push_back(*i);
	AsciiPrinter(Stdout)<<l3;

	l=l3;
      }


    PolyhedralFan F(n);
    for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++)
      {
	{
	  static int a;
	  if(!((++a)&255))
	    {
	      cerr<<a<<"\n";

	      FILE *f=fopen("iteraTIon","w");
	      if(f)
		{
		  fprintf(f,"%i\n",a);
		  fclose(f);
		}
	    }
	}
	PolyhedralCone c=normalConeOfMinkowskiSum(g,*i);
	c.canonicalize();
	F.insert(c);
      }
    AsciiPrinter p(Stdout);
    F.printWithIndices(&p,
		       FPF_group|FPF_conesCompressed|
		       FPF_maximalCones|FPF_cones,
		       &sym);


    return 0;
  }
};

static NormalFanCleanUpApplication theApplication;