def RLCSimulation(folderName, inputType, unit, approachName, houseNumber, randomFlag): ''' This method used to construct yaml file and construct the RLC result based on random. str, str, int, str, [int, int, ...] => file ''' # read CSV input files Result = ReadCSV(folderName, inputType) requests = list(Result[0]) ideal_type_load = modify_ideal_load(Result[1][-1], unit) # write load profile files getLoadProfileFiles(folderName, unit) # get house layout and zip_loads houseLayout = yamlCalcMethods.getHouseLayout(houseNumber, requests) S_ZipList = yamlCalcMethods.getSZipList(len(houseLayout)) lengthMvList = yamlCalcMethods.getLengthMvList(len(houseLayout)) # get the load, which not perform RLC approach original_loads = getOriginalObservedLoad(Result, unit, approachName) # get the relationship between request name, and its last minute number requestNameMinMap = yamlCalcMethods.getRequestNameMinMap(requests) # get the requestNameMinMap # write yaml file, and return RLC result random_observed_loads = writeYamlFileAndReturnRandomProbabilities(Result, houseNumber, requests, unit, folderName, approachName, houseLayout, requestNameMinMap, S_ZipList, lengthMvList) # write the csv file which save original and RLC loads write_output(ideal_type_load, original_loads, random_observed_loads, folderName, inputType, randomFlag) print 'FINISH Random Output'
def writeYamlFileWithLargeNumOfHouses(folderName, inputType, unit, approachName, houseNumber): """ This method used to create a yaml file with the large number of houses. In order to save code time, several methods will import from 'yamlCalcMethods' and 'yamlWriteMethods'. Consider of the tiny different requirement, it is better to write a new python to construct yaml file. str, str, int, str, int, float => file """ print "START read request type file" RequestTypeDict = CsvToLoad.readExperiment(folderName) for RequestType in RequestTypeDict.values(): load_list = CsvToLoad.extractApplianceProfile(RequestType, unit) CsvToLoad.generateLoadTxt(load_list, RequestType.request_name, folderName, unit) print "START read requests file" Result = ReadCSV(folderName, inputType) # read requests information from input csv file requests = list(Result[0]) houseLayout = yamlCalcMethods.getHouseLayout(houseNumber, requests) requestNameMinMap = yamlCalcMethods.getRequestNameMinMap(requests) # get the requestNameMinMap ideal_shiftable_load = modify_ideal_load(Result[1][-1], unit) # get ideal shift-able load signal_load = list(ideal_shiftable_load) # make ideal shift-able load equal to signal load requests = updateProfile(requests, unit) # update profile requests = getProbDistribution(requests, signal_load, unit, approachName) # update probabilities fileCount = 0 totalRequestNumber = getTotalRequestNumber(requests) restRequestNumber = int(totalRequestNumber) while restRequestNumber != 0: if restRequestNumber < houseNumber: repeatNumber = restRequestNumber else: repeatNumber = houseNumber fileName = "".join(("CSVdata/", folderName, "/resident/" "resident_", folderName, "_", str(fileCount), ".yaml")) applianceMap = getApplianceMap(repeatNumber, requests, unit) # get the start time and request name dict requests = setNewRequests(requests) # delete the request which quantity is zero writeFile = open(fileName, "w") yamlWriteMethods.writeConstParameters(writeFile) yamlWriteMethods.writeHouseLayout(writeFile, houseLayout) yamlWriteMethods.writeVariableList(writeFile, houseLayout) yamlWriteMethods.writeConstSimulation(writeFile) yamlWriteMethods.writeConstNetwork(writeFile) yamlWriteMethods.writeConstHeartbeat(writeFile) yamlWriteMethods.writeTimeSerialLoop(writeFile, applianceMap, folderName) # write load / time_series content yamlWriteMethods.writeConstBus(writeFile) yamlWriteMethods.writeConstGenericgen(writeFile) yamlWriteMethods.writeConstLoop(writeFile) applianceCount = 0 yamlWriteMethods.writeAllAppliance(houseLayout, writeFile, applianceMap, applianceCount, requestNameMinMap) writeFile.close() print "No.", print fileCount, print "yaml file had constructed" fileCount = fileCount + 1 restRequestNumber = restRequestNumber - repeatNumber print "CONSTRUCT ", print fileCount, print "yaml files"