# Path: soap/context/default.py



import itertools
import math
import numpy
from soap.context import context
    Performs a binary search of the recurrence-based minimum initiation
    interval (RecMII).
    """
    prec = prec or context.ii_precision

    min_ii = max_ii = init_ii
    incr = prec = 2 ** -prec

    # find an upper-bound on MII
    while not rec_init_int_check(graph, max_ii):
        max_ii += incr
        incr *= 2

    # binary search for the optimal MII
    last_ii = max_ii
    while max_ii - min_ii > prec:
        mid_ii = (min_ii + max_ii) / 2
        if rec_init_int_check(graph, mid_ii):
            max_ii = last_ii = mid_ii
        else:
            min_ii = mid_ii

    if round_values:
        return int(math.ceil(last_ii - (max_ii - min_ii) / 2))
    return last_ii


def res_init_int(memory_access_map):
    if not memory_access_map:
        return 1

# Path: soap/context/default.py



# Path: soap/semantics/schedule/ii.py
import itertools
import math
import numpy
from soap.context import context

    Performs a binary search of the recurrence-based minimum initiation
    interval (RecMII).
    """
    prec = prec or context.ii_precision

    min_ii = max_ii = init_ii
    incr = prec = 2 ** -prec

    # find an upper-bound on MII
    while not rec_init_int_check(graph, max_ii):
        max_ii += incr
        incr *= 2

    # binary search for the optimal MII
    last_ii = max_ii
    while max_ii - min_ii > prec:
        mid_ii = (min_ii + max_ii) / 2
        if rec_init_int_check(graph, mid_ii):
            max_ii = last_ii = mid_ii
        else:
            min_ii = mid_ii

    if round_values:
        return int(math.ceil(last_ii - (max_ii - min_ii) / 2))
    return last_ii


def res_init_int(memory_access_map):
    if not memory_access_map:
        return 1

    port_count = context.port_count