示例#1
0
    dam_params256 = SSN5.init_dam_params256(H_spill, H_max, S_max, _alpha,
                                            diam, c1, c2, L_spill, L_crest)
    q, s_p, s_t, s_s = Set_InitialConditions(0.5, A_i[0], A_i)
    S = [100000 for _ in range(n_dams)]
    # continuous simulation
    update = 60  #mins
    lead_time = 360  # the time window checked if there will be any flooding
    lead_time_opt = 60  # the time window used in optimization procedure
    t0 = 0
    states_all = [(-60, [1 for _ in range(len(dams))])]
    columns = SSN5.__columns__()
    dc_ga = pd.DataFrame(columns=columns[0])
    st_ga = pd.DataFrame(columns=columns[1])
    while t0 < te - lead_time:
        if t0 != 0:
            q, S, s_p, s_t, s_s = SSN5.Get_Snapshot()

        #define initial conditions
        SSN5.initialize(q=q, S=S, s_p=s_p, s_t=s_t, s_s=s_s)
        #check if flooding occurs
        data = RunSimulation([
            SSN5, [1 for _ in range(n_dams)], t0, forcing, dam_params256,
            lead_time
        ])
        flow = data[0]

        if flow['8'] > 31.80 / 2 or flow['26'] > 30.40 / 2 or flow[
                '62'] > 27.4 / 2 or flow['89'] > 16.33 / 2 or flow[
                    '170'] > 16.33 / 2:

            population = InitialPopulation2(16, n_dams)
示例#2
0
    q = initial_condition['q']
    s_p = initial_condition['s_p']
    s_t = initial_condition['s_t']
    s_s = initial_condition['s_s']
    fill_percent = np.repeat([0.0001], n_dams5)
    S = (S_max * fill_percent).tolist()

    t0 = 0
    update = 30  #mins
    columns = SSN5_r.__columns__()
    dc_active_S5r = pd.DataFrame(columns=columns[0])
    st_active_S5r = pd.DataFrame(columns=columns[1])
    out_active_S5r = pd.DataFrame(columns=columns[1])
    while t0 < te:
        if t0 != 0:
            q, S, s_p, s_t, s_s = SSN5_r.Get_Snapshot()

        SSN5_r.initialize(q=q, S=S, s_t=s_t, s_p=s_p, s_s=s_s)

        SSN5_r.set_dam_state(
            states=np.random.choice([0, 0.25, 0.50, 0.75, 1], size=(n_dams5)))

        try:
            dc_S5, st_S5 = SSN5_r.Run_256([t0, t0 + update], forcing,
                                          dam_params256)
            out_S5 = SSN5_r.CalculateOutflow(dam_params256, st_S5)
        except IndexError:
            pass

        dc_active_S5r = dc_active_S5r.append(dc_S5)
        st_active_S5r = st_active_S5r.append(st_S5)