16 #include <carl-common/memory/IDPool.h>
25 template<
typename T1,
typename T2>
204 template<
class Settings,
typename T1,
typename T2>
234 premise( std::move( _premise ) )
257 std::vector<Variable<T1,T2>*>
mRows;
275 carl::FastPointerMap<typename Poly::PolyType, Variable<T1,T2>*>
mSlackVars;
355 bool vEnd(
bool downwards )
const
363 bool hEnd(
bool leftwards )
const
374 assert( !
vEnd( downwards ) );
384 assert( !
hEnd( leftwards ) );
391 std::vector<TableauEntry<T1,T2> >*
pEntries()
const
431 void setSize(
size_t _expectedHeight,
size_t _expectedWidth,
size_t _expectedNumberOfBounds )
433 mRows.reserve( _expectedHeight );
435 mpEntries->reserve( _expectedHeight*_expectedWidth+1 );
457 const std::vector<Variable<T1, T2>*>&
rows()
const
465 const std::vector<Variable<T1, T2>*>&
columns()
const
473 const carl::FastMap< carl::Variable, Variable<T1,T2>*>&
originalVars()
const
481 const carl::FastPointerMap<typename Poly::PolyType, Variable<T1,T2>*>&
slackVars()
const
554 if( Settings::omit_division )
565 if( Settings::omit_division )
763 std::cout <<h.content()<<
'\n';
860 void update(
bool _downwards,
EntryID _pivotingElement, std::vector<Iterator>& _pivotingRowLeftSide, std::vector<Iterator>& _pivotingRowRightSide,
bool _optimizing =
false );
950 void printHeap( std::ostream& _out = std::cout,
int _maxEntryLength = 30,
const std::string _init =
"" )
const;
958 void printEntry(
EntryID _entry, std::ostream& _out = std::cout,
int _maxEntryLength = 20 )
const;
966 void printVariables(
bool _allBounds =
true, std::ostream& _out = std::cout,
const std::string _init =
"" )
const;
992 void print(
EntryID _pivotingElement =
LAST_ENTRY_ID, std::ostream& _out = std::cout,
const std::string _init =
"",
bool _friendlyNames =
true,
bool _withZeroColumns =
false )
const;
Stores a bound, which could be an upper "<= b" or a lower bound ">= b" for a bound value b.
EntryID vNext(bool downwards)
TableauEntry(EntryID _up, EntryID _down, EntryID _left, EntryID _right, Variable< T1, T2 > *_rowVar, Variable< T1, T2 > *_columnVar, const T2 &_content)
Variable< T1, T2 > * rowVar() const
void setHNext(bool leftwards, const EntryID _entryId)
Variable< T1, T2 > * mRowVar
const T2 & content() const
Variable< T1, T2 > * columnVar() const
EntryID hNext(bool leftwards)
TableauEntry(const TableauEntry &_entry)
Variable< T1, T2 > * mColumnVar
void setVNext(bool downwards, const EntryID _entryId)
void setColumnVar(Variable< T1, T2 > *_columnVar)
void setRowVar(Variable< T1, T2 > *_rowVar)
Iterator(const Iterator &_iter)
bool hEnd(bool leftwards) const
bool vEnd(bool downwards) const
void operator=(Iterator &&_iter)
Iterator(EntryID _start, std::vector< TableauEntry< T1, T2 > > *const _entries)
void vMove(bool downwards)
bool operator!=(const Iterator &_iter) const
void hMove(bool leftwards)
TableauEntry< T1, T2 > & operator*()
void operator=(const Iterator &_iter)
bool operator==(const Iterator &_iter) const
std::vector< TableauEntry< T1, T2 > > * mpEntries
std::vector< TableauEntry< T1, T2 > > * pEntries() const
void rowRefinement(Variable< T1, T2 > *_basicVar)
Tries to refine the supremum and infimum of the given basic variable.
std::vector< Variable< T1, T2 > * > mConflictingRows
carl::FastPointerMap< Variable< T1, T2 >, LearnedBound > mLearnedLowerBounds
void printVariables(bool _allBounds=true, std::ostream &_out=std::cout, const std::string _init="") const
void addToEntry(const T2 &_toAdd, Iterator &_horiIter, bool _horiIterLeftFromVertIter, Iterator &_vertIter, bool _vertIterBelowHoriIter)
Adds the given value to the entry being at the position (i,j), where i is the vertical position of th...
std::stack< EntryID > mUnusedIDs
bool betterEntry(EntryID _isBetter, EntryID _than) const
const std::vector< Variable< T1, T2 > * > & columns() const
carl::FastMap< carl::Variable, Variable< T1, T2 > * > mOriginalVars
void updateBasicAssignments(size_t _column, const Value< T1 > &_change)
const carl::FastMap< FormulaT, std::vector< const Bound< T1, T2 > * > * > & constraintToBound() const
std::vector< const Bound< T1, T2 > * > getMultilineConflict()
std::pair< EntryID, bool > hasConflict()
Checks if a conflicting pair exists.
void adaptDelta(const Variable< T1, T2 > &_variable, bool _upperBound, T1 &_minDelta) const
std::vector< Variable< T1, T2 > * > mRows
carl::FastMap< FormulaT, std::vector< const Bound< T1, T2 > * > * > mConstraintToBound
ModuleInput::iterator mDefaultBoundPosition
void computeLeavingCandidates(const std::size_t i, std::vector< std::pair< Value< T1 >, Variable< T1, T2 > * > > &leaving_candidates)
Helper method to compute leavind candidates used in nextPivotingElementInfeasibilities.
size_t numberOfPivotingSteps() const
void resetNumberOfPivotingSteps()
bool rowCorrect(size_t _rowNumber) const
void setBlandsRuleStart(size_t _start)
std::pair< EntryID, bool > nextPivotingElementInfeasibilities()
Method for next pivoting element according to "Simplex with Sum of Infeasibilities for SMT" by Tim Ki...
carl::FastPointerMap< Variable< T1, T2 >, LearnedBound > & rLearnedUpperBounds()
RationalAssignment getRationalAssignment() const
size_t boundedVariables(const Variable< T1, T2 > &_var, size_t _stopCriterium=0) const
Variable< T1, T2 > * getObjectiveVariable(const Poly &_lhs)
bool isActive(const Variable< T1, T2 > &_var) const
void collect_premises(const Variable< T1, T2 > *_rowVar, FormulasT &premises) const
Collects the premises for branch and bound and stores them in premises.
void updateNonbasicVariable(EntryID _pivotingElement)
Updates a nonbasic variable by the assignment stored in mpTheta and triggers updates of depending bas...
const T1 & currentDelta() const
const carl::FastPointerMap< typename Poly::PolyType, Variable< T1, T2 > * > & slackVars() const
carl::IDPool mVariableIdAllocator
Id allocator for the variables.
bool entryIsPositive(const TableauEntry< T1, T2 > &_entry) const
std::vector< T2 > mInfeasibilityRow
std::map< Value< T1 >, Value< T1 > > compute_dVio(const std::vector< std::pair< Value< T1 >, Variable< T1, T2 > * > > &candidates, const Variable< T1, T2 > &nVar, bool positive)
Updated Method to computed dVio more efficienlty.
size_t getNumberOfEntries(Variable< T1, T2 > *_rowVar)
void printLearnedBound(const Variable< T1, T2 > &_var, const LearnedBound &_learnedBound, const std::string _init="", std::ostream &_out=std::cout) const
EntryID isSuitableConflictDetection(const Variable< T1, T2 > &_basicVar, bool _forIncreasingAssignment) const
Checks if the basic variable is pivotable.
EntryID isSuitable(const Variable< T1, T2 > &_basicVar, bool _forIncreasingAssignment) const
void update(bool _downwards, EntryID _pivotingElement, std::vector< Iterator > &_pivotingRowLeftSide, std::vector< Iterator > &_pivotingRowRightSide, bool _optimizing=false)
Updates the tableau according to the new values in the pivoting row containing the given pivoting ele...
Tableau(ModuleInput::iterator _defaultBoundPosition)
const carl::FastMap< carl::Variable, Variable< T1, T2 > * > & originalVars() const
void print(EntryID _pivotingElement=LAST_ENTRY_ID, std::ostream &_out=std::cout, const std::string _init="", bool _friendlyNames=true, bool _withZeroColumns=false) const
std::vector< std::vector< const Bound< T1, T2 > * > > getConflictsFrom(EntryID _rowEntry) const
std::pair< EntryID, bool > nextPivotingElementForOptimizing(const Variable< T1, T2 > &_objective)
std::pair< EntryID, bool > optimizeIndependentNonbasics(const Variable< T1, T2 > &_objective)
std::vector< TableauEntry< T1, T2 > > * mpEntries
const std::vector< Variable< T1, T2 > * > & rows() const
void removeBound(const FormulaT &_constraint)
void printHeap(std::ostream &_out=std::cout, int _maxEntryLength=30, const std::string _init="") const
std::list< std::list< std::pair< Variable< T1, T2 > *, T2 > > > mNonActiveBasics
Value< T1 > violationSum()
Method to compute the sum of derivations to the closest bounds.
Variable< T1, T2 > * newBasicVariable(const typename Poly::PolyType *_poly, bool _isInteger)
auto defaultBoundPosition() const
void activateBound(const Bound< T1, T2 > *_bound, const FormulaT &_formula)
Value< T1 > dViolationSum(const Variable< T1, T2 > *nVar, const Value< T1 > &update)
Computes the change in the violation sum when an the update value is added to the assignment of the n...
std::vector< Variable< T1, T2 > * > mColumns
carl::FastPointerMap< Variable< T1, T2 >, LearnedBound > mLearnedUpperBounds
bool usedBlandsRule()
Returns true, if the next pivoting element is selected by blands rule.
size_t unboundedVariables(const Variable< T1, T2 > &_var, size_t _stopCriterium=0) const
void deactivateBasicVar(Variable< T1, T2 > *_var)
void updateNonbasicVariable(EntryID _pivotingElement, Value< T1 > update)
Updates a nonbasic variable by the given assignment and triggers updates of depending basic variables...
size_t checkCorrectness() const
bool hasMultilineConflict()
std::pair< EntryID, bool > nextZeroPivotingElementForOptimizing(const Variable< T1, T2 > &_objective) const
std::vector< typename carl::FastPointerMap< Variable< T1, T2 >, LearnedBound >::iterator > & rNewLearnedBounds()
void setInfeasibilityRow()
Method to set the initital infeasibility row to avoid recomputation in every round.
void printEntry(EntryID _entry, std::ostream &_out=std::cout, int _maxEntryLength=20) const
std::pair< const Bound< T1, T2 > *, bool > newBound(const FormulaT &_constraint)
void printLearnedBounds(const std::string _init="", std::ostream &_out=std::cout) const
Variable< T1, T2 > * newNonbasicVariable(const typename Poly::PolyType *_poly, bool _isInteger)
carl::FastMap< FormulaT, std::vector< const Bound< T1, T2 > * > * > & rConstraintToBound()
std::vector< typename carl::FastPointerMap< Variable< T1, T2 >, LearnedBound >::iterator > mNewLearnedBounds
std::vector< const Bound< T1, T2 > * > getConflict(EntryID _rowEntry) const
std::pair< EntryID, bool > nextPivotingElement()
bool isConflicting() const
std::vector< T2 > getInfeasibilityRow()
Method to compute the infeasibility row to the current tableau.
carl::FastPointerMap< typename Poly::PolyType, Variable< T1, T2 > * > mSlackVars
bool entryIsNegative(const TableauEntry< T1, T2 > &_entry) const
std::size_t mFullCandidateSearch
Value< T1 > get_dVioSum()
Used as assertion-function to check the progress of the tableau.
size_t mMaxPivotsWithoutBlandsRule
void removeEntry(EntryID _entryID)
void deleteVariable(Variable< T1, T2 > *_variable, bool _optimizationVar=false)
void setSize(size_t _expectedHeight, size_t _expectedWidth, size_t _expectedNumberOfBounds)
void activateBasicVar(Variable< T1, T2 > *_var)
g
Variable< T1, T2 > * pivot(EntryID _pivotingElement, bool _optimizing=false)
EntryID newTableauEntry(const T2 &_content)
Variable< T1, T2 > * getVariable(const Poly &_lhs, T1 &_factor, T1 &_boundValue)
const Poly::PolyType * gomoryCut(const T2 &_ass, Variable< T1, T2 > *_rowVar)
Creates a constraint referring to Gomory Cuts, if possible.
carl::FastPointerMap< Variable< T1, T2 >, LearnedBound > & rLearnedLowerBounds()
std::list< std::list< std::pair< Variable< T1, T2 > *, T2 > > >::iterator positionInNonActives() const
const T2 & factor() const
static EntryID LAST_ENTRY_ID
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::Assignment< Rational > RationalAssignment
carl::MultivariatePolynomial< Rational > Poly
carl::Formulas< Poly > FormulasT
LearnedBound(const LearnedBound &)=delete
LearnedBound(LearnedBound &&_toMove)
LearnedBound(const Value< T1 > &_limit, const Bound< T1, T2 > *_newBound, typename Bound< T1, T2 >::BoundSet::const_iterator _nextWeakerBound, std::vector< const Bound< T1, T2 > * > &&_premise)
const Bound< T1, T2 > * newBound
std::vector< const Bound< T1, T2 > * > premise
Bound< T1, T2 >::BoundSet::const_iterator nextWeakerBound