Jump to content
jdoran

Write step + experiments

Recommended Posts

As you can probably tell by the sheer quantitiy of my recent posts, I have been playing around with the experiments quite a lot recently.


It has always annoyed me that experiments don't seem to follow the write step properly. I have several files I write to, except I use the folder trick where I write to a file called: "test\test.csv". The experiments how ever skip the folder directive, and just write to where the Simio project was located. If I have 200 replications in 3 scenarios, I get 600files dumped in that directory, instead of the nice folder tree I setup for these files.


It would be nice if this was fixed.


Attached is an example.


Run it once in interactive view (fast forward if you want)... and it will write into the folder.


Run it in experiment... and there will be a billion files next to the file.


I realise that the Write step is considered a user add-on, but I view it as staple functionality required in all my models, provided by Simio. I also assume that implementing the required changes, may require changes in Simio code too.

WriteStep.zip

Share this post


Link to post
Share on other sites

Hi James,


Not sure if this is still an issue for you, but I was able to fix the write step to maintain any directory structure included in the file element's file path. I've attached the .dll in a .zip file-- you should be able to stick this in your Simio user extensions folder, e.g.

C:\Program Files (x86)\Simio\UserExtensions\TextFileReadWrite\

(Note: this .dll replaces the existing .dll). I've also included the source file with changes in the same zip file (it's actually the FileElement.cs file that requires changing, not the WriteStep.cs file). You can copy this to the source code location. On my machine,

C:\Users\Public\Documents\Simio\Examples\UserExtensions\TextFileReadWrite\

and compile the .dll yourself if you need/want to.


The fix was pretty simple: I just replaced this

 if (String.IsNullOrEmpty(fileDirectoryName) || String.IsNullOrEmpty(fileRoot))
               {
                   fileDirectoryName = simioProjectFolder;
                   fileName = fileDirectoryName + "\\" + fileName;
               }

with this

if (String.IsNullOrEmpty(fileDirectoryName) || String.IsNullOrEmpty(fileRoot))
               {
                   fileName = simioProjectFolder +"\\" + fileName;
                   fileDirectoryName = System.IO.Path.GetDirectoryName(fileName);
               }

 

In the existing example code, fileName gets used if you don't run an experiment, and fileDirectoryName gets used if you do (due to the need to write multiple copies of the "base" file in experiment mode). This fix makes sure that the fileDirectoryName contains the whole "original" path, not just the simioProjectFolder path.


I have not extensively tested this (of course), but for your example model all output files get written to the /test/ directory.


-Adam

TextFileReadWrite.zip

Share this post


Link to post
Share on other sites

Thanks adam, I will try it out.


The reason I want Simio to improve it (or if yours does the trick, adopt that)... is since unlicensed Simio copies will not be able to use that addon/block... which somewhat defeats the purpose of our specific modelling project and team edition license.

Share this post


Link to post
Share on other sites

×