SliceParameters.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 "SliceParameters.h"
#include "SliceFacade.h"
#include "error.h"
#include "BigattiPivotStrategy.h"
#include "BigattiFacade.h"
SliceParameters::SliceParameters(bool exposeBoundParam,
bool exposeIndependenceParam,
bool supportBigattiAlgorithm):
_exposeBoundParam(exposeBoundParam),
_exposeIndependenceParam(exposeIndependenceParam),
_printDebug
("debug",
"Print what the algorithm does at each step.",
false),
_printStatistics
("stats",
"Print statistics on what the algorithm did.",
false),
_useBoundElimination
("bound",
"Use the bound optimization to solve optimization problems faster\n"
"by eliminating non-improving slices.",
exposeBoundParam),
_useBoundSimplification
("boundSimplify",
"Use the bound optimization to solve optimization problems faster by\n"
"simplifying slices through seeking to generate non-improving slices.\n"
"This requires turning elimination of non-improving slices on.",
exposeBoundParam),
_useIndependence
("independence",
"Perform independence splits when possible.",
exposeIndependenceParam),
_useSimplification
("simplify",
"Perform simplification when possible.",
true),
_minimal
("minimal",
"Specifies that the input ideal is minimally generated by the given\n"
"generators. Turning this on can improve performance, but if it is not\n"
"true then Frobby may go into an infinite loop or produce incorrect results.",
false),
_canonical
("canon",
"Sort the output, including the variables, to get a canonical\n"
"representation. This requires storing the entire output in memory, which\n"
"can increase run time modestly and increase memory consumption greatly.",
false),
_useBigattiGeneric
("genericBase",
"Detect generic ideals as a base case of the Bigatti algorithm.",
true),
_widenPivot
("widenPivot",
"Widen selected pivots when performing pivot splits.\n"
"Bigatti et.al. algorithm only.",
true),
_split
("split",
"The split selection strategy to use. Slice options are maxlabel, minlabel,\n"
"varlabel, minimum, median, maximum, mingen, indep and gcd. Optimization\n"
"computations support the specialized strategy degree as well.",
"median") {
addParameter(&_minimal);
addParameter(&_split);
addParameter(&_printStatistics);
if (exposeIndependenceParam)
addParameter(&_useIndependence);
addParameter(&_useSimplification);
addParameter(&_printDebug);
if (_exposeBoundParam) {
addParameter(&_useBoundSimplification);
addParameter(&_useBoundElimination);
}
addParameter(&_canonical);
if (supportBigattiAlgorithm) {
addParameter(&_useBigattiGeneric);
addParameter(&_widenPivot);
_printDebug.appendToDescription
(" Slice algorithm only.");
_printStatistics.appendToDescription
(" Slice algorithm only.");
_useIndependence.appendToDescription
(" Slice algorithm only.");
_minimal.appendToDescription
("\nSlice algorithm only.");
_canonical.appendToDescription
("\nThe impact for the Bigatti et.al. algorithm is much less than for the"
"\nSlice Algorithm since the Bigatti et.al. algorithm always has to\n"
"store the entire output in memory regardless of this option.");
_split.appendToDescription
("\nBigatti et.al. options are median, mostNGPure, mostNGGcd,\n"
"mostNGTight, typicalPure, typicalGcd, typicalTight, typicalNGPure,\n"
"typicalNGGcd, typicalNGTight, someNGPure, someNGGcd and someNGTight.");
}
}
void SliceParameters::setUseIndependence(bool value) {
_useIndependence = value;
}
void SliceParameters::setSplit(const string& split) {
_split = split;
}
bool SliceParameters::getUseBoundElimination() const {
return _useBoundElimination;
}
bool SliceParameters::getUseBoundSimplification() const {
return _useBoundSimplification;
}
bool SliceParameters::getCanonical() const {
return _canonical;
}
const string& SliceParameters::getSplit() const {
return _split.getValue();
}
void SliceParameters::validateSplit(bool allowLabel,
bool allowDegree) {
unique_ptr<SplitStrategy>
split(SplitStrategy::createStrategy(_split.getValue().c_str()));
if (split.get() == 0)
reportError("Unknown Slice split strategy \"" + _split.getValue() + "\".");
if (!allowLabel && split->isLabelSplit())
reportError("Label split strategy is not appropriate "
"in this context.");
// TODO: implement degree when there is no grading too, so that it
// is always appropriate.
if (!allowDegree && _split.getValue() == "degree") {
reportError("The split strategy degree is not appropriate "
"in this context.");
}
// TODO: remove the deprecated frob.
if (!allowDegree && _split.getValue() == "frob") {
reportError("The split strategy frob is not appropriate "
"in this context.");
}
}
void SliceParameters::validateSplitHilbert() {
unique_ptr<BigattiPivotStrategy> split = BigattiPivotStrategy::createStrategy
(_split.getValue().c_str(), _widenPivot);
if (split.get() == 0)
reportError("Unknown Bigatti et.al. pivot strategy \"" +
_split.getValue() + "\".");
}
bool SliceParameters::getPrintDebug() const {
return _printDebug;
}
bool SliceParameters::getPrintStatistics() const {
return _printStatistics;
}
BigattiFacade.h
BigattiPivotStrategy.h
SliceFacade.h
SliceParameters.h
ParameterGroup::addParameter
void addParameter(Parameter *parameter)
Definition ParameterGroup.cpp:31
SliceParameters::getPrintStatistics
bool getPrintStatistics() const
Returns the value of the stats option.
Definition SliceParameters.cpp:194
SliceParameters::_printDebug
BoolParameter _printDebug
Definition SliceParameters.h:94
SliceParameters::_canonical
BoolParameter _canonical
Definition SliceParameters.h:101
SliceParameters::validateSplit
void validateSplit(bool allowLabel, bool allowDegree)
Checks that the slice split selection strategy specified is valid.
Definition SliceParameters.cpp:155
SliceParameters::getCanonical
bool getCanonical() const
Get the value of the canonical option.
Definition SliceParameters.cpp:147
SliceParameters::validateSplitHilbert
void validateSplitHilbert()
Checks that the Bigatti Et.al.
Definition SliceParameters.cpp:181
SliceParameters::setSplit
void setSplit(const string &split)
Set the value of the option for choosing the split selection strategy.
Definition SliceParameters.cpp:135
SliceParameters::SliceParameters
SliceParameters(bool exposeBoundParams=false, bool exposeIndependenceParam=true, bool supportBigattiAlgorithm=false)
Construct the parameters with default values.
Definition SliceParameters.cpp:25
SliceParameters::_useIndependence
BoolParameter _useIndependence
Definition SliceParameters.h:98
SliceParameters::_printStatistics
BoolParameter _printStatistics
Definition SliceParameters.h:95
SliceParameters::_exposeBoundParam
bool _exposeBoundParam
Definition SliceParameters.h:91
SliceParameters::getUseBoundElimination
bool getUseBoundElimination() const
Get the value of the bound elimination option.
Definition SliceParameters.cpp:139
SliceParameters::_widenPivot
BoolParameter _widenPivot
Definition SliceParameters.h:103
SliceParameters::_useBoundSimplification
BoolParameter _useBoundSimplification
Definition SliceParameters.h:97
SliceParameters::_minimal
BoolParameter _minimal
Definition SliceParameters.h:100
SliceParameters::_exposeIndependenceParam
bool _exposeIndependenceParam
Definition SliceParameters.h:92
SliceParameters::_split
StringParameter _split
Definition SliceParameters.h:105
SliceParameters::getSplit
const string & getSplit() const
Get the value of the split option.
Definition SliceParameters.cpp:151
SliceParameters::_useSimplification
BoolParameter _useSimplification
Definition SliceParameters.h:99
SliceParameters::_useBigattiGeneric
BoolParameter _useBigattiGeneric
Definition SliceParameters.h:102
SliceParameters::getUseBoundSimplification
bool getUseBoundSimplification() const
Get the value of the bound simplification option.
Definition SliceParameters.cpp:143
SliceParameters::getPrintDebug
bool getPrintDebug() const
Returns the value of the debug option.
Definition SliceParameters.cpp:190
SliceParameters::_useBoundElimination
BoolParameter _useBoundElimination
Definition SliceParameters.h:96
SliceParameters::setUseIndependence
void setUseIndependence(bool value)
Set the value of the independence split option.
Definition SliceParameters.cpp:131
SplitStrategy::createStrategy
static unique_ptr< SplitStrategy > createStrategy(const string &prefix)
Returns the strategy whose name has the given prefix.
Definition SplitStrategy.cpp:497
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...