PsiExport (src_name, src_type, connection, data_range, result)
Use PsiExport() to save the results of a solved optimization, simulation, data science or calculation model to an external file. It is the export counterpart to PsiDataSrc(): where PsiDataSrc() reads data into your model from a file, PsiExport() writes your model’s results out to one.
PsiExport() defines a data source for exporting the results of a model data_range. It never takes part in model evaluation and is used only in RASON conversion. Like PsiDataSrc(), it does not return a value or calculate anything in Excel; it takes effect when you deploy your model to RASON and solve it. The generated RASON includes an export data source built from the arguments you supply, and the file is created with the results when the model is solved.
Enter one PsiExport() function for each file you want to create, in any empty cell:
src_name— A name for the export. Example:"con_data".src_type— The file type to create,"csv". Maps to the data source type.connection— The file to write the results to. Example:"ProductMix_con.txt". Maps to the data source connection.data_range— The cells whose solved results are written to the file. This can be a single result cell or a range covering several — even results from different variables, constraints, or outputs. All of the results in the range are saved together in the one file named in connection. Only cells that hold model results are exported; any other cells in the range are ignored.result(Optional) — The name, or names, given to the exported results in the RASON conversion. Accepts a single name or a brace array, for example{"chassis", "screens"}. If omitted, no result names are supplied and the conversion assigns them.
Example 1
Saves the decision variables (Number to Build) and the objective (Total Profit) to their own files, and saves two constraint values (Parts Used) together in a third.
PsiExport("vars_data", "csv", "ProductMix_vars.txt", C14:E14)
PsiExport("obj_data", "csv", "ProductMix_obj.txt", G24)
PsiExport("con_data", "csv", "ProductMix_con.txt", G18:G19)
The con_data range covers two constraints, so both values appear together in ProductMix_con.txt.
Example 2
A simulation model saves results the same way. Here one export saves two uncertain variables together, and the other saves a row of outputs.
PsiExport("yield_var", "csv", "Yield_vars.txt", H28:I28)
PsiExport("yield_out", "csv", "Yield_outs.txt", H37:Q37)
Both uncertain variables in the yield_var range are written to Yield_vars.txt.
