13 #include <carl-common/memory/IDPool.h>
17 #ifdef SMTRAT_DEVOPTION_Statistics
18 #include "VSStatistics.h"
21 #define VS_STATE_DEBUG_METHODS
42 if( n1.first > n2.first )
44 else if( n1.first == n2.first )
47 return n1.second.first > n2.second.first;
50 if( n1.second.second < n2.second.second )
52 else if( n1.second.second == n2.second.second )
53 return n1.second.first > n2.second.first;
62 typedef std::map<UnsignedTriple, vs::State*, unsignedTripleCmp>
ValuationMap;
70 typedef carl::FastPointerMapB<Substitution,ConditionSetSetSet>
ConflictSets;
170 std::vector<std::pair<carl::Variable,std::multiset<double>>>
mRealVarVals;
172 std::vector<std::pair<carl::Variable,std::multiset<double>>>
mIntVarVals;
176 #ifdef SMTRAT_DEVOPTION_Statistics
178 smtrat::VSStatistics* mpStatistics;
188 State( carl::IDPool* _conditionIdAllocator,
bool _withVariableBounds );
197 State(
State*
const _father,
const Substitution& _substitution, carl::IDPool* _conditionIdAllocator,
bool _withVariableBounds );
702 #ifdef SMTRAT_DEVOPTION_Statistics
703 void setStatistics( smtrat::VSStatistics* _stats )
705 assert( mpStatistics ==
nullptr );
706 mpStatistics = _stats;
709 carl::uint numberOfUnusedConditions()
const
798 void variables( carl::Variables& _variables )
const;
838 bool bestCondition(
const Condition*& _bestCondition,
size_t _numberOfAllVariables,
bool _preferEquation );
870 void setIndex(
const carl::Variable& _index );
907 void addSubstitutionResults( std::vector< DisjunctionOfConditionConjunctions >&& _disjunctionsOfCondConj );
1020 std::vector<State*>
addChild(
const Substitution& _substitution );
1042 void passConflictToFather(
bool _checkConflictForSideCondition,
bool _useBackjumping =
true,
bool _includeInconsistentTestCandidates =
false );
1068 std::vector< smtrat::DoubleInterval >
solutionSpace( carl::PointerSet<Condition>& _conflictReason )
const;
1080 #ifdef VS_STATE_DEBUG_METHODS
1088 void print(
const std::string _initiation =
"***", std::ostream& _out = std::cout )
const;
1095 void printAlone(
const std::string =
"***", std::ostream& _out = std::cout )
const;
1102 void printConditions(
const std::string _initiation =
"***", std::ostream& _out = std::cout,
bool =
false )
const;
1130 void printConflictSets(
const std::string _initiation =
"***", std::ostream& _out = std::cout )
const;
Class to manage the bounds of a variable.
void printSubstitutionResults(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the substitution results of this state.
const std::list< State * > & children() const
bool hasSubstitutionResults() const
const Substitution * pSubstitution() const
ConditionList & rConditions()
bool refreshConditions(ValuationMap &_ranking)
Determines the condition vector corresponding to the current combination of the conjunctions of condi...
ConflictSets * mpConflictSets
Stores for each already considered and failed test candidate all conflicts which have been found for ...
bool hasFurtherUncheckedTestCandidates() const
Checks whether there exist more than one test candidate, which has still not been checked.
State(const State &)=delete
size_t currentRangeSize() const
const smtrat::Rational & minIntTestCandidate() const
void printSubstitutionResultCombination(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the combination of substitution results used in this state.
void resetCurrentRangeSize()
void deleteOriginsFromSubstitutionResults(carl::PointerSet< Condition > &_originsToDelete)
Deletes everything originated by the given conditions in the substitution results of this state.
SubResultCombination * mpSubResultCombination
The currently considered combination of conjunctions of constraints in the substitution result vector...
bool mMarkedAsDeleted
A flag indicating whether this state has already marked as deleted, which means that there is no need...
size_t mID
A unique id identifying this state.
smtrat::Rational mMinIntTestCanidate
bool mInconsistent
A flag that indicates whether this state is already inconsistent.
bool hasNoninvolvedCondition() const
Checks whether a condition exists, which was not involved in an elimination step.
size_t mValuation
A heuristically determined value stating the expected difficulty of this state's considered condition...
smtrat::vb::VariableBounds< const Condition * > VariableBoundsCond
bool mSubResultsSimplified
A flag indicating whether the substitution results this state are simplified.
bool mHasRecentlyAddedConditions
A flag that indicates whether this state has conditions in its considered list of conditions,...
unsigned treeDepth() const
smtrat::Rational mMaxIntTestCanidate
bool mHasChildrenToInsert
A flag indicating whether there are states that are children of this state and must be still consider...
std::list< State * > & rChildren()
VariableBoundsCond & rVariableBounds()
void printConflictSets(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the conflict sets of this state.
void variables(carl::Variables &_variables) const
Finds the variables, which occur in this state.
const SubResultCombination & subResultCombination() const
void updateBackendCallValuation()
Valuates the state's currently considered conditions according to a backend call.
bool hasChildWithID() const
Checks whether a child exists, which has no ID (!=0).
bool hasInfinityChild() const
void setIndex(const carl::Variable &_index)
Sets the index of this state.
State * mpFather
The father state of this state.
std::vector< size_t > mBestVarVals
std::vector< std::pair< unsigned, unsigned > > SubResultCombination
SubstitutionResults * mpSubstitutionResults
The vector storing the substitution results, that is for each application of the substitution in this...
bool hasLocalConflict()
Checks whether the currently considered conditions, which have been considered for test candidate con...
bool unfinishedAncestor(State *&_unfinAnt)
Determines (if it exists) a ancestor node, which is unfinished, that is it has still substitution res...
void setInfinityChild(State *_state)
static void removeStatesFromRanking(const State &toRemove, ValuationMap &_ranking)
Type mType
The type of this state, which states whether this state has still a substitution to apply or either t...
bool mTryToRefreshIndex
A flag indicating whether the index (the variable to eliminate in this state) should be reconsidered ...
void simplify(ValuationMap &_ranking)
Cleans up all conditions in this state according to comparison between the corresponding constraints.
carl::PointerSet< Condition > & rTooHighDegreeConditions()
bool getNextIntTestCandidate(smtrat::Rational &_nextIntTestCandidate, size_t _maxIntRange)
bool & rTakeSubResultCombAgain()
SubResultCombination & rSubResultCombination()
bool mTakeSubResultCombAgain
A flag indicating whether to take the current combination of substitution results once again.
bool hasSubResultsCombination() const
bool nextSubResultCombination()
If the state contains a substitution result, which is a conjunction of disjunctions of conjunctions o...
carl::Variable::Arg index() const
void worstConstraintValuation(const std::vector< std::pair< carl::Variable, std::multiset< double >>> &_varVals)
bool conditionsSimplified() const
const ConflictSets & conflictSets() const
ConditionList getCurrentSubresultCombination() const
Gets the current substitution result combination as condition vector.
bool hasOnlyInconsistentChildren() const
Checks whether a child exists, which is not yet marked as inconsistent.
const smtrat::Rational & maxIntTestCandidate() const
const VariableBoundsCond & variableBounds() const
void printAlone(const std::string="***", std::ostream &_out=std::cout) const
Prints the conditions, the substitution and the substitution results of this state.
std::vector< std::pair< carl::Variable, std::multiset< double > > > mRealVarVals
void initConditionFlags()
Sets all flags of the conditions to true, if it contains the variable given by the states index.
bool & rMarkedAsDeleted()
std::vector< std::pair< ConditionList, bool > > SubstitutionResult
bool extendSubResultCombination()
Extends the currently considered combination of conjunctions in the substitution results.
bool & rCannotBeSolvedLazy()
unsigned numberOfNodes() const
Determines the number of nodes in the tree with this state as root.
std::vector< SubstitutionResult > SubstitutionResults
State(carl::IDPool *_conditionIdAllocator, bool _withVariableBounds)
Constructs an empty state (no conditions yet) being the root (hence neither a substitution) of the st...
carl::IDPool * mpConditionIdAllocator
bool takeSubResultCombAgain() const
void bestConstraintValuation(const std::vector< std::pair< carl::Variable, std::multiset< double >>> &_varVals)
const Substitution & substitution() const
void deleteConditions(carl::PointerSet< Condition > &_conditionsToDelete, ValuationMap &_ranking)
Delete everything originated by the given conditions from the entire subtree with this state as root.
void resetCannotBeSolvedLazyFlags()
bool markedAsDeleted() const
void deleteOriginsFromConflictSets(carl::PointerSet< Condition > &_originsToDelete, bool _originsAreCurrentConditions)
Deletes everything originated by the given conditions in the conflict sets of this state.
bool updateIntTestCandidates()
carl::FastPointerMapB< Substitution, ConditionSetSetSet > ConflictSets
static size_t coveringSet(const ConditionSetSetSet &_conflictSets, carl::PointerSet< Condition > &_minCovSet, unsigned _currentTreeDepth)
Finds a covering set of a vector of sets of sets due to some heuristics.
std::vector< State * > addChild(const Substitution &_substitution)
Adds a state as child to this state with the given substitution.
void resetConflictSets()
Clears the conflict sets.
bool subResultsSimplified() const
ConditionList * mpConditions
The currently considered conditions of this state, for which the satisfiability must be checked.
void printConditions(const std::string _initiation="***", std::ostream &_out=std::cout, bool=false) const
Prints the conditions of this state.
const State & father() const
bool isInconsistent() const
size_t getNumberOfCurrentSubresultCombination() const
void updateValuation(bool _lazy)
Updates the valuation of this state.
const Condition * pOriginalCondition() const
bool bestCondition(const Condition *&_bestCondition, size_t _numberOfAllVariables, bool _preferEquation)
Determines the most adequate condition and in it the most adequate variable in the state to generate ...
bool containsState(const State *_state) const
std::vector< smtrat::DoubleInterval > solutionSpace(carl::PointerSet< Condition > &_conflictReason) const
Determines the solution space of the test candidate of this state regarding to the variable bounds of...
bool & rHasRecentlyAddedConditions()
size_t backendCallValuation() const
Substitution & rSubstitution()
carl::Variable mIndex
The variable which is going to be eliminated from this state's considered conditions.
SubstitutionResults & rSubstitutionResults()
void print(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the conditions, the substitution and the substitution results of this state and all its childr...
void resetInfinityChild(const State *_state)
void addConflictSet(const Substitution *_substitution, ConditionSetSet &&_condSetSet)
Adds a conflict set to the map of substitutions to conflict sets.
void addCondition(const smtrat::ConstraintT &_constraint, const carl::PointerSet< Condition > &_originalConditions, size_t _valutation, bool _recentlyAdded, ValuationMap &_ranking)
Adds a constraint to the conditions of this state.
Substitution * mpSubstitution
The substitution this state considers. Note that it is NULL if this state is the root.
void addSubstitutionResults(std::vector< DisjunctionOfConditionConjunctions > &&_disjunctionsOfCondConj)
Adds the given substitution results to this state.
bool tryToRefreshIndex() const
void setOriginalCondition(const Condition *_pOCondition)
Sets the pointer of the original condition of this state to the given pointer to a condition.
bool checkTestCandidatesForBounds()
Checks whether the test candidate of this state is valid against the variable intervals in the father...
bool occursInEquation(const carl::Variable &) const
Checks whether the given variable occurs in a equation.
bool updateOCondsOfSubstitutions(const Substitution &_substitution, std::vector< State * > &_reactivatedStates)
Updates the original conditions of substitutions having the same test candidate as the given.
carl::PointerSet< Condition > * mpTooHighDegreeConditions
The conditions of this state, which cannot be solved by the virtual substitution.
void passConflictToFather(bool _checkConflictForSideCondition, bool _useBackjumping=true, bool _includeInconsistentTestCandidates=false)
Passes the original conditions of the covering set of the conflicts of this state to its father.
const Condition * mpOriginalCondition
If the test candidate considered by this state stems from a condition for which it is enough to consi...
void averageConstraintValuation(const std::vector< std::pair< carl::Variable, std::multiset< double >>> &_varVals)
bool substitutionApplicable() const
Checks if a substitution can be applied.
bool mConditionsSimplified
A flag indicating whether the conditions this state considers are simplified.
bool mTestCandidateCheckedForBounds
A flag indicating whether the test candidate contained by this state has already been check for the b...
void addConflicts(const Substitution *_substitution, ConditionSetSet &&_condSetSet)
Adds all conflicts to all sets of the conflict set of the given substitution.
const SubstitutionResults & substitutionResults() const
std::list< State * > * mpChildren
The children states of this state.
void deleteOriginsFromChildren(carl::PointerSet< Condition > &_originsToDelete, ValuationMap &_ranking)
Deletes everything originated by the given conditions in the children of this state.
int deleteOrigins(carl::PointerSet< Condition > &_originsToDelete, ValuationMap &_ranking)
Removes everything in this state originated by the given vector of conditions.
bool hasChildrenToInsert() const
bool & rSubResultsSimplified()
bool checkSubresultCombinations() const
This is just for debug purpose.
ConditionList::iterator constraintExists(const smtrat::ConstraintT &_constraint)
Checks if the given constraint already exists as condition in the state.
bool initIndex(const carl::Variables &_allVariables, const smtrat::VariableValuationStrategy &_vvstrat, bool _preferEquation, bool _tryDifferentVarOrder=false, bool _useFixedVariableOrder=false)
Sets, if it has not already happened, the index of the state to the name of the most adequate variabl...
size_t mBackendCallValuation
A heuristically determined value stating the expected difficulty of this state's considered condition...
const Condition & originalCondition() const
bool hasRootsInVariableBounds(const Condition *_condition, bool _useSturmSequence)
Checks whether there are no zeros for the left-hand side of the constraint of the given condition.
void printSubstitutionResultCombinationAsNumbers(const std::string _initiation="***", std::ostream &_out=std::cout) const
Prints the combination of substitution results, expressed in numbers, used in this state.
bool hasRecentlyAddedConditions() const
const ConditionList & conditions() const
ConflictSets & rConflictSets()
@ TEST_CANDIDATE_TO_GENERATE
const carl::PointerSet< Condition > & tooHighDegreeConditions() const
bool cannotBeSolved(bool _lazy) const
bool mCannotBeSolved
A flag indicating whether this state has been progressed until a point where a condition must be invo...
bool allTestCandidatesInvalidated(const Condition *_condition) const
bool & rHasChildrenToInsert()
VariableBoundsCond * mpVariableBounds
A pointer to an object which manages and stores the bounds on the variables occurring in this state.
std::vector< std::pair< carl::Variable, std::multiset< double > > > mIntVarVals
std::pair< size_t, std::pair< size_t, size_t > > UnsignedTriple
std::set< ConditionSetSet > ConditionSetSetSet
std::pair< UnsignedTriple, vs::State * > ValStatePair
std::list< const Condition * > ConditionList
std::vector< ConditionList > DisjunctionOfConditionConjunctions
std::set< carl::PointerSet< Condition > > ConditionSetSet
std::map< UnsignedTriple, vs::State *, unsignedTripleCmp > ValuationMap
Class to create the formulas for axioms.
VariableValuationStrategy
carl::Constraint< Poly > ConstraintT
bool operator()(UnsignedTriple n1, UnsignedTriple n2) const