Generic class for a symbolic state. More...
#include <symbolicState.h>
Classes | |
class | OStreamMode |
Public Types | |
typedef multimap< string, string >::const_iterator | TypedObjectConstIterator |
typedef multimap< string, string >::iterator | TypedObjectIterator |
Public Member Functions | |
void | addObject (string obj, string type) |
Add an object to the list of objects. | |
void | addSuperType (string type, string supertype) |
e.g. door_location - location | |
bool | booleanEquals (const SymbolicState &other) const |
Determine if the boolean predicates in this state are the same as in other and vice-versa. | |
void | clear () |
bool | equals (const SymbolicState &other) const |
Determine if all fluents in this state are the same as in other and vice-versa. | |
const multimap< string, string > & | getTypedObjects () const |
Get a map from type -> objects of that type. | |
bool | hasBooleanPredicate (const Predicate &p, bool *value) const |
Determine if this state has the given predicate. | |
bool | hasNumericalFluent (const Predicate &p, double *value) const |
bool | hasObjectFluent (const Predicate &p, string *value) const |
bool | isFulfilledBy (const SymbolicState &other) const |
Does state fulfill this state? | |
bool | numericalEquals (const SymbolicState &other) const |
Determine if the numerical fluents in this state are the same as in other and vice-versa. | |
bool | objectFluentsEquals (const SymbolicState &other) const |
Determine if the object fluents in this state are the same as in other and vice-versa. | |
void | printSuperTypes () const |
Output the super types map. | |
void | removeObject (string obj, bool removePredicates=true) |
Remove an object from the state. | |
void | setAllBooleanPredicates (string name, bool value) |
Set all boolean predicates with name to value. | |
void | setAllNumericalFluents (string name, double value) |
Set all numerical fluents with name to value. | |
void | setAllObjectFluents (string name, string value) |
Set all object fluents with name to value. | |
void | setBooleanPredicate (string name, vector< string > parameters, bool value) |
Set a boolean predicate in the state. If it does not exist it will be created. | |
void | setBooleanPredicate (string name, string parameters, bool value) |
Set a boolean predicate using handcoded parameters. | |
void | setForEachGoalStatement (string objectType, string predicateName, bool value) |
void | setNumericalFluent (string name, vector< string > parameters, double value) |
Set a numerical fluent. If it does not exist it will be created. | |
void | setNumericalFluent (string name, string parameters, double value) |
Set a numerical fluent using handcoded parameters. | |
void | setObjectFluent (string name, vector< string > parameters, string value) |
Set a object fluent. If it does not exist it will be created. | |
void | setObjectFluent (string name, string parameters, string value) |
Set a object fluent using handcoded parameters. | |
SymbolicState () | |
virtual void | toPDDLGoal (std::ostream &ss) const |
Output a goal condition of all predicates. | |
virtual void | toPDDLProblem (std::ostream &ss) const |
Give a PDDL notation as required for writing a PDDL problem. | |
virtual | ~SymbolicState () |
Protected Types | |
typedef map< Predicate, bool > ::value_type | BooleanPredicateEntry |
typedef multimap< string, pair < string, bool > > | ForEachGoalStatements |
typedef map< Predicate, double > ::value_type | NumericalFluentEntry |
typedef map< Predicate, string > ::value_type | ObjectFluentEntry |
Protected Member Functions | |
vector< string > | buildParameterList (string params) const |
split string at " " | |
bool | isMostSpecificType (string obj, string type) const |
Protected Attributes | |
map< Predicate, bool > | _booleanPredicates |
ForEachGoalStatements | _forEachGoalStatements |
map< Predicate, double > | _numericalFluents |
map< Predicate, string > | _objectFluents |
multimap< string, string > | _superTypes |
Type -> Supertypes (including type) | |
multimap< string, string > | _typedObjects |
Map from type to objects of this same type. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const SymbolicState &ss) |
Generic class for a symbolic state.
A symbolic state represents grounded boolean predicates, numeric and object fluents.
The contents should be filled by a robot specific implementation.
Definition at line 50 of file symbolicState.h.
typedef map<Predicate, bool>::value_type SymbolicState::BooleanPredicateEntry [protected] |
Definition at line 197 of file symbolicState.h.
typedef multimap<string, pair<string, bool> > SymbolicState::ForEachGoalStatements [protected] |
Definition at line 194 of file symbolicState.h.
typedef map<Predicate, double>::value_type SymbolicState::NumericalFluentEntry [protected] |
Definition at line 198 of file symbolicState.h.
typedef map<Predicate, string>::value_type SymbolicState::ObjectFluentEntry [protected] |
Definition at line 199 of file symbolicState.h.
typedef multimap<string,string>::const_iterator SymbolicState::TypedObjectConstIterator |
Definition at line 63 of file symbolicState.h.
typedef multimap<string,string>::iterator SymbolicState::TypedObjectIterator |
Definition at line 62 of file symbolicState.h.
Definition at line 82 of file symbolicState.cpp.
SymbolicState::~SymbolicState | ( | ) | [virtual] |
Definition at line 86 of file symbolicState.cpp.
void SymbolicState::addObject | ( | string | obj, |
string | type | ||
) |
Add an object to the list of objects.
The object will be entered for type and all its supertypes. Thus all super types have to be defined by addSuperType before.
Definition at line 90 of file symbolicState.cpp.
void SymbolicState::addSuperType | ( | string | type, |
string | supertype | ||
) |
e.g. door_location - location
Definition at line 129 of file symbolicState.cpp.
bool SymbolicState::booleanEquals | ( | const SymbolicState & | other | ) | const |
Determine if the boolean predicates in this state are the same as in other and vice-versa.
Definition at line 444 of file symbolicState.cpp.
vector< string > SymbolicState::buildParameterList | ( | string | params | ) | const [protected] |
split string at " "
Definition at line 598 of file symbolicState.cpp.
void SymbolicState::clear | ( | ) | [inline] |
Definition at line 65 of file symbolicState.h.
bool SymbolicState::equals | ( | const SymbolicState & | other | ) | const |
Determine if all fluents in this state are the same as in other and vice-versa.
Definition at line 518 of file symbolicState.cpp.
const multimap<string, string>& SymbolicState::getTypedObjects | ( | ) | const [inline] |
Get a map from type -> objects of that type.
Definition at line 94 of file symbolicState.h.
bool SymbolicState::hasBooleanPredicate | ( | const Predicate & | p, |
bool * | value | ||
) | const |
Determine if this state has the given predicate.
[out] | value,if | != NULL and the hasBooleanPredicate is true, the value will be filled. |
Definition at line 357 of file symbolicState.cpp.
bool SymbolicState::hasNumericalFluent | ( | const Predicate & | p, |
double * | value | ||
) | const |
Definition at line 367 of file symbolicState.cpp.
bool SymbolicState::hasObjectFluent | ( | const Predicate & | p, |
string * | value | ||
) | const |
Definition at line 377 of file symbolicState.cpp.
bool SymbolicState::isFulfilledBy | ( | const SymbolicState & | other | ) | const |
Does state fulfill this state?
Check if the other state fulfills this (partial) state, i.e. for each predicate in this state, there is a corresponding one in the other state and it has the same truth value. Predicates in the other state that do not exist in this state are ignored. Numeric fluents need to be the same up to double_equals.
Commonly this is a goal state and the other state is the current state.
Definition at line 388 of file symbolicState.cpp.
bool SymbolicState::isMostSpecificType | ( | string | obj, |
string | type | ||
) | const [protected] |
doorl1 - door_location -> true doorl1 - location -> false
Definition at line 176 of file symbolicState.cpp.
bool SymbolicState::numericalEquals | ( | const SymbolicState & | other | ) | const |
Determine if the numerical fluents in this state are the same as in other and vice-versa.
Definition at line 470 of file symbolicState.cpp.
bool SymbolicState::objectFluentsEquals | ( | const SymbolicState & | other | ) | const |
Determine if the object fluents in this state are the same as in other and vice-versa.
Definition at line 494 of file symbolicState.cpp.
void SymbolicState::printSuperTypes | ( | ) | const |
Output the super types map.
Definition at line 203 of file symbolicState.cpp.
void SymbolicState::removeObject | ( | string | obj, |
bool | removePredicates = true |
||
) |
Remove an object from the state.
[in] | removePredicates | if true, all predicates/fluents that contain obj will also be removed. |
Definition at line 227 of file symbolicState.cpp.
void SymbolicState::setAllBooleanPredicates | ( | string | name, |
bool | value | ||
) |
Set all boolean predicates with name to value.
Definition at line 298 of file symbolicState.cpp.
void SymbolicState::setAllNumericalFluents | ( | string | name, |
double | value | ||
) |
Set all numerical fluents with name to value.
Definition at line 321 of file symbolicState.cpp.
void SymbolicState::setAllObjectFluents | ( | string | name, |
string | value | ||
) |
Set all object fluents with name to value.
Definition at line 344 of file symbolicState.cpp.
void SymbolicState::setBooleanPredicate | ( | string | name, |
vector< string > | parameters, | ||
bool | value | ||
) |
Set a boolean predicate in the state. If it does not exist it will be created.
Definition at line 283 of file symbolicState.cpp.
void SymbolicState::setBooleanPredicate | ( | string | name, |
string | parameters, | ||
bool | value | ||
) |
Set a boolean predicate using handcoded parameters.
The parameters string is a space-separated string of the form: "robot0 x1 test" and will be parsed into the single parameters.
Definition at line 292 of file symbolicState.cpp.
void SymbolicState::setForEachGoalStatement | ( | string | objectType, |
string | predicateName, | ||
bool | value | ||
) |
Create a forall statement for a object type with the specified predicate and value. Useful for goal conditions.
Definition at line 352 of file symbolicState.cpp.
void SymbolicState::setNumericalFluent | ( | string | name, |
vector< string > | parameters, | ||
double | value | ||
) |
Set a numerical fluent. If it does not exist it will be created.
Definition at line 306 of file symbolicState.cpp.
void SymbolicState::setNumericalFluent | ( | string | name, |
string | parameters, | ||
double | value | ||
) |
Set a numerical fluent using handcoded parameters.
Definition at line 315 of file symbolicState.cpp.
void SymbolicState::setObjectFluent | ( | string | name, |
vector< string > | parameters, | ||
string | value | ||
) |
Set a object fluent. If it does not exist it will be created.
Definition at line 329 of file symbolicState.cpp.
void SymbolicState::setObjectFluent | ( | string | name, |
string | parameters, | ||
string | value | ||
) |
Set a object fluent using handcoded parameters.
Definition at line 338 of file symbolicState.cpp.
void SymbolicState::toPDDLGoal | ( | std::ostream & | ss | ) | const [virtual] |
Output a goal condition of all predicates.
Definition at line 558 of file symbolicState.cpp.
void SymbolicState::toPDDLProblem | ( | std::ostream & | ss | ) | const [virtual] |
Give a PDDL notation as required for writing a PDDL problem.
Definition at line 524 of file symbolicState.cpp.
std::ostream& operator<< | ( | std::ostream & | os, |
const SymbolicState & | ss | ||
) | [friend] |
Definition at line 648 of file symbolicState.cpp.
map<Predicate, bool> SymbolicState::_booleanPredicates [protected] |
Definition at line 190 of file symbolicState.h.
Definition at line 195 of file symbolicState.h.
map<Predicate, double> SymbolicState::_numericalFluents [protected] |
Definition at line 191 of file symbolicState.h.
map<Predicate, string> SymbolicState::_objectFluents [protected] |
Definition at line 192 of file symbolicState.h.
multimap<string, string> SymbolicState::_superTypes [protected] |
Type -> Supertypes (including type)
Definition at line 186 of file symbolicState.h.
multimap<string, string> SymbolicState::_typedObjects [protected] |
Map from type to objects of this same type.
should also contain entries for all supertypes, e.g.: l1_door1 has an entry for door_location and for location (given addSuperType was inserted)
Definition at line 184 of file symbolicState.h.