04-18-2017 09:04 AM
Hello,
I use the ExperiementManager to launch several simulations.
I want to save my model after each simulation run. Without distributed simulation that works perfectly but when I want to use distributed simulation it just saves the last one.
So I try to catch the endSim to save my model, but...
Is there a way to catch the endSim before the "remoteEndSim" ?
Solved! Go to Solution.
04-19-2017 04:20 AM
Hello rpinon,
have you checked out the "save-model" option of the ExperimentManager? Maybe it's what you need:
Best Regards,
Alex
04-19-2017 04:26 AM
Hello,
Yes, I use it for a non distributed simulation and It works.
But with the distributed mode it saves only the last experience.
Regards
04-19-2017 05:45 AM
OK, then how about the user-evaluation-method (also under advanced settings)? This should work. I've tried it (but I used distributed simulation only on my local computer, not on several machines). Maybe you used an invalid folder/filepath? The folder must already exist for the saveModel-function. If you don't provide a specific filepath, it may save the model, but I don't know where (definitely not at the location suggested by the documentation...). Try this code:
-- After an observation you can perform special evaluations. (localExp, localRun: integer; unused: integer /*always 0*/) is sDestFolder : string; do -- save model-file for each observation sDestFolder := "C:\xxx\ExpModels"; saveModel(to_str(sDestFolder, "\Model_",localExp,"_",localRun,".spp")); end;
04-19-2017 05:56 AM
Hello
If needed you can add the following to create a folder to save the files into.
if NOT ExistsFile(sDestFolder) then
startExtProc(To_Str("cmd.exe /C mkdir \"", sDestFolder, "\""), false, true);
end;
JamesM
04-19-2017 07:19 AM
04-19-2017 08:32 AM
In this model, the attribute "ModelDir" is an empty string, so you create an invalid filepath and "savemodel" is not executed successfully. When I provide a valid filepath and directly use the savemodel-function, your model works and saves like a charm for me, with and without distribution.
If it still doesn't work: what Patch-Version do you have?
04-19-2017 09:05 AM
I use Plant simulation 13.0.0.
And i get my mistake.
in my "evaluation method", I use the variable "currExpNo" and with distributed simulation "currExpNo" doesn't exist or doesn't change.
I change to "localExp" and now it work.
-- After an observation you can perform special evaluations. param localExp, localRun: integer, unused: integer /*always 0*/ print "EVAL Experiment",localExp," Observation: ",localRun var ModDirLoc := to_str(ModelDir,"\\",savefile,localExp,".spp") executeSilent("param modStr:string saveModel(modStr,false,false)",ModDirLoc)
thanks a lot for your answers