예제 #1
0
    def dump(self, index, binding_unit):
        if is_int(self.symbol):  # We have an integer constant
            return dict(type='constant',
                        symbol=self.symbol,
                        value=int(self.symbol),
                        type_id="int_t",
                        fstype="int")

        elif is_float(self.symbol):  # We have a float constant
            return dict(type='constant',
                        symbol=self.symbol,
                        value=float(self.symbol),
                        type_id="float_t",
                        fstype="number")
        elif self.symbol in ("true", "false"):  # We have a bool constant
            return dict(type='constant',
                        symbol=self.symbol,
                        value=1 if self.symbol == "true" else 0,
                        type_id="bool_t",
                        fstype="bool")

        elif self.symbol in ("true", "false"):  # We have a bool constant
            return dict(type='constant',
                        symbol=self.symbol,
                        value=1 if self.symbol == "true" else 0,
                        type_id="bool_t",
                        fstype="bool")

        else:  # We have a logical constant
            return dict(type='constant',
                        symbol=self.symbol,
                        value=index.objects.get_index(self.symbol),
                        type_id="object_t",
                        fstype=index.object_types[self.symbol])
예제 #2
0
    def _extract_initial_atom_names_and_arguments(self, fd_initial_state):
        names = []
        for atom in fd_initial_state:
            if isinstance(atom, pddl.Assign):
                name = atom.fluent.symbol
                if _check_symbol_in_initial_state(name, self.symbols):
                    args = tuple(
                        int(a) if utils.is_int(a) else a
                        for a in atom.fluent.args)
                    value = self.parse_value(atom.expression)
                    names.append((name, args, value))

            elif isinstance(atom, pddl.Atom):
                if atom.negated:
                    raise RuntimeError(
                        "No negations allowed in the initialization of atoms")

                name = atom.predicate
                if _check_symbol_in_initial_state(name, self.symbols):
                    names.append((name, atom.args, None))

            else:
                raise RuntimeError(
                    "Unrecognized type of atom '{}'".format(atom))

        return names
예제 #3
0
    def dump(self, index, binding_unit):
        if is_int(self.symbol):  # We have a numeric constant
            return dict(type='int_constant',
                        value=int(self.symbol),
                        typename="int")

        else:  # We have a logical constant
            return dict(type='constant',
                        value=index.objects.get_index(self.symbol),
                        typename=index.object_types[self.symbol])
예제 #4
0
 def __init__(self, symbol, args):
     self.symbol = symbol
     self.args = []
     for a in args:
         if is_int(a):
             self.args.append(a)
         elif is_float(a):
             self.args.append(a)
         elif isinstance(a, TypedObject):
             self.args.append(a.name)
         else:
             self.args.append(a)
     self.args = tuple(self.args)
 def dump_state_variable(self, var):
     head = self.index.symbol_index[var.symbol]
     constants = [arg if utils.is_int(arg) else self.index.objects.get_index(arg) for arg in var.args]
     return [head, constants]
예제 #6
0
 def __init__(self, symbol, args):
     self.symbol = symbol
     self.args = tuple(int(a) if is_int(a) else a for a in args)