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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
|
////////////////////////////////////////////////////////////////////////////////
//
// ComputeTriangs.cc
//
// produced: 25 Nov 1999 jr
// last change: 25 nov 1999 jr
//
////////////////////////////////////////////////////////////////////////////////
#include "SimplicialComplex.hh"
#include "CommandlineOptions.hh"
#include "Permutation.hh"
#include "PointConfiguration.hh"
#include "Volumes.hh"
#include "Chirotope.hh"
#include "Circuits.hh"
#include "Facets.hh"
#include "Admissibles.hh"
#include "InteriorFacets.hh"
#include "PartialTriang.hh"
#include "CheckTriang.hh"
#include "Flip.hh"
#include "MarkedFlips.hh"
#include "TriangNode.hh"
#include "TriangFlips.hh"
#include "Symmetry.hh"
#include "FineTriang.hh"
#include "SymmetricFlipGraph.hh"
#include "SymmetricExtensionGraphMaster.hh"
#include "RegularityCheck.hh"
#include "ComputeTriangs.hh"
namespace topcom {
const size_type __min_triang_card(const parameter_type no,
const parameter_type rank,
const PointConfiguration& points,
const Chirotope& chiro,
const SymmetryGroup& symmetries,
const bool output_triangs,
const bool only_fine_triangs
) {
SymmetricExtensionGraphMaster segm(no, rank, points, chiro, symmetries, output_triangs, only_fine_triangs, true);
if (CommandlineOptions::verbose()) {
std::cerr << segm.nodecount() << " partial triangulations visited in total." << std::endl;
std::cerr << segm.deadendcount() << " branching deadends." << std::endl;
std::cerr << segm.earlydeadendcount() << " early detected deadends." << std::endl;
std::cerr << segm.mintriang() << " is a minimal triangulation." << std::endl;
std::cerr << segm.mincard() << " simplices in a minimal triangulation." << std::endl;
}
return segm.mincard();
}
const size_type __no_of_all_triangs(const parameter_type no,
const parameter_type rank,
const PointConfiguration& points,
const Chirotope& chiro,
const SymmetryGroup& symmetries,
const bool output_triangs,
const bool only_fine_triangs
) {
SymmetricExtensionGraphMaster segm(no, rank, points, chiro, symmetries, output_triangs, only_fine_triangs, false);
if (CommandlineOptions::verbose()) {
std::cerr << segm.nodecount() << " partial triangulations visited in total." << std::endl;
std::cerr << segm.deadendcount() << " branching deadends." << std::endl;
std::cerr << segm.earlydeadendcount() << " early detected deadends." << std::endl;
std::cerr << segm.maxiter_coversimptighten() << " max iterations in coversimp tightening." << std::endl;
std::cerr << segm.symcount() << " symmetry classes";
if (!CommandlineOptions::skip_orbitcount()) {
std::cerr << " --- " << segm.totalcount() << " triangulations in total";
}
std::cerr << "." << std::endl;
}
return segm.symcount();
}
const size_type __no_of_triangs(const parameter_type no,
const parameter_type rank,
const PointConfiguration& points,
const Chirotope& chiro,
const SymmetryGroup& symmetries,
const SimplicialComplex& seed,
const symmetryptr_datapair& seed_symmetryptrs,
const Volumes* voltableptr,
const bool output_triangs,
const bool fine_only) {
SymmetricFlipGraph sfg(no, rank, points, chiro,
symmetries, seed, seed_symmetryptrs,
voltableptr,
output_triangs, fine_only);
if (CommandlineOptions::verbose()) {
std::cerr << sfg.symcount() << " symmetry classes";
if (!CommandlineOptions::skip_orbitcount()) {
std::cerr << " --- " << sfg.totalcount() << " triangulations in total";
}
std::cerr << "." << std::endl;
}
return sfg.symcount();
}
int ComputeTriangs::run(const int flags) {
if (CommandlineOptions::lp_solver_needed()) {
// some solvers need initialization of global constants etc.:
RegularityCheck::init();
}
{
const bool input_chiro = flags & INPUT_CHIRO;
const bool compute_all = flags & COMPUTE_ALL;
const bool fine_only = flags & FINE_ONLY;
const bool output_triangs = flags & OUTPUT_TRIANGS;
const bool preprocess = flags & PREPROCESS;
const bool findflips = flags & FINDFLIPS;
const bool unimodular = flags & UNIMODULAR;
const bool findmin = flags & FINDMIN;
if (CommandlineOptions::verbose()) {
std::cerr << std::endl;
std::cerr << "------------------------------------------------------------\n";
std::cerr << "------------------ " << PACKAGE << " VERSION " << VERSION << " --------------------\n";
std::cerr << "Triangulations of Point Configurations and Oriented Matroids\n";
std::cerr << "--------------------- by Joerg Rambau ----------------------\n";
std::cerr << "------------------------------------------------------------\n";
std::cerr << std::endl;
#ifdef STL_CONTAINERS
std::cerr << " -- using STL containers for hash tables --" << std::endl;
#endif
#ifdef STL_SYMMETRIES
std::cerr << " -- using STL containers for symmetries --" << std::endl;
#endif
#ifdef STL_FLIPS
std::cerr << " -- using STL containers for flips --" << std::endl;
#endif
#ifdef STL_CHIROTOPE
std::cerr << " -- using STL containers for chirotopes --" << std::endl;
#endif
std::cerr << std::endl;
}
// terminate if non-consistent options have been chosen:
if (input_chiro && CommandlineOptions::check_regular()) {
std::cerr << "regularity check not possible if only chirotope is given; exiting." << std::endl;
exit(1);
}
Chirotope chiro;
PointConfiguration points = PointConfiguration();
if (input_chiro) {
if (CommandlineOptions::output_asy()) {
std::cerr << "graphics output cancelled because of chirotope input." << std::endl;
}
if (!chiro.read_string(std::cin)) {
if (CommandlineOptions::verbose()) {
std::cerr << "error while reading chirotope." << std::endl;
}
return 1;
}
if (CommandlineOptions::verbose()) {
std::cerr << "read chirotope with " << chiro.no()
<< " elements in rank " << chiro.rank() << std::endl;
}
}
else {
if (!points.read(std::cin)) {
if (CommandlineOptions::verbose()) {
std::cerr << "error while reading point configuration." << std::endl;
}
return 1;
}
if (points.rank() < points.rowdim()) {
std::cerr << "point configuration has " << points.rowdim() << " rows of rank " << points.rank() << std::endl;
points.transform_to_full_rank();
std::cerr << "resulting no of rows after transformation: " << points.rank() << std::endl;
points.pretty_print(std::cerr);
}
if ((points.no() < 1) || (points.rank() < 1)) {
if (CommandlineOptions::verbose()) {
std::cerr << "no of points and rank must be at least one." << std::endl;
}
return 1;
}
if (points.rank() > points.no()) {
if (CommandlineOptions::verbose()) {
std::cerr << "rank must not be larger than no of points." << std::endl;
}
return 1;
}
if (CommandlineOptions::verbose()) {
std::cerr << "read point configuration with " << points.no()
<< " points in rank " << points.rank() << std::endl;
}
chiro = Chirotope(points, preprocess);
}
size_type no(chiro.no());
size_type rank(chiro.rank());
SymmetryGroup symmetries(no);
if (!CommandlineOptions::ignore_symmetries()) {
if (CommandlineOptions::use_switch_tables()) {
// if (false) {
if (symmetries.read_generators(std::cin)) {
std::cerr << "read " << symmetries.generators().size()
<< " generators" << std::endl;
if (CommandlineOptions::debug()) {
std::cerr << "symmetries.generators():" << std::endl;
std::cerr << symmetries.generators() << std::endl;
}
}
}
else {
if (symmetries.read(std::cin)) {
if (CommandlineOptions::verbose()) {
std::cerr << "read symmetry group with " << symmetries.generators().size()
<< " generators of order " << symmetries.size() + 1 << std::endl;
if (CommandlineOptions::debug()) {
std::cerr << "symmetries:" << std::endl;
std::cerr << symmetries << std::endl;
}
}
}
}
}
else {
// read symmetries anyway into dummy structure to be able to read seed later:
SymmetryGroup dummy_symmetries(no);
dummy_symmetries.read(std::cin);
if (CommandlineOptions::verbose()) {
std::cerr << "no valid symmetry generators found." << std::endl;
}
}
if (compute_all) {
if (findmin) {
const size_type K = __min_triang_card(no,
rank,
points,
chiro,
symmetries,
output_triangs,
fine_only);
if (CommandlineOptions::verbose()) {
std::cerr << "... done." << std::endl;
}
if (!output_triangs) {
std::cout << K << std::endl;
}
goto TERM_OK;
}
else {
const size_type N = __no_of_all_triangs(no,
rank,
points,
chiro,
symmetries,
output_triangs,
fine_only);
if (CommandlineOptions::verbose()) {
std::cerr << N << " symmetry classes of triangulations in total." << std::endl;
std::cerr << "... done." << std::endl;
}
if (!output_triangs) {
std::cout << N << std::endl;
}
goto TERM_OK;
}
}
else {
Volumes* voltableptr = 0;
if (CommandlineOptions::use_gkz()
&& CommandlineOptions::symmetries_are_isometric()
&& !points.empty()) {
if (CommandlineOptions::verbose()) {
std::cerr << "computing volumes table ..." << std::endl;
}
voltableptr = new Volumes(points);
if (CommandlineOptions::verbose()) {
std::cerr << "... done." << std::endl;
}
}
if (CommandlineOptions::memopt()) {
if (CommandlineOptions::verbose()) {
std::cerr << "no preprocessing of simplex table to save memory" << std::endl;
}
}
else {
if (CommandlineOptions::verbose()) {
std::cerr << "preprocessing simplex table for all simplices up to rank "
<< rank + 1 << " ..." << std::endl;
}
if (voltableptr) {
SimplicialComplex::preprocess_index_table(no, 0, rank + 1, *voltableptr, true);
}
else {
SimplicialComplex::preprocess_index_table(no, 0, rank + 1, chiro, true);
}
if (CommandlineOptions::verbose()) {
std::cerr << "... done: "
<< SimplicialComplex::no_of_simplices(rank)
<< " full-dimensional simplices in rank " << rank << std::endl;
}
}
SimplicialComplex seed;
bool input_seed;
if (!seed.read(std::cin)) {
input_seed = false;
if (CommandlineOptions::verbose()) {
std::cerr << "no valid seed triangulation found" << std::endl;
std::cerr << "computing seed triangulation via placing and pushing ..."
<< std::endl;
}
if (fine_only) {
seed = FineTriang(chiro);
}
else {
seed = PlacingTriang(chiro);
}
}
else {
input_seed = true;
}
if (CommandlineOptions::verbose()) {
std::cerr << "computing symmetries of seed ..." << std::endl;
}
const symmetryptr_datapair seed_symmetryptrs(symmetries.stabilizer_ptrs(seed));
if (CommandlineOptions::verbose()) {
std::cerr << "... done." << std::endl;
std::cerr << seed_symmetryptrs.first.size() << " symmetries in total in seed." << std::endl;
if (CommandlineOptions::debug()) {
std::cerr << "symmetries:" << std::endl;
std::cerr << symmetries << std::endl;
}
}
if (CommandlineOptions::check()) {
if (CommandlineOptions::verbose()) {
std::cerr << "checking seed triangulation ..." << std::endl;
}
if (!(CheckTriang(seed, seed_symmetryptrs, chiro, symmetries, fine_only))()) {
if (CommandlineOptions::verbose()) {
std::cerr << "seed triangulation " << std::endl
<< seed << std::endl
<< "not valid." << std::endl;
}
goto TERM_ERROR;
}
if (CommandlineOptions::verbose()) {
std::cerr << "... done." << std::endl;;
}
}
if (CommandlineOptions::verbose()) {
std::cerr << "seed: " << seed << std::endl;
std::cerr << "containing " << seed.card() << " simplices" << std::endl;
std::cerr << "using the following " << seed.support().card() << " vertices: "
<< seed.support() << std::endl;
std::cerr << "... done." << std::endl;
}
if (findflips) {
if (CommandlineOptions::verbose()) {
std::cerr << "count all flips of seed ..." << std::endl;
}
const TriangNode tn(0, no, rank, seed);
const TriangFlips tf(chiro, tn, seed_symmetryptrs, fine_only);
if (CommandlineOptions::verbose()) {
std::cerr << tf.flips().size() << " flips in total." << std::endl;
std::cerr << "... done." << std::endl;
}
if (output_triangs) {
std::cout << tf << std::endl;
}
else {
std::cout << tf.flips().size() << std::endl;
}
goto TERM_OK;
}
if (CommandlineOptions::verbose()) {
std::cerr << "exploring all seed-connected symmetry classes of triangulations by flipping ..." << std::endl;
}
const size_type N = __no_of_triangs(no, rank, points, chiro,
symmetries,
seed, seed_symmetryptrs,
voltableptr,
output_triangs, fine_only);
if (CommandlineOptions::verbose()) {
std::cerr << N << " symmetry classes of triangulations in total." << std::endl;
std::cerr << "... done." << std::endl;
}
if (!output_triangs) {
std::cout << N << std::endl;
}
delete voltableptr;
goto TERM_OK;
}
}
TERM_ERROR:
if (CommandlineOptions::lp_solver_needed()) {
// some solvers need termination of global constants etc.:
RegularityCheck::term();
}
return 1;
TERM_OK:
if (CommandlineOptions::lp_solver_needed()) {
// some solvers need termination of global constants etc.:
RegularityCheck::term();
}
return 0;
}
}; // namespace topcom
// eof ComputeTriangs.cc
|