Hello everyone,
I am trying to use parralel computing to run the same program (EnergyPlan) simultaneously. EnergyPlan is a energy system tool that computes whether a given energy system is able to supply the given demand. I would like to run different energy system configurations (e.g. different amounts of wind and solar power) and use an optimization algorithm to find the best setup for the given demand.
The program is set up that it opens EnergyPlan using the "system" command to execute EnergyPlan. Afterwards the results of each run are retrieved compared to see, which system scores highest. When I run the program in a simple for-loop, it works without problems. However, when I change the for-loop to a parfor-loop, the opened EnergyPlan displays the error "I/O error 32". According to sources I found this error indicates a sharing violation. The first EnergyPlan program is executed (unfortunately the program pops up so I can always see when a run is performed) just fine and it closes again. However, there is a second EnergyPlan opened while the first one is still open and this one shows the beforementioned error. According to EnergyPlan.eu the tool can be run in parallel and other researchers have done so succesfully using python or java. Therefore, I don't know why this error occurs with Matlab.
Does anyone know how to circumvent this issue? Any help would be much appreciated.
Regards,
Markus
Minimum working example (provided EnergyPlan and toolbox for Matlab are installed):
%%Paths and Folder definitions
%Path where it is located EnergyPLAN executable.
dir.energyPlanPath = 'energyPLAN.exe';%Path of reference file.
dir.inputFilePath = 'energyPlan Data\Data\Denmark2030Alternative.txt';%Folder where will be output resulf of EnergyPLAN.
dir.outputFolder = 'Outputs\';REvalue = 1e4*rand(10,2);result = zeros(size(REvalue,1),1);parfor i = 1:length(REvalue) % Call EnergyPlan
annualData = energyPlan(dir.energyPlanPath,... dir.inputFilePath,dir.outputFolder,... 'input_RES1_capacity=', REvalue(i,1),... % 1st variable to be changed 'input_RES2_capacity=', REvalue(i,2)); % 2nd variable to be changed
result(i) = annualData(55); % random value taken out
end
Best Answer