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 result type, or types, to export. Enter a single type without braces, or several as an Excel array, for example {"mean", "stddev"}. If omitted, the default is "finalValue" for deterministic models and "mean" for simulation models.
The result types you can request include "finalValue", "mean", "stddev", "min", "max", "stderr", "variance", "skewness", and "kurtosis". Common synonyms are also accepted — for example, "average" for "mean" and "stdev" for "stddev".
Merging results. Multiple PsiExport() functions may point to different outputs while passing the same src_name. When the same src_name is shared, all results are merged into a single exported file containing the union of the result types requested by every function. If a result type was not requested for a given output, NULL appears in that column for that record. For example, given PsiExport("src", …, {"mean", "stddev"}) and PsiExport("src", …, {"mean"}), the exported file contains both a mean and a stddev column, with NULL in the stddev column for the second output's record.
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, one in cell g18 and one in cell g19, 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.
