def decay_growth_df(growth_type, growth_rate): vintages, years = np.asarray(cfgfile.get('case', 'vintages')), np.asarray(cfgfile.get('case', 'years')) ages = np.zeros((len(years), len(vintages))) for i, year in enumerate(years): ages[i] = vintages - year if growth_type == 'linear': fill = 1 + (growth_rate * ages) fill = np.triu(fill, k=(min(years) - min(vintages))) elif growth_type == 'exponential': fill = (1 + growth_rate) ** ages fill = np.triu(fill, k=(min(years) - min(vintages))) return pd.DataFrame(fill, index=vintages, columns=years)
""" multiprocessing.log_to_stderr().setLevel(logging.DEBUG) if __name__ == "__main__": _start_time = datetime.datetime.now() print "Running dispatch..." multiprocessing.freeze_support( ) # can be omitted if we won't be producing a Windows executable # ############# SETTINGS ############# # # Currently using all available CPUs in multiprocessing function below available_cpus = multiprocessing.cpu_count() # Solver info solver_name = cfgfile.get('case', 'solver') solver_settings = None # Pyomo solve keyword arguments # Set 'keepfiles' to True if you want the problem and solution files # Set 'tee' to True if you want to stream the solver output solve_kwargs = {"keepfiles": False, "tee": False} # How much to print to standard output; set to 1 for more detailed output, 0 for limited detail stdout_detail = 1 # The directory structure will have to change, but I'm not sure how yet current_directory = os.getcwd() results_directory = current_directory + "/results" inputs_directory = current_directory + "/test_inputs"
# -*- coding: utf-8 -*- """ Created on Wed Sep 02 11:19:36 2015 @author: Ben """ import numpy as np from config import cfgfile import pandas as pd vintage_start, vintage_stop, vintage_step = 1950, 2050, 1 vintages = np.arange(vintage_start, vintage_stop + 1, vintage_step) year_start, year_stop, year_step = 1950, 2050, 1 years = np.asarray(cfgfile.get('case', 'years')) vintages = np.asarray(cfgfile.get('case', 'vintages')) # vintage_age creates an array of numbers for each vintage v that represents age in year y. def vintage_age(years, vintages): ages = np.zeros((len(years), len(vintages))) # vintage_exist creates a binary array that is 1 if year is greater than vintage (i.e. vintage v exists in year y) def vintage_exist(years, vintages): # Built in function to create a lower triangular distribution, k gives the shift from the diagonal age = vintage_age(years, vintages) return np.triu(age, k=(min(years) - min(vintages))) test = np.triu(len(years), len(vintages), k=min(years) - min(vintages))
:return: """ multiprocessing.log_to_stderr().setLevel(logging.DEBUG) if __name__ == "__main__": _start_time = datetime.datetime.now() print "Running dispatch..." multiprocessing.freeze_support() # can be omitted if we won't be producing a Windows executable # ############# SETTINGS ############# # # Currently using all available CPUs in multiprocessing function below available_cpus = multiprocessing.cpu_count() # Solver info solver_name = cfgfile.get('case','solver') solver_settings = None # Pyomo solve keyword arguments # Set 'keepfiles' to True if you want the problem and solution files # Set 'tee' to True if you want to stream the solver output solve_kwargs = {"keepfiles": False, "tee": False} # How much to print to standard output; set to 1 for more detailed output, 0 for limited detail stdout_detail = 1 # The directory structure will have to change, but I'm not sure how yet current_directory = os.getcwd() results_directory = current_directory + "/results" inputs_directory = current_directory + "/test_inputs"