atom_icaps2014.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 from .atom import Atom
00004 
00005 class AtomICAPS2014(Atom):
00006 
00007     ACTION_NAMES = ["askploc", "greet", "collectmail", "gothrough", "opendoor",
00008                     "approach"]
00009     FLUENT_NAMES = ["inside", "knowinside", "open", "visiting", "mailcollected",
00010                     "facing", "beside", "loc"]
00011     TERM_NAMES = ["hasdoor", "acc", "passto", "knows"]
00012 
00013     def __init__(self, name, value=None, time=None, negated=False):
00014         super(AtomICAPS2014, self).__init__(name, value, time, negated)
00015 
00016         if self.type == Atom.ACTION or self.type == Atom.FLUENT: 
00017             if self.name in AtomICAPS2014.ACTION_NAMES:
00018                 self.type = Atom.ACTION
00019                 return
00020             if self.name in AtomICAPS2014.FLUENT_NAMES:
00021                 self.type = Atom.FLUENT
00022                 return
00023         else:
00024             return
00025 
00026         raise ValueError("Malformed atom - Unknown action/fluent: %s"%str(name))
00027 
00028     def conflicts_with(self, other):
00029         """
00030           Test for hard negation conflict and uniqueness constraints only.
00031         """
00032 
00033         if super(AtomICAPS2014, self).conflicts_with(other):
00034             return True
00035 
00036         # Check for uniqueness constraints
00037         if (self.name == "loc" and other.name == "loc" or \
00038             self.name == "facing" and other.name == "facing" or \
00039             self.name == "beside" and other.name == "beside") and \
00040            self.value != other.value and \
00041            not self.negated and not other.negated:
00042             return True
00043 
00044         # Check for uniqueness constraint for inside/knowinside
00045         # if the person is same, but the location is different and both 
00046         # fluents are not negated
00047         inside_names = ["inside", "knowinside"]
00048         if self.name in inside_names and other.name in inside_names and \
00049            self.value.value[0] == other.value.value[0] and \
00050            self.value.value[1] != other.value.value[1] and \
00051            not self.negated and not other.negated:
00052             return True
00053 
00054         return False
00055 


bwi_planning_icaps14
Author(s): Piyush Khandelwal , Fangkai Yang
autogenerated on Wed Aug 26 2015 10:55:00