def parse_constraint(optimizer, lisp_list): value_from_attribute = parse_lisp_list(lisp_list) assert set(value_from_attribute) <= {':constraint', ':necessary', ':fluents'} return ConstraintStream(optimizer, value_from_attribute[':constraint'], list_from_conjunction(value_from_attribute[':necessary']), value_from_attribute.get(':fluents', []))
def parse_stream(lisp_list, stream_map, stream_info): value_from_attribute = parse_lisp_list(lisp_list) assert set(value_from_attribute) <= { ':stream', ':wild-stream', ':inputs', ':domain', ':fluents', ':outputs', ':certified' } is_wild = (':wild-stream' in value_from_attribute) name = value_from_attribute[ ':wild-stream'] if is_wild else value_from_attribute[':stream'] domain = value_from_attribute.get(':domain', None) # TODO: dnf_from_positive_formula(value_from_attribute.get(':domain', [])) if not (get_formula_operators(domain) <= {AND}): # TODO: allow positive DNF raise ValueError( 'Stream [{}] domain must be a conjunction'.format(name)) certified = value_from_attribute.get(':certified', None) if not (get_formula_operators(certified) <= {AND}): raise ValueError( 'Stream [{}] certified must be a conjunction'.format(name)) return Stream(name, get_procedure_fn(stream_map, name), value_from_attribute.get(':inputs', []), list_from_conjunction(domain), value_from_attribute.get(':outputs', []), list_from_conjunction(certified), stream_info.get(name, StreamInfo()), fluents=value_from_attribute.get(':fluents', []), is_wild=is_wild)
def parse_constraint(optimizer, lisp_list, infos): value_from_attribute = parse_lisp_list(lisp_list) assert set(value_from_attribute) <= {CONSTRAINT, ':necessary'} # , ':fluents'} return ConstraintStream(optimizer, value_from_attribute[CONSTRAINT], list_from_conjunction(value_from_attribute[':necessary']), infos)
def parse_variable(optimizer, lisp_list, info): value_from_attribute = parse_lisp_list(lisp_list) assert set(value_from_attribute) <= {':variable', ':inputs', ':domain', ':graph'} return VariableStream(optimizer, value_from_attribute[':variable'], # TODO: assume unique? value_from_attribute.get(':inputs', []), list_from_conjunction(value_from_attribute.get(':domain')), list_from_conjunction(value_from_attribute.get(':graph')), info)
def parse_rule(lisp_list, stream_map, stream_info): value_from_attribute = parse_lisp_list(lisp_list[1:]) assert set(value_from_attribute) <= {':inputs', ':domain', ':certified'} # TODO: if len(certified) == 1, augment existing streams RULES.append(Stream(name='rule{}'.format(len(RULES)), gen_fn=from_test(lambda *args: True), inputs=value_from_attribute.get(':inputs', []), domain=list_from_conjunction(value_from_attribute.get(':domain', [])), fluents=[], outputs=[], certified=list_from_conjunction(value_from_attribute.get(':certified', [])), info=StreamInfo(eager=True, p_success=1, overhead=0))) return RULES[-1]