1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/python3
# Copyright (C) 2018 The Regents of the University of California, Michael Ludkovski and Aditya Maheshwari
# All Rights Reserved
# This code is published under the GNU Lesser General Public License (GNU LGPL)
from __future__ import division
import numpy as np
import math
import matplotlib.pyplot as plt
import time
import sys
from datetime import datetime
if (sys.version_info > (3, 0)):
import pickle
else:
import cPickle as pickle
import microgridDEA.parameters as bp
import microgridDEA.calEngineBatched as ce
import microgridDEA.forwardSimulations as fs
def runSimulation():
# create an instance of parameter class.
param = bp.basicVariables()
# creates the list of objects defining the type of regression monte carlo.
regParamObjcs = []
for i in range(param.nstep):
# for time steps from 0 to "param.designChangePnt-1", we use regress now-2D
if i<param.designChangePnt:
regType = bp.regressionType('regress now 2D')
regParamObjcs.append(regType)
else:
# for time steps after "param.designChangePnt", we use grid-discretization
regType = bp.regressionType('gd')
regParamObjcs.append(regType)
# dump the regression parameters using pickle.
name = param.regParamDump
with open(name, 'wb') as output:
pickle.dump(regParamObjcs, output, pickle.HIGHEST_PROTOCOL)
ce.storageCalculation(param,regParamObjcs)
if __name__ == "__main__":
runSimulation()
fs.forwardSimulations()
|