필터 지우기
필터 지우기

Parfor Loop & EnergyPlus Co-Simulation

조회 수: 3 (최근 30일)
Mohamad Khalil
Mohamad Khalil 2021년 6월 17일
댓글: Mohamad Khalil 2021년 6월 21일
Hello everyone,
I'm trying to run a parfor loop to run the EnergyPlus toolbox co-simulation a bit faster (EnergyPlus Co-Simulation). I tried a lot but I'm getting an error that I'm unable to solve.
Below is my code:
ep=[];
tStart = tic;
i=0;
HVACEnergy = array2table(zeros(25,8));
Blg_Electricity = array2table(zeros(25,8));
Total_Energy = array2table(zeros(25,8));
parfor c=1:8
%%
t = getCurrentTask();
d = fullfile(tempdir, sprintf('worker_%d', t.ID));
if ~exist(d, 'dir'), mkdir(d); end
%%
ep = mlep;
ep.workDir = d;
% Building simulation file
ep.idfFile = 'C:\Users\mak19\Desktop\UBC_PhD\Trial_Two\6-Modeling\1-Trial_One\4-IHDX\DD_Winter_EE.idf';
% Weather file
ep.epwFile = 'C:\Users\mak19\Desktop\UBC_PhD\Trial_Two\6-Modeling\1-Trial_One\4-IHDX\CAN_BC_Kamloops.718870_CWEC.epw';
% Initialize
ep.initialize;
% Simulation length
endTime = 1*24*60*60; %[s]
% Logging
VN = ep.outputSigName;
VN{3} = 'HVAC_Energy';
VN{4} = 'Total_Building_Electricity';
VN{5} = 'Total_Electricity';
logTable = table('Size',[0, 1 + ep.nOut],...
'VariableTypes',repmat({'double'},1,1 + ep.nOut),...
'VariableNames',[{'Time'}; VN]);
% Start co-simulation
ep.start;
iLog = 1;
%%
% The simulation loop
t = 0;
while t < endTime
% Prepare inputs (possibly from last outputs)
u = [20 24 1 1 1 1 1 1 1];
% Get outputs from EnergyPlus
[y, t] = ep.read;
% Send inputs to EnergyPlus
ep.write(u,t);
% Log
logTable(iLog, :) = num2cell([t y(:)']);
iLog = iLog + 1;
i=i+1;
end
% Stop co-simulation process
%%
ep.stop;
%%
delete(ep)
%
HVACEnergy(:,c) = logTable(:,4);
Blg_Electricity(:,c)=logTable(:,5);
Total_Energy(:,c)=logTable(:,6);
end
TotalTime = toc(tStart);
And this is the error I'm getting:
Error using mlep/acceptSocket (line 1144)
Java exception occurred:
java.net.SocketTimeoutException: Accept timed out
at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:135)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
Error in mlep/start (line 289)
obj.acceptSocket;
Many thanks in advance.
Mohamad

채택된 답변

Raymond Norris
Raymond Norris 2021년 6월 18일
I would suggest trying this first with a pool size of 1. If it works, then my guess is that mlep only allows one connection at a time.
  댓글 수: 9
Mohamad Khalil
Mohamad Khalil 2021년 6월 20일
It seems it has something to do with the "socket.cfg"! Although I'm doing as the answer in this post: https://www.mathworks.com/matlabcentral/answers/443270-parfor-energyplus-co-simulation-toolbox, I'm still getting an error. Your support means a lot for me. Thanks.
Mohamad Khalil
Mohamad Khalil 2021년 6월 21일
Is it possible to copy the "mlep" function to the multiple workers in a way that each worker has its own "mlep" function?. I feel might be better rather than all of the workers are using the same "mlep", which might not be supporting the "parfor" loop? Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by