import sys sys.path.append('C:\\MyPythonPackages\\dynamic_stock_model-master\\dynamic_stock_model\\') from dynamic_stock_model import DynamicStockModel import numpy as np TestDSM = DynamicStockModel(t = np.arange(1,11,1), i = np.arange(2.5,12.5,1), lt = {'Type': 'Normal', 'Mean': np.array([5]), 'StdDev': np.array([1.5]) }) TestDSM.t TestDSM.i TestDSM.lt CheckStr, ExitFlag = TestDSM.dimension_check() print(CheckStr) Stock_by_cohort, ExitFlag = TestDSM.compute_s_c_inflow_driven() print(Stock_by_cohort) S, ExitFlag = TestDSM.compute_stock_total() print(S) O_C, ExitFlag = TestDSM.compute_o_c_from_s_c() print(O_C) O, ExitFlag = TestDSM.compute_outflow_total() print(O) DS, ExitFlag = TestDSM.compute_stock_change() print(DS) print(TestDSM.dimension_check()[0]) # dimension_check returns two variables, but we only print the first one, which has index 0. Bal, ExitFlag = TestDSM.check_stock_balance() print(Bal) %matplotlib inline # this is only for the IPython notebook, not part of the python script! import matplotlib.pyplot as plt plt.imshow(TestDSM.s_c, interpolation='nearest') plt.xlabel('age-cohort') plt.ylabel('year') plt.title('Stock by age-cohort') plt.show(); plt.imshow(TestDSM.o_c,interpolation='nearest') plt.xlabel('age-cohort') plt.ylabel('year') plt.title('Outflow by age-cohort') plt.show(); TestDSMX = DynamicStockModel(t = np.arange(1,11,1), s = np.array([ 2.5, 6. , 10.5, 16. , 22.5, 27.5, 32.5, 37.5, 42.5, 47.5]), lt = {'Type': 'Normal', 'Mean': np.array([4]), 'StdDev': np.array([1.0]) }) CheckStr, ExitFlag = TestDSMX.dimension_check() print(CheckStr) S_C, O_C, I, ExitFlag = TestDSMX.compute_stock_driven_model() O, ExitFlag = TestDSMX.compute_outflow_total() DS, ExitFlag = TestDSMX.compute_stock_change() Bal, ExitFlag = TestDSMX.check_stock_balance() print(Bal) plt1, = plt.plot(TestDSMX.t, TestDSMX.i) plt2, = plt.plot(TestDSMX.t, TestDSMX.s) plt3, = plt.plot(TestDSMX.t, TestDSMX.o) plt.xlabel('Year') plt.ylabel('tons') plt.title('Stock parameters') plt.legend([plt1,plt2,plt3], ['Inflow','Stock','Outflow'], loc = 2) plt.show(); plt.imshow(TestDSMX.s_c,interpolation='nearest') plt.xlabel('age-cohort') plt.ylabel('year') plt.title('Stock by age-cohort') plt.show(); plt.imshow(TestDSMX.o_c,interpolation='nearest') plt.xlabel('age-cohort') plt.ylabel('year') plt.title('Outflow by age-cohort') plt.show();