Exemplo n.º 1
0
def set_dynamic_zeropoint(network: STN):
    network = network.copy()
    largish = 1000000.0

    if ZERO_ID not in network.verts:
        network.addVertex(ZERO_ID)

    adjacent_events = set(network.getAdjacent(ZERO_ID))
    for event in network.verts:
        if (event not in adjacent_events) and (event != ZERO_ID):
            network.addEdge(ZERO_ID, event, 0.0, largish)

    return network
Exemplo n.º 2
0
def find_bounds(network: STN) -> dict:
    # Add zero timepoint
    if ZERO_ID not in network.verts:
        network.addVertex(ZERO_ID)
    # Add bounds relative to zero timepoint
    adjacent_to_zero = set(network.getAdjacent(ZERO_ID))
    events = network.verts.keys()
    bounds = {}
    for event in events:
        if (event != ZERO_ID) and (event not in adjacent_to_zero):
            return 0
        else:
            return 0

    # To make sure zero timepoint starts first
    bounds[ZERO_ID] = (-1.0, 0.0)
    return bounds