Loading pyehub/multi_run_period.py +10 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ def same_converter_constraint(converter, hubs): """ Constraint to ensure the capacities are kept constant across all the subproblems. """ #TODO: Check that storage capacites are also kept the same for i in range(len(hubs)-1): yield hubs[i].capacities[converter] == hubs[i+1].capacities[converter] Loading Loading @@ -53,8 +54,8 @@ def split_hubs(excel=None, request=None, max_carbon=None, num_periods=1, len_per for i in range(0, num_periods): temp_request = copy.deepcopy(request) for stream in temp_request['time_series']: stream['data'] = stream['data'][len_periods(i + i*(num_periods_in_sample_period-1) + sample_period_position) : len_periods(i+1 + i*(num_periods_in_sample_period-1) + sample_period_position)] stream['data'] = stream['data'][len_periods*(i + i*(num_periods_in_sample_period-1) + sample_period_position) : len_periods*(i+1 + i*(num_periods_in_sample_period-1) + sample_period_position)] hub = EHubModel(request=temp_request, max_carbon=max_carbon) hubs.append(hub) Loading @@ -78,6 +79,10 @@ def merge_hubs(hubs): return constraints #TODO: Finish and move to outputter? def multi_run_output(hubs): return None def run_split_period(excel=None, request=None, output_filename=None, max_carbon=None, num_periods=1, len_periods=24, num_periods_in_sample_period=1, sample_period_position=0, solver='glpk'): """ Core function for splitting a PyEHub model into smaller problems to solve together. Loading @@ -99,6 +104,7 @@ def run_split_period(excel=None, request=None, output_filename=None, max_carbon= #FIXME: Ralph had specific instructions for how to handle the objective (wanting a single one or something) # "Make the objective function only one of the investment consts (since they're all the same) # plus the operating cost for each sub-hub scaled by an appropriate factor to represent the whole year."" #TODO: Double check if I should apply the factor here or at the outputter? objective = hubs[0].investment_cost for hub in hubs: objective += hub.operating_cost*(num_periods_in_sample_period) + hub.maintenance_cost*(num_periods_in_sample_period) Loading @@ -107,4 +113,6 @@ def run_split_period(excel=None, request=None, output_filename=None, max_carbon= status = pylp.solve(objective=objective, constraints=constraints, minimize=True, solver=solver) output = multi_run_output(hubs) #TODO: Figure out setting up the output No newline at end of file Loading
pyehub/multi_run_period.py +10 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ def same_converter_constraint(converter, hubs): """ Constraint to ensure the capacities are kept constant across all the subproblems. """ #TODO: Check that storage capacites are also kept the same for i in range(len(hubs)-1): yield hubs[i].capacities[converter] == hubs[i+1].capacities[converter] Loading Loading @@ -53,8 +54,8 @@ def split_hubs(excel=None, request=None, max_carbon=None, num_periods=1, len_per for i in range(0, num_periods): temp_request = copy.deepcopy(request) for stream in temp_request['time_series']: stream['data'] = stream['data'][len_periods(i + i*(num_periods_in_sample_period-1) + sample_period_position) : len_periods(i+1 + i*(num_periods_in_sample_period-1) + sample_period_position)] stream['data'] = stream['data'][len_periods*(i + i*(num_periods_in_sample_period-1) + sample_period_position) : len_periods*(i+1 + i*(num_periods_in_sample_period-1) + sample_period_position)] hub = EHubModel(request=temp_request, max_carbon=max_carbon) hubs.append(hub) Loading @@ -78,6 +79,10 @@ def merge_hubs(hubs): return constraints #TODO: Finish and move to outputter? def multi_run_output(hubs): return None def run_split_period(excel=None, request=None, output_filename=None, max_carbon=None, num_periods=1, len_periods=24, num_periods_in_sample_period=1, sample_period_position=0, solver='glpk'): """ Core function for splitting a PyEHub model into smaller problems to solve together. Loading @@ -99,6 +104,7 @@ def run_split_period(excel=None, request=None, output_filename=None, max_carbon= #FIXME: Ralph had specific instructions for how to handle the objective (wanting a single one or something) # "Make the objective function only one of the investment consts (since they're all the same) # plus the operating cost for each sub-hub scaled by an appropriate factor to represent the whole year."" #TODO: Double check if I should apply the factor here or at the outputter? objective = hubs[0].investment_cost for hub in hubs: objective += hub.operating_cost*(num_periods_in_sample_period) + hub.maintenance_cost*(num_periods_in_sample_period) Loading @@ -107,4 +113,6 @@ def run_split_period(excel=None, request=None, output_filename=None, max_carbon= status = pylp.solve(objective=objective, constraints=constraints, minimize=True, solver=solver) output = multi_run_output(hubs) #TODO: Figure out setting up the output No newline at end of file