I am linking a third party software to UQLabs using UQLink. The third party software is called Hi-sAFe which is used to simulate interactions between trees and crops for agriculture. The software uses multiple input files and output files which are all specified in a simulation file, along with some extra simulation parameters. In order to run the simulation, these input and output files are not explicitly specified in the execution command. The command only includes a simulation file which has the names of the input files in it.
When I try to evaluate the model for some specific values (just for testing), I get the following warning:
“Warning: Third party software returned an error for run #1: Returning NaN in the corresponding output”
I originally thought this was an issue with my output parser, however after running my output parser directly on the output file, I can confirm it works correctly. Thus, it has led me to believe that the issue comes from the fact that the input/output file is not specified in the execution command. This would make sense as UQLink would not be able to run the simulation changing the input file name. Is this correct of me to assume?
If that is the case, I have considered solving this by opening the simulation file and for each iteration changing the name of the input file for the one with the altered values generated by the code. Is this something I should try?
Any recommendations that anyone has would be great, thank you!
Dear @elisara1000
Do I understand correctly that you need to change the “simulation file” and the actual input file that is then specified in the “simulation file”? I think you can do this by making both files template files and specifying multiple input files for UQLink as described in section 2.7.6 of the manual:
And did you check if the command specified in the model options (Mopts.Command
) is correct and Hi-sAFe get actually executed?
Best regards
Styfen
Hi Styfen,
Thank you for your response!
The simulation file just lists where all the input files for my simulation are. The template I made is for the input file, referenced by the simulation file, which I wish to use as input parameters. So I did not make a template for the simulation file. Would this work? From my understanding the template specifies the parameters which should be changed on each iteration. But can I specify two input files 1) the simulation file which would have to change the name of the input file to the one generated by UQLabs and 2) the input file with the list of parameters to alter? I assumed the markers placed for the parameters could only represent numeric values so this wouldn’t work. Is this a correct assumption?
I did ended up making a fix for it which is now working so I do not have this issue anymore. First, I created a script which opens the simulation file, finds the input file, and changes it to the input file generated by UQLabs. Then, I modified “uq_wrapper_uqlink.m” to insert my fix before the command is executed. This works when I the model is evaluated once. I am now having some confusion as to where the generated input file is stored. It seems that it is in the root folder where the code is running, and after one run, the input file is archived if Modelopts.Archiving.Action is set to ‘save’. However for some reason on the second run, I get an issue with my simulation software not finding the input file, even though I can see that it has been generated and is also in the root folder. Would you have any hints as to where the generated files are stored during runtime?
Thanks again for your comments.
Kind regards,
Elisa
Dear @elisara1000
Yes, what you describe in the first paragraph is what I would suggest. Since you know how UQLink changes the name of the input file, you can put a marker in the simulation file and also specify it as a template file. You are correct in assuming that you need to format the marker correctly. You can specify the format as follows: Mopts.Format = {'%1.8f', ..., '%06d'}
(Section 2.7.4 in the manual). Note that there is a format specifiers for each input variable. The '%1.8f'
should suffice for the variables of the input file, which (I assume) requires floating point numbers, and the '%06d'
formats the generated file ID of the input file which you need in the simulation file. I think the '%06d'
is what UQLink does by default. In case you’re not familiar with formatting strings you can check out:
Regarding your second paragraph, UQLink should generate it in the modelopts.ExecutionPath
directory (Section 2.7.2 in the manual). Have you tried specifying it explicitly?
However, I would first try the other approach we discussed. That seems to me to be a less cumbersome way.
Best regards
Styfen
Dear @elisara1000
we have discussed your problem and it seems that it is more difficult than I first thought. The formatting refers only to the random variables and it is not possible to format other values than these variables. So the best thing to do is to update the uq_wrapper_uqlink.m
file as you did.
Again, about your problem with the input file path: It sounds strange to me that you can see the input file in the expected directory, but your simulation software cannot. Did you check that the input file name was updated correctly in the simulation file after the first run, and that all paths are set correctly?
Keep us informed about your problem so we can find a solution.
Best regards
Styfen
Dear @styfen.schaer
Yes, the input file is correctly updated in the simulation file after the first run, and I think all the paths are correct especially because on the first run it works. Nevertheless, I will look further into it today and will keep you informed.
Thank you again for your support!
Best,
Elisa
Dear @styfen.schaer
Apologies for the delay with the response.
It turns out this is a problem with the third party simulation software. It requires input files to be in a specific location. Where are the input files generated based on the template? Or more specifically, do you know if there is a way for me to define where the generated input files should be stored during execution?
Kind regards,
Elisa