GenerateIdealAction.cpp
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#include "stdinc.h"
#include "GenerateIdealAction.h"
#include "BigIdeal.h"
#include "GenerateDataFacade.h"
#include "IOFacade.h"
#include "error.h"
#include "DataType.h"
GenerateIdealAction::GenerateIdealAction():
Action
(staticGetName(),
"Generate a random monomial ideal.",
"Generate a monomial ideal. The default is to generate a random one,\n"
"and in certain rare cases the generated ideal may have less than the "
"requested\n"
"number of minimial generators. This can be alleviated by increasing the\n"
"exponent range or the number of variables.\n\n"
"The other types of ideals are not random, and they use the number of "
"variables\n"
"as a parameter and may thus have more generators, depending on the type.",
false),
_type
("type",
"The supported types of ideals are random, edge, list, king, knight, rook, matching and tree.",
"random"),
_variableCount("varCount", "The number of variables.", 3),
_generatorCount("genCount", "The number of minimal generators.", 5),
_exponentRange
("expRange",
"Exponents are chosen uniformly in the range [0,INTEGER].", 9),
_io(DataType::getNullType(), DataType::getMonomialIdealType()) {
}
void GenerateIdealAction::obtainParameters(vector<Parameter*>& parameters) {
Action::obtainParameters(parameters);
_io.obtainParameters(parameters);
parameters.push_back(&_exponentRange);
parameters.push_back(&_variableCount);
parameters.push_back(&_generatorCount);
parameters.push_back(&_type);
}
void GenerateIdealAction::perform() {
_io.validateFormats();
BigIdeal ideal;
GenerateDataFacade generator(_printActions);
const string& type = _type;
if (type == "random")
generator.generateIdeal(ideal,
_exponentRange,
_variableCount,
_generatorCount);
else if (type == "list")
generator.generateListIdeal(ideal, _variableCount);
else if (type == "edge")
generator.generateEdgeIdeal(ideal, _variableCount, _generatorCount);
else if (type == "king")
generator.generateKingChessIdeal(ideal, _variableCount);
else if (type == "knight")
generator.generateKnightChessIdeal(ideal, _variableCount);
else if (type == "rook")
generator.generateRookChessIdeal(ideal, _variableCount, _generatorCount);
else if (type == "matching")
generator.generateMatchingIdeal(ideal, _variableCount);
else if (type == "tree")
generator.generateTreeIdeal(ideal, _variableCount);
else
reportError("Unknown ideal type \"" + type + "\".");
IOFacade ioFacade(_printActions);
unique_ptr<IOHandler> output = _io.createOutputHandler();
ioFacade.writeIdeal(ideal, output.get(), stdout);
}
const char* GenerateIdealAction::staticGetName() {
return "genideal";
}
BigIdeal.h
DataType.h
GenerateDataFacade.h
GenerateIdealAction.h
IOFacade.h
Action::_printActions
BoolParameter _printActions
Definition Action.h:68
Action::Action
Action(const char *name, const char *shortDescription, const char *description, bool acceptsNonParameter)
Definition Action.cpp:46
Action::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition Action.cpp:133
BigIdeal
Definition BigIdeal.h:27
DataType
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
Definition DataType.h:29
GenerateDataFacade
A facade for random and other kinds of data.
Definition GenerateDataFacade.h:29
GenerateDataFacade::generateIdeal
void generateIdeal(BigIdeal &ideal, size_t exponentRange, size_t varCount, size_t generatorCount)
Definition GenerateDataFacade.cpp:96
GenerateDataFacade::generateKingChessIdeal
void generateKingChessIdeal(BigIdeal &ideal, unsigned int rowsAndColumns)
Definition GenerateDataFacade.cpp:36
GenerateDataFacade::generateTreeIdeal
void generateTreeIdeal(BigIdeal &ideal, unsigned int varCount)
Definition GenerateDataFacade.cpp:73
GenerateDataFacade::generateEdgeIdeal
void generateEdgeIdeal(BigIdeal &ideal, size_t varCount, size_t generatorCount)
Definition GenerateDataFacade.cpp:83
GenerateDataFacade::generateKnightChessIdeal
void generateKnightChessIdeal(BigIdeal &ideal, unsigned int rowsAndColumns)
Definition GenerateDataFacade.cpp:46
GenerateDataFacade::generateRookChessIdeal
void generateRookChessIdeal(BigIdeal &ideal, unsigned int n, unsigned int k)
Definition GenerateDataFacade.cpp:55
GenerateDataFacade::generateMatchingIdeal
void generateMatchingIdeal(BigIdeal &ideal, unsigned int n)
Definition GenerateDataFacade.cpp:64
GenerateDataFacade::generateListIdeal
void generateListIdeal(BigIdeal &ideal, size_t varCount)
Definition GenerateDataFacade.cpp:27
GenerateIdealAction::_type
StringParameter _type
Definition GenerateIdealAction.h:36
GenerateIdealAction::staticGetName
static const char * staticGetName()
Definition GenerateIdealAction.cpp:98
GenerateIdealAction::GenerateIdealAction
GenerateIdealAction()
Definition GenerateIdealAction.cpp:26
GenerateIdealAction::perform
virtual void perform()
Definition GenerateIdealAction.cpp:63
GenerateIdealAction::_exponentRange
IntegerParameter _exponentRange
Definition GenerateIdealAction.h:40
GenerateIdealAction::obtainParameters
virtual void obtainParameters(vector< Parameter * > &parameters)
Definition GenerateIdealAction.cpp:53
GenerateIdealAction::_io
IOParameters _io
Definition GenerateIdealAction.h:42
GenerateIdealAction::_generatorCount
IntegerParameter _generatorCount
Definition GenerateIdealAction.h:39
GenerateIdealAction::_variableCount
IntegerParameter _variableCount
Definition GenerateIdealAction.h:38
IOFacade
A facade for input and output of mathematical objects.
Definition IOFacade.h:39
IOFacade::writeIdeal
void writeIdeal(const BigIdeal &ideal, IOHandler *handler, FILE *out)
Definition IOFacade.cpp:156
reportError
void reportError(const string &errorMsg)
Definition error.cpp:23
error.h
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...