コード例 #1
0
def extract_static_facts(plan, certificate, initial_confs):
    # TODO: use certificate instead
    # TODO: only keep objects used on the plan
    #static_facts = []
    static_facts = [
        f for f in certificate.all_facts
        if get_prefix(get_function(f)) in ['distance', 'trajtrajcollision']
    ]
    for name, actions in partition_plan(plan).items():
        last_element = None
        last_conf = initial_confs[name]
        for i, action in enumerate(actions):
            if action.name == 'print':
                r, n1, e, n2, q1, q2, t = action.args
                static_facts.extend([
                    ('PrintAction', ) + action.args,
                    ('Assigned', r, e),
                    ('Conf', r, q1),
                    ('Conf', r, q2),
                    ('Traj', r, t),
                    ('CTraj', r, t),
                    # (Start ?r ?n1 ?e ?q1) (End ?r ?e ?n2 ?q2)
                    ('Transition', r, q2, last_conf),
                ])
                if last_element is not None:
                    static_facts.append(('Order', e, last_element))
                last_element = e
                last_conf = q1
                # TODO: save collision information
            else:
                raise NotImplementedError(action.name)
        static_facts.extend([
            ('Transition', name, initial_confs[name], last_conf),
        ])
    return static_facts
コード例 #2
0
ファイル: serialized.py プロジェクト: syc7446/pddlstream
def partition_facts(domain, facts):
    fluents = get_fluents(domain)
    static_facts = []
    fluent_facts = []
    for fact in facts:
        if get_prefix(get_function(fact)).lower() in fluents:
            fluent_facts.append(fact)
        else:
            static_facts.append(fact)
    return static_facts, fluent_facts