예제 #1
0
파일: fs_task.py 프로젝트: ramonpereira/fs
def _init_data_structures(symbols, fluent_symbols):
    init, static_data = {}, {}
    for s in symbols.values():
        if util.is_external(s.name):
            continue

        var = init if s.name in fluent_symbols else static_data
        var[s.name] = static.instantiate_extension(s)

    return init, static_data
예제 #2
0
파일: fs_task.py 프로젝트: Wushaowei001/fs
def _init_data_structures(symbols, fluent_symbols):
    init, static_data = {}, {}
    for s in symbols.values():
        if util.is_external(s.name):
            continue

        var = init if s.name in fluent_symbols else static_data
        var[s.name] = static.instantiate_extension(s)

    return init, static_data
예제 #3
0
파일: fs_task.py 프로젝트: Wushaowei001/fs
def _check_symbol_in_initial_state(s, symbols):  # A small helper
    if s == 'total-cost':  # We ignore the 'total-cost' initial specification
        return False

    if util.is_external(s):
        raise RuntimeError("The extension of an external symbol cannot ne specified in the initial state")

    if s not in symbols:
        raise ParseException("Unknown symbol: '{}'".format(s))

    return True
예제 #4
0
파일: parser.py 프로젝트: ramonpereira/fs
    def process_predicative_expression(self, exp):
        assert isinstance(exp, (Atom, NegatedAtom))
        name = exp.predicate
        args = self.process_arguments(exp.args)

        if is_external(name) and (exp.negated or not self.is_static(name)):
            raise RuntimeError("External symbols cannot be fluent nor negated")

        if is_relational_operator(name):
            return RelationalExpression(exp.predicate, exp.negated, args)
        else:
            return PredicativeExpression(name, exp.negated, args, static=self.is_static(name))
예제 #5
0
파일: fs_task.py 프로젝트: ramonpereira/fs
def _check_symbol_in_initial_state(s, symbols):  # A small helper
    if s == 'total-cost':  # We ignore the 'total-cost' initial specification
        return False

    if util.is_external(s):
        raise RuntimeError(
            "The extension of an external symbol cannot ne specified in the initial state"
        )

    if s not in symbols:
        raise ParseException("Unknown symbol: '{}'".format(s))

    return True
예제 #6
0
def create_all_possible_state_variables(symbols, static_symbols, type_map):
    """ Creates an index with all possible state variables """
    variables = IndexDictionary()

    for symbol in symbols.values():
        name = symbol.name
        if is_external(
                name
        ) or name in static_symbols:  # The symbol won't yield any state variable
            continue
        instantiations = [type_map[t] for t in symbol.arguments]
        for instantiation in itertools.product(*instantiations):
            variables.add(Variable(symbol.name, instantiation))
    return variables
예제 #7
0
 def get_function_instantiations(self):
     return [tplManager.get('function_instantiation').substitute(name=symbol, accessor=symbol[1:])
             for symbol in self.index.static_symbols if is_external(symbol)]
예제 #8
0
 def requires_compilation(self):
     # The problem requires compilation iff there are external symbols involved.
     return len([s for s in self.index.static_symbols if is_external(s)])
예제 #9
0
 def get_function_instantiations(self):
     return [
         tplManager.get('function_instantiation').substitute(
             name=symbol, accessor=symbol[1:])
         for symbol in self.index.static_symbols if is_external(symbol)
     ]
예제 #10
0
 def requires_compilation(self):
     # The problem requires compilation iff there are external symbols involved.
     return len([s for s in self.index.static_symbols if is_external(s)])
예제 #11
0
파일: parser.py 프로젝트: ramonpereira/fs
 def check_declared(self, symbol):
     if not is_builtin_operator(symbol) and symbol not in self.index.all_symbols and not is_external(symbol):
         raise exceptions.UndeclaredSymbol("Undeclared symbol '{0}'".format(symbol))
예제 #12
0
파일: parser.py 프로젝트: ramonpereira/fs
 def is_static(self, symbol):
     return symbol in self.index.static_symbols or is_builtin_operator(symbol) or is_external(symbol)