Exemplo n.º 1
0
def test_load_aut_json():
    g = gr1c.load_aut_json(REFERENCE_AUTJSON_smallbool)
    assert g.env_vars == dict(x='boolean'), (g.env_vars)
    assert g.sys_vars == dict(y='boolean'), (g.sys_vars)
    # `REFERENCE_AUTJSON_smallbool` defined above
    h = nx.DiGraph()
    nodes = {0: '0x1E8FA40', 1: '0x1E8FA00', 2: '0x1E8F990'}
    h.add_node(nodes[0], state=dict(x=0, y=0),
               mode=0, rgrad=1, initial=False)
    h.add_node(nodes[1], state=dict(x=1, y=1),
               mode=1, rgrad=1, initial=False)
    h.add_node(nodes[2], state=dict(x=0, y=1),
               mode=0, rgrad=1, initial=True)
    edges = [(nodes[0], nodes[1]),
             (nodes[1], nodes[0]),
             (nodes[2], nodes[1])]
    h.add_edges_from(edges)
    # compare
    for u, d in h.nodes_iter(data=True):
        assert u in g, (u, g.nodes())
        d_ = g.node[u]
        for k, v in d.iteritems():
            v_ = d_.get(k)
            assert v_ == v, (k, v, v_, d, d_)
    h_edges = set(h.edges_iter())
    g_edges = set(g.edges_iter())
    assert h_edges == g_edges, (h_edges, g_edges)
Exemplo n.º 2
0
def synthesize(spec, init_option="ALL_ENV_EXIST_SYS_INIT"):
    """Synthesize strategy realizing the given specification.

    cf. L{tulip.interfaces.gr1c.synthesize}
    """
    tsys, exprtab = _spec_to_gr1py(spec)
    strategy = gr1py.solve.synthesize(tsys, exprtab)
    if strategy is None:
        return None
    s = gr1py.output.dump_json(tsys.symtab, strategy)
    return load_aut_json(s)
Exemplo n.º 3
0
def synthesize(spec):
    """Synthesize strategy realizing the given specification.

    cf. L{tulip.interfaces.gr1c.synthesize}
    """
    init_option = select_options(spec)
    tsys, exprtab = _spec_to_gr1py(spec)
    strategy = gr1py.solve.synthesize(tsys, exprtab, init_flags=init_option)
    if strategy is None:
        return None
    s = gr1py.output.dump_json(tsys.symtab, strategy)
    return load_aut_json(s)