51 Facade(params.getPrintActions()),
54 _common.readIdealAndSetOutput(params, output);
60 Facade(params.getPrintActions()),
63 _common.setIdealAndIdealOutput(params, ideal, consumer);
69 Facade(params.getPrintActions()),
72 _common.setIdealAndPolyOutput(params, ideal, consumer);
80 beginAction(
"Computing multigraded Hilbert-Poincare series.");
82 unique_ptr<CoefTermConsumer> consumer =
_common.makeTranslatedPolyConsumer();
84 consumer->consumeRing(
_common.getNames());
85 consumer->beginConsuming();
88 consumer->doneConsuming();
95 beginAction(
"Computing univariate Hilbert-Poincare series.");
97 unique_ptr<CoefTermConsumer> consumer =
98 _common.makeToUnivariatePolyConsumer();
100 consumer->consumeRing(
_common.getNames());
101 consumer->beginConsuming();
104 consumer->doneConsuming();
117 if (
_common.getIdeal().containsIdentity()) {
120 return mpz_class(
_common.getIdeal().getVarCount()) + 1;
131 fill_n(back_inserter(v),
_common.getIdeal().getVarCount(), -1);
135 mpz_class minusCodimension;
145 return -minusCodimension;
147 return v.size() + minusCodimension;
153 size_t varCount =
_common.getIdeal().getVarCount();
155 Ideal irreducibleDecom(varCount);
162 (
"Computing primary decomposition from irreducible decomposition.");
172 _common.getTranslator().setInfinityPowersToZero(irreducibleDecom);
178 irreducibleDecom.
getLcm(lcm);
181 Term support(varCount);
185 Ideal primaryComponent(varCount);
189 unique_ptr<TermConsumer> consumer =
_common.makeTranslatedIdealConsumer();
190 consumer->consumeRing(
_common.getNames());
191 consumer->beginConsumingList();
200 primaryComponentDual.
insert(tmp);
205 _common.getTranslator().addPurePowersAtInfinity(primaryComponentDual);
210 _common.getTranslator().setInfinityPowersToZero(primaryComponent);
212 consumer->beginConsuming();
214 dualTerm != primaryComponent.
end(); ++dualTerm) {
216 consumer->consume(tmp);
218 consumer->doneConsuming();
220 primaryComponent.
clear();
221 primaryComponentDual.
clear();
224 consumer->doneConsumingList();
231 beginAction(
"Computing maximal staircase monomials.");
233 unique_ptr<TermConsumer> consumer =
_common.makeTranslatedIdealConsumer();
234 consumer->consumeRing(
_common.getNames());
244 beginAction(
"Preparing to compute maximal standard monomials.");
245 _common.getTranslator().decrement();
254 beginAction(
"Ensuring specified point is divisible by lcm.");
255 vector<mpz_class> lcm;
258 for (
size_t var = 0; var < lcm.size(); ++var) {
259 if (lcm[var] > point[var]) {
262 (
"The specified point to dualize on is not divisible by the "
263 "least common multiple of the minimal generators of the ideal.");
268 beginAction(
"Preparing to compute Alexander dual.");
269 _common.getTranslator().dualize(point);
279 vector<mpz_class> lcm;
289 size_t varCount =
_common.getIdeal().getVarCount();
292 Ideal radical(varCount);
294 Ideal decom(varCount);
298 beginAction(
"Computing associated primes from irreducible decomposition.");
303 for (
size_t var = 0; var < varCount; ++var) {
307 if (
_common.getTranslator().getExponent(var, (*it)[var]) == 0)
321 unique_ptr<TermConsumer> consumer =
_common.makeTranslatedIdealConsumer();
323 consumer->consumeRing(
_common.getNames());
324 consumer->beginConsuming();
329 consumer->consume(tmp);
331 consumer->doneConsuming();
337(
const vector<mpz_class>& grading,
338 mpz_class& optimalValue,
339 bool reportAllSolutions) {
343 beginAction(
"Preparing to solve optimization program.");
344 if (!
_common.getIdeal().containsIdentity())
345 _common.addPurePowersAtInfinity();
348 return solveProgram(grading, optimalValue, reportAllSolutions);
352(
const vector<mpz_class>& grading,
353 mpz_class& optimalValue,
354 bool reportAllSolutions) {
358 _common.getTranslator().decrement();
359 return solveProgram(grading, optimalValue, reportAllSolutions);
364 beginAction(
"Computing irreducible decomposition.");
366 _common.addPurePowersAtInfinity();
376 mpz_class& optimalValue,
377 bool reportAllSolutions) {
381 if (
_params.getUseIndependenceSplits()) {
383 (
"Turning off Independence splits as they are not supported\n"
384 "for optimization.");
385 _params.useIndependenceSplits(
false);
388 if (
_params.getUseBoundSimplification() &&
389 !
_params.getUseBoundElimination()) {
391 (
"Bound simplification requires using the bound to eliminate\n"
392 "non-improving slices, which has been turned off. Am now turning\n"
394 _params.useBoundElimination(
true);
400 if (
_params.getUseBoundSimplification()) {
403 }
else if (
_params.getUseBoundElimination())
410 (grader,
_split.get(), reportAllSolutions, boundSetting);
417 unique_ptr<TermConsumer> consumer =
_common.makeTranslatedIdealConsumer();
418 consumer->consumeRing(
_common.getNames());
419 consumer->consume(solution);
440 _common.getIdeal().getLcm(lcm);
441 if (lcm.isSquareFree())
445 _common.getTranslator().setInfinityPowersToZero(
_common.getIdeal());
446 _common.getIdeal().takeRadicalNoMinimize();
459 _common.getIdeal().getLcm(lcm);
462 bigLcm.reserve(
_common.getIdeal().getVarCount());
463 for (
size_t var = 0; var <
_common.getIdeal().getVarCount(); ++var)
464 bigLcm.push_back(
_common.getTranslator().getExponent(var, lcm));
474 unique_ptr<SliceStrategy> debugStrategy;
477 (
new DebugStrategy(strategyWithOptions, stderr));
478 strategyWithOptions = debugStrategy.get();
481 unique_ptr<SliceStrategy> statisticsStrategy;
482 if (
_params.getPrintStatistics()) {
483 statisticsStrategy.reset
485 strategyWithOptions = statisticsStrategy.get();
488 ASSERT(strategyWithOptions != 0);
void setToZeroOne(TermTranslator &translator)
The intention of this class is to describe the different kinds of mathematical structures that Frobby...
void beginAction(const char *message)
Prints message to standard error if printing is turned on, and records the time when the action start...
void endAction()
Prints to standard error the time since the last call to beginAction.
Facade(bool printActions)
Constructs a facade that prints out what it is doing if printActions is true.
Represents a monomial ideal with int exponents.
void getLcm(Exponent *lcm) const
Sets lcm to the least common multiple of all generators.
Cont::const_iterator const_iterator
void insert(const Exponent *term)
const_iterator end() const
const_iterator begin() const
OptimizeStrategy optimizes a function on the maximal standard monomials of a monomial ideal using bra...
BoundSetting
The values of BoundSetting indicate how to use the bound.
@ DoNotUseBound
Make no use of the bound.
@ UseBoundToEliminateAndSimplify
Eliminate non-improving slices and simplify slices by trying to generate non-improving slices that ar...
@ UseBoundToEliminate
Eliminate non-improving slices, achieving a branch-and-bound algorithm in place of the usual backtrac...
const Ideal & getMaximalSolutions()
Returns one of or all of the msm's with optimal value found so far, depending on the value of reportA...
const mpz_class & getMaximalValue()
The optimal value associated to all entries from getMaximalSolutions().
unique_ptr< SplitStrategy > _split
void computeAssociatedPrimes()
Compute the associated primes of the ideal.
void runSliceAlgorithmWithOptions(SliceStrategy &strategy)
void computeMultigradedHilbertSeries()
Compute the numerator of the multigraded Hilbert-Poincare series.
bool solveStandardProgram(const vector< mpz_class > &grading, mpz_class &value, bool reportAllSolutions)
Solve an optimization program over maximal standard monomials.
bool solveIrreducibleDecompositionProgram(const vector< mpz_class > &grading, mpz_class &optimalValue, bool reportAllSolutions)
Solve an optimization program over irreducible components.
bool isFirstComputation() const
CommonParamsHelper _common
void getLcmOfIdeal(vector< mpz_class > &lcm)
mpz_class computeDimension(bool codimension=false)
Compute the Krull dimension of ideal.
SliceFacade(const SliceParams ¶ms, const DataType &output)
void computeUnivariateHilbertSeries()
Compute the numerator of the univariate Hilbert-Poincare series.
void computePrimaryDecomposition()
Compute the unique "nicest" primary decomposition of the ideal.
bool solveProgram(const vector< mpz_class > &grading, mpz_class &optimalValue, bool reportAllSolutions)
void computeIrreducibleDecomposition(bool encode)
Compute the unique irredundant set of irreducible ideals whose intersection equals ideal.
void computeMaximalStaircaseMonomials()
Compute the maximal staircase monomials of the ideal.
void computeMaximalStandardMonomials()
Compute the maximal standard monomials of the ideal.
void produceEncodedIrrDecom(TermConsumer &consumer)
void computeAlexanderDual()
Compute the Alexander dual of the ideal.
const string & getSplit() const
This class describes the interface of a strategy object for the Slice Algorithm.
virtual void setUseSimplification(bool use)=0
This method should only be called before calling run().
virtual void setUseIndependence(bool use)=0
This method should only be called before calling run().
virtual void run(const Ideal &ideal)=0
Run the Slice algorithm.
static unique_ptr< SplitStrategy > createStrategy(const string &prefix)
Returns the strategy whose name has the given prefix.
A wrapper for a SliceStrategy that collects statistics on what is going on, while delegating everythi...
This class is used to transfer terms one at a time from one part of the program to another,...
virtual void consumeRing(const VarNames &names)
Tell the consumer which ring is being used.
A TermGrader assigns a value, the degree, to each monomial.
Term represents a product of variables which does not include a coefficient.
static bool hasSameSupport(const Exponent *a, const Exponent *b, size_t varCount)
Returns whether for every variable .
static void encodedDual(Exponent *res, const Exponent *dualOf, const Exponent *point, size_t varCount)
The parameter dualOf is interpreted to encode an irreducible ideal, and the dual of that reflected in...
void displayNote(const string &msg)
Display msg to standard error in a way that indicates that this is something that the user should tak...
This file contains functions for printing strings to standard error.
void reportError(const string &errorMsg)
This header file includes common definitions and is included as the first line of code in every imple...