dlvhex  2.5.0
AnswerSet Class Reference

Stores a set of atoms as in an Interpretation enhanced with additional information which is necessary for encoding answer sets (such as e.g. More...

#include <include/dlvhex2/AnswerSet.h>

Inheritance diagram for AnswerSet:
Collaboration diagram for AnswerSet:

Public Types

typedef boost::shared_ptr
< AnswerSet
Ptr
typedef boost::shared_ptr
< const AnswerSet
ConstPtr

Public Member Functions

void computeWeightVector ()
 Computes AnswerSet::weightVector by interpreting auxiliary atoms of type 'w' (see WeakConstraintPlugin).
std::vector< int > & getWeightVector ()
 Returns a reference to the current weight vector.
bool betterThan (std::vector< int > &cwv)
 Compares the weight vector of this answer set to that of another one.
bool strictlyBetterThan (std::vector< int > &cwv)
 Compares weight vector of this answer set to that of another one.
std::ostream & printWeightVector (std::ostream &o) const
 Prints the vector in dlv syntax.
 AnswerSet (RegistryPtr registry)
 Constructor.
 AnswerSet (InterpretationPtr interpretation)
 Constructor.
virtual ~AnswerSet ()
 Destructor.
virtual std::ostream & print (std::ostream &o) const
 Prints the answer set including its weight vector (if present).

Data Fields

InterpretationPtr interpretation
 Set of atoms in this answer set.
std::vector< int > weightVector
 Stores the weight of the answer set for each level, where levels with a greater index have a higher priority.

Detailed Description

Stores a set of atoms as in an Interpretation enhanced with additional information which is necessary for encoding answer sets (such as e.g.

its costs).

Definition at line 50 of file AnswerSet.h.


Member Typedef Documentation

typedef boost::shared_ptr<const AnswerSet> AnswerSet::ConstPtr

Definition at line 56 of file AnswerSet.h.

typedef boost::shared_ptr<AnswerSet> AnswerSet::Ptr

Definition at line 55 of file AnswerSet.h.


Constructor & Destructor Documentation

AnswerSet::AnswerSet ( RegistryPtr  registry) [inline]

Constructor.

Initializes the answer set with an empty interpretation.

Parameters:
registryRegistry used to interpret IDs.

Definition at line 109 of file AnswerSet.h.

References computeWeightVector().

AnswerSet::AnswerSet ( InterpretationPtr  interpretation) [inline]

Constructor.

Initializes the answer set with an existing interpretation.

Parameters:
interpretationExisting interpretation to form the answer set.

Definition at line 121 of file AnswerSet.h.

References computeWeightVector().

virtual AnswerSet::~AnswerSet ( ) [inline, virtual]

Destructor.

Definition at line 130 of file AnswerSet.h.


Member Function Documentation

bool AnswerSet::betterThan ( std::vector< int > &  cwv)

Compares the weight vector of this answer set to that of another one.

(<=)

If the maximal level where this vector has costs > 0 is greater then that of cwv, false is returned. Conversely, if the maximal level where vector has costs > 0 is greater then that of this vector, true is returned.

Otherwise the comparison starts at at the greatest common level with costs > 0. If the element in this weight vector is smaller than that of cwv, true is returned. If the element in this weight vector is greater than that of cwv, false is returned. If the elements are equal, the comparison is repeated with the next smaller level until a difference is found. If also level 0 does not yield a difference, true is returned as the vectors are of equal quality.

Parameters:
cwvOther weight vector.
Returns:
True if this weight vector is better than or of equal quality as cwv.

Definition at line 82 of file AnswerSet.cpp.

References strictlyBetterThan(), and weightVector.

Computes AnswerSet::weightVector by interpreting auxiliary atoms of type 'w' (see WeakConstraintPlugin).

Definition at line 43 of file AnswerSet.cpp.

References DLVHEX_BENCHMARK_REGISTER_AND_SCOPE, interpretation, Atom::tuple, and weightVector.

Referenced by AnswerSet().

std::vector< int > & AnswerSet::getWeightVector ( )

Returns a reference to the current weight vector.

Returns:
Weight vector.

Definition at line 76 of file AnswerSet.cpp.

References weightVector.

std::ostream & AnswerSet::print ( std::ostream &  o) const [virtual]

Prints the answer set including its weight vector (if present).

Parameters:
oStream to print.
Returns:
o.

Definition at line 134 of file AnswerSet.cpp.

References DLVHEX_BENCHMARK_REGISTER_AND_SCOPE, interpretation, printWeightVector(), and weightVector.

std::ostream & AnswerSet::printWeightVector ( std::ostream &  o) const

Prints the vector in dlv syntax.

Prints the vector as a comma-separated sequence (encosed in angular brackets) of elements [c:l], where c is the cost value at level l.

Parameters:
oStream to print.
Returns:
o.

Definition at line 115 of file AnswerSet.cpp.

References DLVHEX_BENCHMARK_REGISTER_AND_SCOPE, and weightVector.

Referenced by print().

bool AnswerSet::strictlyBetterThan ( std::vector< int > &  cwv)

Compares weight vector of this answer set to that of another one.

(<)

See betterThan.

Definition at line 88 of file AnswerSet.cpp.

References DLVHEX_BENCHMARK_REGISTER_AND_SCOPE, and weightVector.

Referenced by betterThan().


Field Documentation

Set of atoms in this answer set.

Definition at line 59 of file AnswerSet.h.

Referenced by computeWeightVector(), and print().

std::vector<int> AnswerSet::weightVector

Stores the weight of the answer set for each level, where levels with a greater index have a higher priority.

Definition at line 61 of file AnswerSet.h.

Referenced by betterThan(), computeWeightVector(), getWeightVector(), print(), printWeightVector(), and strictlyBetterThan().


The documentation for this class was generated from the following files: