GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
//1// reduce_complex.cpp2// Bistellar3//4// Created by Alexander Thumm on 22.10.11.5// Copyright 2011 -. All rights reserved.6//789#include "reduce_complex.h"1011#include <iostream>12#include <stdlib.h>13#include <time.h>1415const unsigned int baseHeating = 4;16const unsigned int baseRelaxation = 3;171819void reduce_complex(MovableComplex & complex, unsigned int rounds, int heating, int relaxation)20{21if (complex.dimension() == 0)22return;2324// initialize the RNG25srand(static_cast<unsigned int>(time(0)));2627MovableComplex minimalComplex = complex;2829for (int currentRound = 1; currentRound < rounds; currentRound++)30{31// select move32bistellar_move_list_t moves;3334if (complex.dimension() < 3)35{36unsigned int i = complex.dimension();37while (moves.empty())38{39moves = complex.validMoves(i);40i--;41}42}43else if (complex.dimension() == 3)44{45if (heating > 0)46{47if (heating % 15 == 0)48{49moves = complex.validMoves(0);50}51else52{53moves = complex.validMoves(1);54if (moves.empty())55{56moves = complex.validMoves(2);57heating = 0;58}59}60heating--;61}62else63{64moves = complex.validMoves(3);65if (moves.empty())66{67moves = complex.validMoves(2);68if (moves.empty())69{70moves = complex.validMoves(1);71if (relaxation == 10)72{73heating = 15;74relaxation = 0;75}76relaxation++;77}78}79}80}81else if (complex.dimension() == 4)82{83if (heating > 0)84{85if (heating % 20 == 0)86{87moves = complex.validMoves(0);88}89else90{91moves = complex.validMoves(1);92bistellar_move_list_t temp = complex.validMoves(2);93if (!temp.empty())94moves.insert(moves.begin(), temp.begin(), temp.end());9596if (moves.empty())97moves = complex.validMoves(3);98}99heating--;100}101else102{103moves = complex.validMoves(4);104if (moves.empty())105{106moves = complex.validMoves(3);107if (moves.empty())108{109moves = complex.validMoves(2);110bistellar_move_list_t temp = complex.validMoves(1);111if (!temp.empty())112moves.insert(moves.begin(), temp.begin(), temp.end());113114if (relaxation == 10)115{116heating = 20;117relaxation = 0;118}119relaxation++;120}121}122}123}124else if (complex.dimension() == 5)125{126if (heating > 0)127{128if (heating % 40 == 0)129{130moves = complex.validMoves(0);131}132else133{134moves = complex.validMoves(1);135bistellar_move_list_t temp = complex.validMoves(2);136if (!temp.empty())137moves.insert(moves.begin(), temp.begin(), temp.end());138temp = complex.validMoves(3);139if (!temp.empty())140moves.insert(moves.begin(), temp.begin(), temp.end());141142if (moves.empty())143moves = complex.validMoves(4);144}145heating--;146}147else148{149moves = complex.validMoves(5);150if (moves.empty())151{152moves = complex.validMoves(4);153if (moves.empty())154{155moves = complex.validMoves(3);156if (moves.empty())157{158moves = complex.validMoves(2);159bistellar_move_list_t temp = complex.validMoves(1);160if (!temp.empty())161moves.insert(moves.begin(), temp.begin(), temp.end());162163if (relaxation == 20)164{165heating = 40;166relaxation = 0;167}168relaxation++;169}170}171}172}173174}175else176{177if (heating > 0)178{179//if (heating % ((complex.dimension()+2)*baseHeating) == 0)180//{181// moves = complex.validMoves(0);182//}183//else184//{185for (unsigned int i = 1; i < complex.dimension()/2 + 1; i++)186{187bistellar_move_list_t temp = complex.validMoves(i);188if (!temp.empty())189moves.insert(moves.begin(), temp.begin(), temp.end());190}191//}192if (moves.empty())193{194for (unsigned int i = 1; i < complex.dimension()+2; i++)195{196bistellar_move_list_t temp = complex.validMoves(complex.dimension() + 1 - i);197if (!temp.empty())198{199moves.insert(moves.begin(), temp.begin(), temp.end());200if (i > (complex.dimension()-1)/2)201break;202}203}204}205heating--;206}207else208{209if (complex.dimension() % 2 == 1)210{211for (unsigned int i = 1; i < (complex.dimension()+1)/2 + 1; i++)212{213bistellar_move_list_t temp = complex.validMoves(complex.dimension() + 1 - i);214if (!temp.empty())215{216moves = temp;217break;218}219}220}221else222{223for (unsigned int i = 1; i < std::min((complex.dimension()+1)/2 + 1, complex.dimension())+1; i++)224{225bistellar_move_list_t temp = complex.validMoves(complex.dimension() + 1 - i);226if (!temp.empty())227{228moves = temp;229break;230}231}232}233if (moves.empty())234{235for (unsigned int i = 1; i < std::min((complex.dimension()+1)/2 + 1, complex.dimension())+1; i++)236{237bistellar_move_list_t temp = complex.validMoves(i);238if (!temp.empty())239{240moves = temp;241break;242}243}244}245if (relaxation == (complex.dimension()+2)*baseRelaxation)246{247//heating = (complex.dimension()+2)*baseHeating;248heating = 1;249relaxation = 0;250}251relaxation++;252}253}254255// perform move256if (moves.size() == 0)257break;258259BistellarMove move = moves.at(rand() % moves.size());260complex.moveComplex(move);261262if (complex.f(0) < minimalComplex.f(0))263{264minimalComplex = complex;265std::cout << "found complex with " << minimalComplex.f(0) << " vertices in round " << currentRound << std::endl;266267}268}269complex = minimalComplex;270}271272273