Sorry for my late reply, but it took a bit time to get time profile of the code.
First of all, I inserted @timeit
for RecordCSV()
to get time profile of CSV writing. Since we already have time profile of all "report_results"
, we simply figure out how much time spent for RecordPlot()
:
function ExpansionModel()
@timeit to "build_model" begin
My model here...
end
@timeit to "solve_model" begin optimize!(Expansion_Model) end
@timeit to "report_results" begin
@timeit to "write_to_CSV" begin RecordCSV(some inputs here...) end
RecordPlot(some inputs here...)
end
end
And, I got the following results:
So, plotting takes huge amount of time. Then, I was curious if stack plot or bar/line plot was a problem because I am calling Python to create stack plots. To get this, I update the time profile as follows:
function RecordPlot(some inputs here...)
@timeit to "create_Bar_and_Line_plots" begin
for ...
CreateBarLine()
end
end
@timeit to "create_Stack_plots" begin
for ...
for ...
CSV.write(path_to_folder)
scriptdir = @__DIR__
pushfirst!(PyVector(pyimport("sys")."path"), scriptdir)
pyimportjulia = pyimport("CreateDisStack")
pyimportjulia.CreateDisStack(dispatchpath, filename)
end
end
end
end
And, I got the following results:
However, I also realized that this is not always the case. For example, when I solved this model in one trial, I got the following time profile:
It still does not make sense to me that plotting and writing to CSV files takes this amount of time, but I was surprised to see big difference from the previous time profiles. Note that results are exactly the same. I am not changing the model at all. So, every time I solve the model, I get the same optimal solutions, CSV files, and plots. Note also that total size of these figures and CSV files is at most 9 MB.
I am in contact with HPC as well. We are trying to figure out whether this is an issue related to Julia/Python or HPC.
I also wanted to share a warning with you. I have no idea if this is related to slow processing of outputs, but I just wanted to share:
Sorry, I bombarded lost of feedbacks. Hope that these are useful for you to get some insights.
Kind regards