python控制EnergyPlus方法(linux)

简介:使用python控制bcvtb与energyplus进行交互,参考 https://github.com/zhangzhizza/Gym-Eplus ,抠掉了其中gym库的内容

一.安装软件,bcvtb1.6 和 energyplus8.7

1.bcvtb,https://simulationresearch.lbl.gov/bcvtb/

①.官网提到的依赖库(好像可以不装),https://simulationresearch.lbl.gov/bcvtb/releases/latest/doc/manual/tit-sofReqDev.xhtml
sudo apt-get install libxml2-dev libexpat-dev doxygen graphviz
sudo apt-get install docbook docbook-xsl libsaxon-java libxalan2-java docbook-xsl-saxon dblatex pdftk

②.安装jdk,https://www.oracle.com/java/technologies/javase-downloads.html
sudo dpkg -i jdk-11.0.12_linux-x64_bin.deb
③.安装bcvtb,https://simulationresearch.lbl.gov/bcvtb/Download
java -jar bcvtb-install-linux64-v1.6.0.jar

卸载
cd bcvtb/Uninstallerr
java -jar uninstaller.jar

2.energy plus,https://energyplus.net/downloads
sh EnergyPlus-8.7.0-78a111df4a-Linux-x86_64.sh

二.创建新的虚拟环境
pip install pipreqs -i HTTPS://mirrors.aliyun.com/pypi/simple/ # 安装 pipreqs
pip freeze > requirements.txt # 打包 requirements

virtualenv --python=/usr/bin/python3 virt_env # 创建环境
source virt_env/bin/activate # 激活环境
pip install -r requirements.txt -i HTTPS://mirrors.aliyun.com/pypi/simple/ # 安装依赖

三.调用库函数跑demo
EplusUtils.py

# bcvtb 和 EnergyPlus 交互的库
# 参考 https://github.com/zhangzhizza/Gym-Eplus,抠掉了gym的内容,函数全部整合到这一个脚本
# 修改日期:2021.7.30import socket, signal, _thread, threading
import os, copy, time, subprocess, traceback, datetime
import logging
from shutil import copyfile, rmtree
from xml.etree.ElementTree import Element, SubElement, tostringYEAR = 1991
CWD = os.getcwd()
LOG_LEVEL_MAIN = 'INFO'
LOG_LEVEL_EPLS = 'ERROR'
LOG_FMT = "[%(asctime)s] %(name)s %(levelname)s:%(message)s"WEEKDAY_ENCODING = {'monday': 0,'tuesday': 1,'wednesday': 2,'thursday': 3,'friday': 4,'saturday': 5,'sunday': 6}class IdfParser(object):"""功能:改写idf文件"""def __init__(self, idf_dir, version='8_7'):self._idf_dir = idf_dir# idf_dict is:# {idf_class_name:[obj_content_str, obj_content_str]}self._idf_dict = {}self._version = versionself._parser_idf()def _parser_idf(self):with open(self._idf_dir, 'r') as idf_file:idf_lines = idf_file.readlines()is_obj_start = Falseobj_content = ''obj_name = ''for idf_line in idf_lines:idf_line_prcd = idf_line.split('\n')[0].split('!')[0].strip()if is_obj_start == False:if len(idf_line_prcd) > 0:if idf_line_prcd[-1] == ',':obj_name = idf_line_prcd[:-1]is_obj_start = Trueelif idf_line_prcd[-1] == ';':obj_name = idf_line_prcd[0:idf_line_prcd.find(',')]obj_content = idf_line_prcd[idf_line_prcd.find(',') + 1:];if obj_name in self._idf_dict:self._idf_dict[obj_name].append(obj_content)else:self._idf_dict[obj_name] = [obj_content]# Reset obj temp fieldsis_obj_start = Falseobj_content = ''obj_name = ''else:obj_content += idf_lineif len(idf_line_prcd) > 0:if idf_line_prcd[-1] == ';':if obj_name in self._idf_dict:self._idf_dict[obj_name].append(obj_content)else:self._idf_dict[obj_name] = [obj_content]# Reset obj temp fieldsis_obj_start = Falseobj_content = ''obj_name = ''def write_idf(self, to_write_dir):to_write_str = ''# Construct the string to writefor idf_obj_name in self._idf_dict:obj_contents = self._idf_dict[idf_obj_name]for obj_content in obj_contents:to_write_str += idf_obj_name + ',\n'to_write_str += obj_content + '\n'with open(to_write_dir, 'w') as idf_file:idf_file.write(to_write_str)def write_object_in_idf(self, to_write_dir, object_name):to_write_str = ''# Construct the string to writeobj_contents = self._idf_dict[object_name]for obj_content in obj_contents:to_write_str += object_name + ',\n'to_write_str += obj_content + '\n'with open(to_write_dir, 'w') as idf_file:idf_file.write(to_write_str)def remove_objects_all(self, class_name):self._idf_dict.pop(class_name)def get_obj_reference_count(self, obj_name):ref_ct = 0for key, value in self._idf_dict.items():for obj in value:obj_lines = obj.split(',')[1:]  # Exclude the obj name itself from the referencefor obj_line in obj_lines:# Remove \nnl_sps = obj_line.split('\n')nl_free = nl_sps[1] if len(nl_sps) > 2 else nl_sps[-1]  # Handle the line with ;effc_obj_line = nl_free.split(';')[0].strip()if obj_name == effc_obj_line:ref_ct += 1return ref_ctdef remove_object(self, class_name, obj_name):try:tgt_objects = self._idf_dict[class_name]tgt_idx = 0for obj in tgt_objects:obj_name_this = self.get_object_name(obj)if obj_name_this == obj_name:breakelse:tgt_idx += 1self._idf_dict[class_name].pop(tgt_idx)except Exception as e:print('Func: remove_object, args:(%s, %s), error: %s' % (class_name, obj_name, traceback.format_exc()))def get_object_name(self, object_content):obj_name = object_content.split(',')[0].split('\n')[-1].strip()return obj_namedef get_schedule_type_init_value(self, schedule_name):schedule_content = Nonefor cmp_schedule_content in self._idf_dict['Schedule:Compact']:if self.get_object_name(cmp_schedule_content) == schedule_name:schedule_content = cmp_schedule_contentbreakschedule_content = schedule_content.split(';')[0].split(',')schedule_type = schedule_content[1].split('\n')[-1].strip()# Schedule init valuefor schedule_line_i in schedule_content[2:]:try:init_value = float(schedule_line_i.split('\n')[-1].strip())breakexcept Exception as e:passreturn (schedule_type, init_value)def get_all_compact_schedules_names(self):returned_list = []for cmp_schedule_content in self._idf_dict['Schedule:Compact']:returned_list.append(self.get_object_name(cmp_schedule_content))return returned_listdef localize_schedule(self, local_file_path):file_name = local_file_path.split(os.sep)[-1]file_dir = local_file_path[:local_file_path.rfind(os.sep)]sch_file_contents = self._idf_dict['Schedule:File']content_i = 0for sch_file_obj in copy.deepcopy(sch_file_contents):if file_name in sch_file_obj:file_name_st_idx = sch_file_obj.rfind(file_name)full_path_st_idx = sch_file_obj.rfind(',', 0, file_name_st_idx)sch_file_obj = sch_file_obj[0:full_path_st_idx] + ',\n' + file_dir + '/' + sch_file_obj[file_name_st_idx:]sch_file_contents[content_i] = sch_file_objcontent_i += 1self._idf_dict['Schedule:File'] = sch_file_contentsdef is_contain_filesch(self):result = 'Schedule:File' in self._idf_dictreturn (result)def add_objects(self, dict_to_add):for key in dict_to_add:objects_to_add = dict_to_add[key]if key in self._idf_dict:self._idf_dict[key].extend(objects_to_add)else:self._idf_dict[key] = objects_to_adddef add_dxf_output(self):self._idf_dict['Output:Surfaces:Drawing'] = ['DXF,!- Report Type\n' +'Triangulate3DFace;\n']def set_minimum_run(self):self._idf_dict['SimulationControl'] = ['Yes,!- Do Zone Sizing Calculation\n' +'No,!- Do System Sizing Calculation\n' +'No,!- Do Plant Sizing Calculation\n' +'No,!- Run Simulation for Sizing Periods\n' +'No;!- Run Simulation for Weather File Run Periods\n'];if 'Schedule:File' in self._idf_dict:self._idf_dict.pop('Schedule:File', None)@propertydef idf_dict(self):return self._idf_dictdef create_env(source_idf_path, add_idf_path):"""功能:创建 EnergyPlus 运行需要的 .env 模型文件"""# Create a new idf file with the addtional contentssource_idf = IdfParser(source_idf_path)add_idf = IdfParser(add_idf_path)# Remove the original output variablesource_idf.remove_objects_all('Output:Variable')# Remove the schedules in the original idftgt_class_name_in_add = 'ExternalInterface:Schedule'tgt_sch_names_in_org = [source_idf.get_object_name(add_content)for add_content inadd_idf.idf_dict[tgt_class_name_in_add]]tgt_class_name_in_org = 'Schedule:Compact'for to_rm_obj_name in tgt_sch_names_in_org:source_idf.remove_object(tgt_class_name_in_org, to_rm_obj_name)# Check whether or not the tgt_sch_names have been actually used in the# source idffor tgt_sch_name in tgt_sch_names_in_org:tgt_sch_ref_ct = source_idf.get_obj_reference_count(tgt_sch_name)if tgt_sch_ref_ct < 1:print('WARNING!!!!! The target schedule %s ''may not be used the source IDF.' % tgt_sch_name)# Add the addition to the source idfsource_idf.add_objects(add_idf.idf_dict)# Write the new idf out. The name has '.env' before the file idf# extensionnew_idf_name = source_idf_path + '.env'source_idf.write_idf(new_idf_name)class Logger():def getLogger(self, name, level, formatter):logger = logging.getLogger(name)consoleHandler = logging.StreamHandler()consoleHandler.setFormatter(logging.Formatter(formatter))logger.addHandler(consoleHandler)logger.setLevel(level)logger.propagate = Falsereturn loggerdef get_delta_seconds(st_year, st_mon, st_day, ed_mon, ed_day):"""funtion: 计算时间差(秒),[start_year:start_month:start_day:0:0:0] 到 [start_year:end_mon:end_day:24:0:0]"""startTime = datetime.datetime(st_year, st_mon, st_day, 0, 0, 0)endTime = datetime.datetime(st_year, ed_mon, ed_day, 23, 0, 0) + datetime.timedelta(0, 3600)delta_sec = (endTime - startTime).total_seconds()return delta_secclass EplusEnv():"""funtion: EnergyPlus 仿真运行的类,重点在 self.step() 函数"""def __init__(self,eplus_path,weather_path,bcvtb_path,variable_path,idf_path,env_name,act_repeat=1,max_ep_data_store_num=1):self._env_name = env_nameself._thread_name = threading.current_thread().getName()self.logger_main = Logger().getLogger('EPLUS_ENV_%s_%s_ROOT' % (env_name, self._thread_name),LOG_LEVEL_MAIN, LOG_FMT)# Set the environment variable for bcvtbos.environ['BCVTB_HOME'] = bcvtb_path# Create a socket for communication with the EnergyPlusself.logger_main.debug('Creating socket for communication...')s = socket.socket()host = socket.gethostname()  # Get local machine names.bind((host, 0))  # Bind to the host and any available portsockname = s.getsockname()port = sockname[1]  # Get the port numbers.listen(60)  # Listen on requestself.logger_main.debug('Socket is listening on host %s port %d' % (sockname))self._env_working_dir_parent = self._get_eplus_working_folder(CWD, '-%s-res' % (env_name))os.makedirs(self._env_working_dir_parent)self._host = hostself._port = portself._socket = sself._eplus_path = eplus_pathself._weather_path = weather_pathself._variable_path = variable_pathself._idf_path = idf_pathself._episode_existed = False(self._eplus_run_st_mon,self._eplus_run_st_day,self._eplus_run_ed_mon,self._eplus_run_ed_day,self._eplus_run_st_weekday,self._eplus_run_stepsize) = self._get_eplus_run_info(idf_path)self._eplus_run_stepsize = 3600 / self._eplus_run_stepsize# Stepsize in secondself._eplus_one_epi_len = self._get_one_epi_len(self._eplus_run_st_mon,self._eplus_run_st_day,self._eplus_run_ed_mon,self._eplus_run_ed_day)self._epi_num = 0self._act_repeat = act_repeatself._max_res_to_keep = max_ep_data_store_numself._last_action = [20.0]def reset(self):ret = []# End the last episode if existsif self._episode_existed:self._end_episode()self.logger_main.info('Last EnergyPlus process has been closed. ')self._epi_num += 1# Create EnergyPlus simulaton processself.logger_main.info('Creating EnergyPlus simulation environment...')eplus_working_dir = self._get_eplus_working_folder(self._env_working_dir_parent, '-sub_run')os.makedirs(eplus_working_dir)  # Create the Eplus working directory# Remove redundant past working directoriesself._rm_past_history_dir(eplus_working_dir, '-sub_run')eplus_working_idf_path = (eplus_working_dir +'/' +self._get_file_name(self._idf_path))eplus_working_var_path = (eplus_working_dir +'/' +'variables.cfg')  # Variable file must be with this nameeplus_working_out_path = (eplus_working_dir +'/' +'output')copyfile(self._idf_path, eplus_working_idf_path)# Copy the idf file to the working directorycopyfile(self._variable_path, eplus_working_var_path)# Copy the variable.cfg file to the working dirself._create_socket_cfg(self._host,self._port,eplus_working_dir)# Create the socket.cfg file in the working dirself.logger_main.info('EnergyPlus working directory is in %s' % (eplus_working_dir))eplus_process = self._create_eplus(self._eplus_path,self._weather_path,eplus_working_idf_path,eplus_working_out_path,eplus_working_dir)self.logger_main.debug('EnergyPlus process is still running ? %r' % self._get_is_subprocess_running(eplus_process))self._eplus_process = eplus_process# Log the Eplus outputeplus_logger = Logger().getLogger('EPLUS_ENV_%s_%s-EPLUSPROCESS_EPI_%d'% (self._env_name, self._thread_name, self._epi_num), LOG_LEVEL_EPLS, LOG_FMT)_thread.start_new_thread(self._log_subprocess_info, (eplus_process.stdout, eplus_logger))_thread.start_new_thread(self._log_subprocess_err, (eplus_process.stderr, eplus_logger))# Establish connection with EnergyPlus# Establish connection with client.conn, addr = self._socket.accept()self.logger_main.debug('Got connection from %s at port %d.' % (addr))# Start the first data exchangercv_1st = conn.recv(2048).decode(encoding='ISO-8859-1')self.logger_main.debug('Got the first message successfully: ' + rcv_1st)version, flag, nDb, nIn, nBl, curSimTim, Dblist = self._disassembleMsg(rcv_1st)ret.append(curSimTim)ret.append(Dblist)# Remember the message header, useful when send data back to EnergyPlusself._eplus_msg_header = [version, flag]self._curSimTim = curSimTim# Check if episode terminatesis_terminal = Falseif curSimTim >= self._eplus_one_epi_len:is_terminal = Trueret.append(is_terminal)# Change some attributesself._conn = connself._eplus_working_dir = eplus_working_dirself._episode_existed = True# Process for episode terminalif is_terminal:self._end_episode()return tuple(ret)def step(self, action):# Check terminalif self._curSimTim >= self._eplus_one_epi_len:return Noneret = []# Send to the EnergyPlusact_repeat_i = 0is_terminal = FalsecurSimTim = self._curSimTim# Now just hard code to the energy, the last item in state observationintegral_item_list = []while act_repeat_i < self._act_repeat and (not is_terminal):self.logger_main.debug('Perform one step.')header = self._eplus_msg_headerrunFlag = 0  # 0 is normal flagtosend = self._assembleMsg(header[0], runFlag, len(action), 0, 0, curSimTim, action)self._conn.send(tosend.encode())# Recieve from the EnergyPlusrcv = self._conn.recv(2048).decode(encoding='ISO-8859-1')self.logger_main.debug('Got message successfully: ' + rcv)# Process received msgversion, flag, nDb, nIn, nBl, curSimTim, Dblist = self._disassembleMsg(rcv)# Hard code that the last item is the integral itemintegral_item_list.append(Dblist[-1])if curSimTim >= self._eplus_one_epi_len:is_terminal = True# Remember the last actionself._last_action = actionact_repeat_i += 1# Construct the return. The return is the state observation of the last# step plus the integral itemret.append(curSimTim)Dblist[-1] = 1.0 * sum(integral_item_list) / len(integral_item_list)ret.append(Dblist)# Add terminal statusret.append(is_terminal)# Change some attributesself._curSimTim = curSimTimreturn retdef _rm_past_history_dir(self, cur_eplus_working_dir, dir_sig):cur_dir_name, cur_dir_id = cur_eplus_working_dir.split(dir_sig)cur_dir_id = int(cur_dir_id)if cur_dir_id - self._max_res_to_keep > 0:rm_dir_id = cur_dir_id - self._max_res_to_keeprm_dir_full_name = cur_dir_name + dir_sig + str(rm_dir_id)rmtree(rm_dir_full_name)def _create_eplus(self, eplus_path, weather_path, idf_path, out_path, eplus_working_dir):eplus_process = subprocess.Popen('%s -w %s -d %s %s'% (eplus_path + '/energyplus',weather_path,out_path, idf_path),shell=True,cwd=eplus_working_dir,stdout=subprocess.PIPE,stderr=subprocess.PIPE,preexec_fn=os.setsid)return eplus_processdef _get_eplus_working_folder(self, parent_dir, dir_sig='-run'):os.makedirs(parent_dir, exist_ok=True)experiment_id = 0for folder_name in os.listdir(parent_dir):if not os.path.isdir(os.path.join(parent_dir, folder_name)):continuetry:folder_name = int(folder_name.split(dir_sig)[-1])if folder_name > experiment_id:experiment_id = folder_nameexcept:passexperiment_id += 1parent_dir = os.path.join(parent_dir, 'Out')parent_dir = parent_dir + '%s%d' % (dir_sig, experiment_id)return parent_dirdef _create_socket_cfg(self, host, port, write_dir):top = Element('BCVTB-client')ipc = SubElement(top, 'ipc')socket = SubElement(ipc, 'socket', {'port': str(port), 'hostname': host, })xml_str = tostring(top, encoding='ISO-8859-1').decode()with open(write_dir + '/' + 'socket.cfg', 'w+') as socket_file:socket_file.write(xml_str)def _get_file_name(self, file_path):path_list = file_path.split('/')return path_list[-1]def _log_subprocess_info(self, out, logger):for line in iter(out.readline, b''):logger.info(line.decode())def _log_subprocess_err(self, out, logger):for line in iter(out.readline, b''):logger.error(line.decode())def _get_is_subprocess_running(self, subprocess):if subprocess.poll() is None:return Trueelse:return Falsedef get_is_eplus_running(self):return self._get_is_subprocess_running(self._eplus_process)def end_env(self):self._end_episode()self._socket.shutdown(socket.SHUT_RDWR)self._socket.close()def end_episode(self):self._end_episode()def _end_episode(self):# Send the final msg to EnergyPlusheader = self._eplus_msg_headerflag = 1.0  # Terminate flag is 1.0, specified by EnergyPlusaction = self._last_actionaction_size = len(self._last_action)tosend = self._assembleMsg(header[0], flag, action_size, 0, 0, self._curSimTim, action)self.logger_main.debug('Send the final msg to Eplus.')self._conn.send(tosend.encode())# Recieve the final msg from Eplusrcv = self._conn.recv(2048).decode(encoding='ISO-8859-1')self.logger_main.debug('Final msh from Eplus: %s', rcv)self._conn.send(tosend.encode())  # Send again, don't know why# time.sleep(0.2) # Rest for a while so EnergyPlus finish post processing# Remove the connectionself._conn.close()self._conn = None# Process the output# self._run_eplus_outputProcessing();time.sleep(1)  # Sleep the thread so EnergyPlus has time to do the# post processing# Kill subprocessos.killpg(self._eplus_process.pid, signal.SIGTERM)self._episode_existed = Falsedef _run_eplus_outputProcessing(self):eplus_outputProcessing_process = \subprocess.Popen('%s'% (self._eplus_path + '/PostProcess/ReadVarsESO'),shell=True,cwd=self._eplus_working_dir + '/output',stdout=subprocess.PIPE,stderr=subprocess.PIPE,preexec_fn=os.setsid)def _assembleMsg(self, version, flag, nDb, nIn, nBl, curSimTim, Dblist):ret = ''ret += '%d' % (version)ret += ' 'ret += '%d' % (flag)ret += ' 'ret += '%d' % (nDb)ret += ' 'ret += '%d' % (nIn)ret += ' 'ret += '%d' % (nBl)ret += ' 'ret += '%20.15e' % (curSimTim)ret += ' 'for i in range(len(Dblist)):ret += '%20.15e' % (Dblist[i])ret += ' 'ret += '\n'return retdef _disassembleMsg(self, rcv):rcv = rcv.split(' ')version = int(rcv[0])flag = int(rcv[1])nDb = int(rcv[2])nIn = int(rcv[3])nBl = int(rcv[4])curSimTim = float(rcv[5])Dblist = []for i in range(6, len(rcv) - 1):Dblist.append(float(rcv[i]))return (version, flag, nDb, nIn, nBl, curSimTim, Dblist)def _get_eplus_run_info(self, idf_path):ret = []with open(idf_path, encoding='ISO-8859-1') as idf:contents = idf.readlines()# Run periodtgtIndex = Nonefor i in range(len(contents)):line = contents[i]effectiveContent = line.strip().split('!')[0]  # Ignore contents after '!'effectiveContent = effectiveContent.strip().split(',')[0]# Remove tailing ','if effectiveContent.lower() == 'runperiod':tgtIndex = ibreakfor i in range(2, 6):ret.append(int(contents[tgtIndex + i].strip().split('!')[0].strip().split(',')[0].strip().split(';')[0]))# Start weekdayret.append(WEEKDAY_ENCODING[contents[tgtIndex + i + 1].strip().split('!')[0].strip().split(',')[0].strip().split(';')[0].strip().lower()])# Step sizeline_count = 0for line in contents:effectiveContent = line.strip().split('!')[0]  # Ignore contents after '!'effectiveContent = effectiveContent.strip().split(',')if effectiveContent[0].strip().lower() == 'timestep':if len(effectiveContent) > 1 and len(effectiveContent[1]) > 0:ret.append(int(effectiveContent[1].split(';')[0].strip()))else:ret.append(int(contents[line_count + 1].strip().split('!')[0].strip().split(',')[0].strip().split(';')[0]))breakline_count += 1return tuple(ret)def _get_one_epi_len(self, st_mon, st_day, ed_mon, ed_day):return get_delta_seconds(YEAR, st_mon, st_day, ed_mon, ed_day)@propertydef start_year(self):return YEAR@propertydef start_mon(self):return self._eplus_run_st_mon@propertydef start_day(self):return self._eplus_run_st_day@propertydef start_weekday(self):return self._eplus_run_st_weekday@propertydef env_name(self):return self._env_name@propertydef max_res_to_keep(self):return self._max_res_to_keep@max_res_to_keep.setter  # setter装饰器,调用后进行该预处理def max_res_to_keep(self, value):self._max_res_to_keep = valuedef get_abs_path(rel_path):return_path = rel_pathif rel_path[0] != '/':return_path = os.getcwd() + '/' + rel_path  # os.getcwd() return to current work directoryreturn return_pathdef init_model(env_name,eplus_path,weather_path,bcvtb_path,base_idf_path,add_idf_path,variable_path):idf_env_path = base_idf_path + '.env'# abs patheplus_path = get_abs_path(eplus_path)weather_path = get_abs_path(weather_path)bcvtb_path = get_abs_path(bcvtb_path)base_idf_path = get_abs_path(base_idf_path)add_idf_path = get_abs_path(add_idf_path)variable_path = get_abs_path(variable_path)idf_env_path = get_abs_path(idf_env_path)# Create EnergyPlus Env# env_creator = creator.EplusEnvCreator()create_env(base_idf_path, add_idf_path)# init EplusEnv()changban_env = EplusEnv(eplus_path,weather_path,bcvtb_path,variable_path,idf_env_path,env_name,)return changban_env

UseEplusModel.py

from EplusUtils import init_modelif __name__ == '__main__':# config pathsenv_name = 'myenv'eplus_path = 'software/EnergyPlus-8-7-0/'  # ep安装路径bcvtb_path = 'software/bcvtb'  # bcvtb安装路径weather_path = 'weather.epw'  # 天气model_path = 'models/eplus/flow/'base_idf_path = model_path + 'changban_flow.idf'add_idf_path = model_path + 'add_flow.idf'variable_path = model_path + 'variables_flow.cfg'# init energyplus envchangban_env = init_model(env_name,eplus_path,weather_path,bcvtb_path,base_idf_path,add_idf_path,variable_path)# env resettime, states, end = changban_env.reset()# actions valueactions = [1]while not end:time, states, end = changban_env.step(actions)step_num = step_num + 1print('step:', step_num)changban_env.end_env()

python控制EnergyPlus方法(linux)相关推荐

  1. linux除了eeprom其他的保存方法,linux的EEPROM的读写控制.doc

    毕业设计[论文]题目:基于linux的EEPROM的读写控制毕业论文(设计)原创性声明 本人所呈交的毕业论文(设计)是我在导师的指导下进行的研究工作及取得的研究成果.据我所知,除文中已经注明引用的内容 ...

  2. xbox手柄usb连接linux python控制

    xbox手柄usb连接linux python控制 手柄在linux中叫joystick 首先插上手柄,打开目录/dev/input,ls看到里面以js0,js1等文件就是手柄的输入. 用这个代码. ...

  3. python控制手机自动刷新闻_Python脚本利用adb进行手机控制的方法

    一. adb 相关命令: 1. 关闭adb服务:adb kill-server 2. 启动adb服务 adb start-server 3. 查询当前运行的所有设备 adb devices 4. 可能 ...

  4. linux下运行python_在Linux命令行终端中使用python的简单方法(推荐)

    Linux终端中的操作均是使用命令行来进行的.因此,对于小白来说,熟记几个基本的命令行和使用方法能够较快的在Linux命令行环境中将python用起来. 打开命令行窗口 打开命令行窗口的快捷键如下: ...

  5. python控制电脑屏幕_Python简单实现控制电脑的方法

    本文实例讲述了Python简单实现控制电脑的方法.分享给大家供大家参考,具体如下: 1.windows 下,CMD的一些命令: dir:列出当前的所有文件 time:打印当前的时间 tree:列出当前 ...

  6. linux 下载python命令_Linux下修改Python命令的方法示例(附代码)

    本篇文章给大家带来的内容是关于Linux下修改Python命令的方法示例(附代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. Linux默认python命令指向的是/usr/bi ...

  7. COI实验室技能:python控制相机的方法——采集、处理、显示、实时

    COI实验室技能:python控制相机的方法--采集.处理.显示.实时   本文介绍如何利用python控制办公摄像头.工业相机和科研相机.将数据采集和处理统一到python代码中.   主要围绕解决 ...

  8. python控制电脑程序,Python简单实现控制电脑的方法

    本文实例讲述了Python简单实现控制电脑的方法.分享给大家供大家参考,具体如下: 1.windows 下,CMD的一些命令: dir:列出当前的所有文件 time:打印当前的时间 tree:列出当前 ...

  9. python实现摄像头拍照_使用Python控制摄像头拍照并发邮件

    o1 前言 为什么会有写这个程序的想法呢? 最初的想法是写一个可以用电脑前置摄像头拍照的程序,在舍友使用你电脑的时候,不经意间获取到一大堆奇葩舍友的表情包. 然后我又突发奇想,要不搞个开机启动吧,这样 ...

  10. python __reduce__魔法方法_Python魔法方法指南

    (译)Python魔法方法指南 简介 本指南归纳于我的几个月的博客,主题是 魔法方法 . 什么是魔法方法呢?它们在面向对象的Python的处处皆是.它们是一些可以让你对类添加"魔法" ...

最新文章

  1. [HAOI2018]染色
  2. linux删除U盘分区、创建分区和格式化
  3. sdut 2107 DFS
  4. 【Flask】自定义转换器
  5. rust大油田分解机_低渗油田油井反向调驱(堵水)技术:单井平均含水率从95.6%降至53.65%,单井平均日产油从0.115t上升至1.32t...
  6. 创业者具备的五大技能_一、如今大学生创业需要具备哪些知识与技能?
  7. “618”台前幕后的那些事
  8. Ruby中的字符串与符号
  9. 空间参考不存在_空间实景三维信息如何服务于BIM应用
  10. UI:target-action设计模式、手势识别器
  11. 图像处理结果的度量 —— SNR、PSNR、SSIM
  12. 碱性干电池的内阻测试方法_电池内阻怎么测
  13. html中src中的url,HTML 中的 href\src\url
  14. python博弈论代码_科学网—两篇关于社交网络和博弈论的论文及源代码分享 - 陈俊东的博文...
  15. 韩国服务器性能排行榜,2019韩国云服务器排名
  16. React Native_React Native组件(ListViewFlatListSectionList)
  17. 从病毒开始聊聊那些windows下大杂烩
  18. 初学java者写家庭收支账本
  19. 高级搜索:搜索指定网址
  20. Oracle Flashback 知行合一

热门文章

  1. C++ 软件备份(拷贝构造函数)
  2. vue实现登录验证码
  3. android screenshot流程,APP中,Screenshot的设计要领和各发布渠道的要求
  4. 百度logo识别SDK108问题解决
  5. 无法打开计算机的组策略,本地组策略编辑器打不开?Win7本地组策略编辑器无法打开的解决方法...
  6. VAD自适应算法降噪控制毕业论文【matlab】
  7. bandicam安装注册
  8. 基于stc89c58的万年历设计
  9. 【网络技术题库梳理11】第三道大题——DHCP报文
  10. HTML里css画蝴蝶,纯css3制作煽动翅膀的蝴蝶的示例