38 const Ideal& initialSubtract):
41 _initialSubtract(new
Ideal(initialSubtract)) {
54 Term sliceMultiply(varCount);
55 for (
size_t var = 0; var < varCount; ++var)
56 sliceMultiply[var] = 1;
91 return auto_ptr<MsmSlice>(
static_cast<MsmSlice*
>(slice.release()));
95 return auto_ptr<Slice>(
new MsmSlice(*
this));
105 ASSERT(sliceParam.get() != 0);
107 auto_ptr<MsmSlice> slice
108 (
static_cast<MsmSlice*
>(sliceParam.release()));
110 ASSERT(!slice->adjustMultiply());
111 ASSERT(!slice->normalize());
115 Term term(slice->getVarCount());
117 const Term&
lcm = slice->getLcm();
121 bool hasTwoLabels =
false;
124 if ((*it)[var] == 1) {
128 bool couldBeLabel = !slice->getSubtract().contains(term);
130 for (
size_t v = 0; v < slice->getVarCount(); ++v) {
131 if (term[v] ==
lcm[v]) {
132 couldBeLabel =
false;
149 auto_ptr<Slice> hasLabelSlice;
156 *hasLabelSlice = *slice;
157 hasLabelSlice->innerSlice(term);
160 slice->outerSlice(term);
166 slice->innerSlice(term);
169 if (hasLabelSlice.get() != 0) {
260 ASSERT(sliceParam.get() != 0);
262 auto_ptr<MsmSlice> slice
263 (
static_cast<MsmSlice*
>(sliceParam.release()));
267 autoSplit->reset(slice->getConsumer(),
_indep);
272 auto_ptr<MsmSlice> leftSlice(
new MsmSlice(*
this));
277 auto_ptr<MsmSlice> rightSlice(
new MsmSlice(*
this));
Represents a monomial ideal with int exponents.
void clearAndSetVarCount(size_t varCount)
Cont::const_iterator const_iterator
void insert(const Exponent *term)
const_iterator end() const
const_iterator begin() const
size_t getVarCount() const
void getRestProjection(Projection &projection) const
size_t getVarCount() const
void getBigProjection(Projection &projection) const
bool analyze(const Slice &slice)
Projection _leftProjection
MsmIndependenceSplit::RightConsumer _rightConsumer
virtual void dispose()
Called when the task is no longer used but run has not and will not be called.
TermConsumer * getLeftConsumer()
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.
Projection _rightProjection
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
virtual void run(TaskEngine &engine)
Does whatever work this task represents.
void reset(TermConsumer *consumer, IndependenceSplitter &splitter)
const Projection & getRightProjection()
TermConsumer * getRightConsumer()
const Projection & getLeftProjection()
virtual void consume(const Term &term)
Consume a term.
Invariant: either the slice is a trivial base case, or removeDoubleLcm returns false.
auto_ptr< MsmSlice > newMsmSlice()
virtual bool debugIsValidSlice(Slice *slice)
Check that this slice is valid for use with this strategy.
void independenceSplit(auto_ptr< Slice > slice)
IndependenceSplitter _indep
virtual bool processSlice(TaskEngine &tasks, auto_ptr< Slice > slice)
Process the parameter slice.
virtual void getPivot(Term &pivot, Slice &slice)
Used by pivotSplit to obtain a pivot.
void labelSplit(auto_ptr< Slice > slice)
virtual void run(const Ideal &ideal)
Run the Slice algorithm.
MsmStrategy(TermConsumer *consumer, const SplitStrategy *splitStrategy)
virtual auto_ptr< Slice > allocateSlice()
Directly allocate a slice of the correct type using new.
auto_ptr< Ideal > _initialSubtract
void inverseProject(Term &to, const Exponent *from) const
size_t getRangeVarCount() const
This class adds code to the SliceStrategy base class that is useful for derived classes.
bool getUseIndependence() const
Returns true if independence splits should be performed when possible.
bool getUseSimplification() const
Returns true if slices should be simplified.
const SplitStrategy * _split
virtual bool simplify(Slice &slice)
Simplifies slice and returns true if it changed.
virtual void pivotSplit(auto_ptr< Slice > slice)
Takes over ownership of slice.
auto_ptr< Slice > newSlice()
Returns a slice from the cache that freeSlice adds to, or allocate a new one using allocateSlice.
virtual void freeSlice(auto_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
TaskEngine _tasks
This keeps track of pending tasks to process.
This class represents a slice, which is the central data structure of the Slice Algorithm.
A SplitStrategy is an implementation of a split selection strategy for the Slice Algorithm.
virtual size_t getLabelSplitVariable(const Slice &slice) const =0
Returns the variable to perform a label split on.
virtual bool isPivotSplit() const =0
If returns true, only call getPivot.
virtual bool isLabelSplit() const =0
If returns true, only call getLabelSplitVariable.
virtual void getPivot(Term &pivot, Slice &slice) const =0
Sets pivot to the pivot of a pivot split on slice.
TaskEngine handles a list of tasks that are to be carried out.
void addTask(Task *task)
Add a task at the head of the list of pending tasks.
void runTasks()
Runs all pending tasks.
A Task object represents a unit of work that is performed when the method run() is called.
This class is used to transfer terms one at a time from one part of the program to another,...
virtual void beginConsuming()=0
Tell the consumer to begin consuming an ideal.
virtual void doneConsuming()=0
Must be called once after each time beginConsuming has been called.
virtual void consume(const Term &term)=0
Consume a term.
A TermGrader assigns a value, the degree, to each monomial.
Term represents a product of variables which does not include a coefficient.
void reset(size_t newVarCount)
static void setToIdentity(Exponent *res, size_t varCount)
Set res equal to , i.e. set each entry of res equal to 0.
void lcm(Word *res, const Word *resEnd, const Word *a, const Word *b)
virtual void doneConsuming()
Must be called once after each time beginConsuming has been called.
virtual void consume(const Term &term)
Consume a term.
virtual void beginConsuming()
Tell the consumer to begin consuming an ideal.