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 143 144 145 146 147 148
|
/*
* app_traversetropicalintersection.cpp
*
* Created on: Jan 4, 2011
* Author: anders
*/
#include "printer.h"
#include "parser.h"
#include "gfanapplication.h"
#include "division.h"
#include "log.h"
#include "polyhedralcone.h"
#include "tropical2.h"
#include "wallideal.h"
#include "halfopencone.h"
#include "integergb.h"
#include <ostream>
using namespace std;
class TropicalIntersectionTraverser: public ConeTraverser
{
PolynomialSet allPolys;
PolynomialSet iForms;
PolyhedralCone theCone;
int n;//,d;
int prime;
bool collect;
IntegerVectorList collection;
void updatePolyhedralCone()
{
theCone=PolyhedralCone(fastNormals(wallInequalities(allPolys)),wallInequalities(iForms),n);
theCone.canonicalize();
if(collect)
{
collection.push_back(theCone.getRelativeInteriorPoint());
int temp=collection.size();
if((temp&(2*(temp-1)))==temp)pout<<"RELINT:\n"<<collection;
}
}
public:
TropicalIntersectionTraverser(PolynomialSet const &generators, IntegerVector const &omega):
allPolys(generators),
iForms(generators.getRing()),
n(generators.getRing().getNumberOfVariables()),
collect(true)
{
IntegerVectorList l;
l.push_back(omega);
MatrixTermOrder T(l);
iForms=initialForms(generators,omega);
allPolys.mark(T);
iForms.mark(T);
updatePolyhedralCone();
}
virtual void changeCone(IntegerVector const &ridgeVector, IntegerVector const &rayVector)
{
IntegerVectorList l;
l.push_back(ridgeVector);l.push_back(rayVector);
MatrixTermOrder T(l);
allPolys.mark(T);
iForms=initialForms(initialForms(allPolys,ridgeVector),rayVector);
iForms.mark(T);
updatePolyhedralCone();
}
virtual IntegerVectorList link(IntegerVector const &ridgeVector)
{
PolyhedralFan l=tropicalHyperSurfaceIntersectionClosed(n, initialForms(allPolys,ridgeVector));
assert(l.getMaxDimension()==l.dimensionOfLinealitySpace()+1);
IntegerVectorList ret;
for(set<PolyhedralCone>::const_iterator i=l.conesBegin();i!=l.conesEnd();i++)
if(!(i->getUniquePoint().isZero()))ret.push_back(i->getUniquePoint());
assert(ret.size()>1);
return ret;
}
PolyhedralCone & refToPolyhedralCone()
{
return theCone;
}
};
class TraverseTropicalIntersectionApplication : public GFanApplication
{
SimpleOption optionSymmetry;
public:
bool includeInDefaultInstallation()
{
return false;
}
const char *helpText()
{
return "This program \n";
}
TraverseTropicalIntersectionApplication():
optionSymmetry("--symmetry","Do computations up to symmetry and group the output accordingly. If this option is used the program will read in a list of generators for a symmetry group after the other input.")
{
registerOptions();
}
const char *name()
{
return "_traversetropicalintersection";
}
int main()
{
FileParser P(Stdin);
PolynomialSet a=P.parsePolynomialSetWithRing();
int n=a.getRing().getNumberOfVariables();
IntegerVector omega=P.parseIntegerVector();
{
SymmetryGroup G(n);
if(optionSymmetry.getValue())
{
IntegerVectorList generators=P.parseIntegerVectorList();
G.computeClosure(generators);
G.createTrie();
}
SymmetricTargetFanBuilder target(n,G);
TropicalIntersectionTraverser traverser(a,omega);
symmetricTraverse(traverser,target,&G);
AsciiPrinter Q(Stdout);
target.getFanRef().printWithIndices(&Q,
FPF_default);
}
return 0;
}
};
static TraverseTropicalIntersectionApplication theApplication;
|