예제 #1
0
def _get_data(sp, force_new=False):
    "get solution data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("odu")

        if force_new or not existed:
            if existed:
                grp.v._f_remove()
                grp.phi_vfi._f_remove()
                grp.phi_pfi._f_remove()
                grp.new_v._f_remove()
            v, phi_vfi, phi_pfi, new_v = _new_solution(sp, f, grp)

            return v, phi_vfi, phi_pfi, new_v

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading data
            v = grp.v[:]
            phi_vfi = grp.phi_vfi[:]
            phi_pfi = grp.phi_pfi[:]
            new_v = grp.new_v[:]

        except:
            # doesn't exist. Let's create it
            v, phi_vfi, phi_pfi, new_v = _new_solution(sp, f, grp)

    return v, phi_vfi, phi_pfi, new_v
예제 #2
0
def _get_data(sp, force_new=False):
    "get solution data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("odu")

        if force_new or not existed:
            if existed:
                grp.v._f_remove()
                grp.phi_vfi._f_remove()
                grp.phi_pfi._f_remove()
                grp.new_v._f_remove()
            v, phi_vfi, phi_pfi, new_v = _new_solution(sp, f, grp)

            return v, phi_vfi, phi_pfi, new_v

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading data
            v = grp.v[:]
            phi_vfi = grp.phi_vfi[:]
            phi_pfi = grp.phi_pfi[:]
            new_v = grp.new_v[:]

        except:
            # doesn't exist. Let's create it
            v, phi_vfi, phi_pfi, new_v = _new_solution(sp, f, grp)

    return v, phi_vfi, phi_pfi, new_v
def _get_price_data(tree, force_new=False):
    "get price data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("lucastree")

        if force_new or not existed:
            if existed:
                grp.prices._f_remove()
            prices = _new_solution(tree, f, grp)

            return prices

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading vfi
            prices = grp.prices[:]

        except:
            # doesn't exist. Let's create it
            prices = _new_solution(tree, f, grp)

    return prices
def _get_price_data(tree, force_new=False):
    "get price data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("lucastree")

        if force_new or not existed:
            if existed:
                grp.prices._f_remove()
            prices = _new_solution(tree, f, grp)

            return prices

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading vfi
            prices = grp.prices[:]

        except:
            # doesn't exist. Let's create it
            prices = _new_solution(tree, f, grp)

    return prices
예제 #5
0
def _get_data(gm, force_new=False):
    "get solution data from file, or create if necessary"
    with get_h5_data_file() as f:
        existed, grp = get_h5_data_group("optgrowth")

        if force_new or not existed:
            if existed:
                grp.w._f_remove()
            v = _new_solution(gm, f, grp)

            return v

        # if we made it here, the group exists and we should try to read
        # existing solutions
        try:
            # Try reading data
            v = grp.v[:]

        except:
            # doesn't exist. Let's create it
            v = _new_solution(gm, f, grp)

    return v