Difference between revisions of "Save results"
Line 1: | Line 1: | ||
− | Normally Analytica must recompute any result | + | Normally when you restart a model or change an input, Analytica must recompute any result you ask to view. When a result takes a long time to compute, it is sometimes useful to save the result in the model, so that |
− | * you | + | * you can see the result when you restart the model without having to wait to recompute it, |
− | + | * you can compare a new result against the original version after you change inputs | |
− | * you can compare | ||
− | It's also | + | It's also sometimes helpful to save data imported from a CSV file or a spreadsheet into a model so that you don't have to reimport it whenever you start the model. And when you share the model with someone else, you don't need to remember to send them the data files too. |
− | Here's how to save a result, say | + | Here's how to save a result, say Variable X, in the model: |
− | # Create a place to store the result, say | + | # Create a place to store the result, say Variable Saved_X. |
# Create a button called "Save X" and set its [[OnClick]] Attribute to: | # Create a button called "Save X" and set its [[OnClick]] Attribute to: | ||
− | + | ::<code>Saved_X := X<\code> | |
− | Whenever you want to, just click button "Save X". It will compute X if needed and save a copy into Saved_X. | + | Whenever you want to, just click button "Save X". It will compute X if needed and save a copy into Variable Saved_X. |
− | If you want to save the prob value ( | + | If you want to save the [[Evaluation mode|prob value] (rather than the mid value), set the [[OnClick]] Attribute of "Save prob X" to: |
− | + | ::<code>Saved_Prob_X := Sample(X)<\code> | |
− | Note that Saved_X will contain only the Mid value and | + | Note that Saved_X will contain only the Mid value and Saved_prob_X contains only the Prob value in this second example. There's no simple way to give it both Mid and Prob values. |
− | If you change an index used by a saved result, it may affect that result. For example, suppose Samplesize = 1000 when you click "Save prob X", and | + | If you change an index used by a saved result, it may affect that result. For example, suppose <code>Samplesize = 1000<\code> when you click "Save prob X", and then increase <code>Samplesize = 2000<\code>. This changes the length of the <code>Run<\code> Index from 1000 to 2000, and the second 1000 elements of Saved_prob_X will be Null, untill you click button "Save prob X" again. |
+ | |||
+ | If you want to save an array result and make sure it doesn't get affected by future changes to its indexes, you can save the indexes at the same time that you save the array: | ||
+ | ::<code>Saved_X := X<\code> |
Revision as of 01:27, 19 January 2024
Normally when you restart a model or change an input, Analytica must recompute any result you ask to view. When a result takes a long time to compute, it is sometimes useful to save the result in the model, so that
- you can see the result when you restart the model without having to wait to recompute it,
- you can compare a new result against the original version after you change inputs
It's also sometimes helpful to save data imported from a CSV file or a spreadsheet into a model so that you don't have to reimport it whenever you start the model. And when you share the model with someone else, you don't need to remember to send them the data files too.
Here's how to save a result, say Variable X, in the model:
- Create a place to store the result, say Variable Saved_X.
- Create a button called "Save X" and set its OnClick Attribute to:
Saved_X := X<\code>
Whenever you want to, just click button "Save X". It will compute X if needed and save a copy into Variable Saved_X.
If you want to save the [[Evaluation mode|prob value] (rather than the mid value), set the OnClick Attribute of "Save prob X" to:
Saved_Prob_X := Sample(X)<\code>
Note that Saved_X will contain only the Mid value and Saved_prob_X contains only the Prob value in this second example. There's no simple way to give it both Mid and Prob values.
If you change an index used by a saved result, it may affect that result. For example, suppose Samplesize = 1000<\code> when you click "Save prob X", and then increase Samplesize = 2000<\code>. This changes the length of the Run<\code> Index from 1000 to 2000, and the second 1000 elements of Saved_prob_X will be Null, untill you click button "Save prob X" again.
If you want to save an array result and make sure it doesn't get affected by future changes to its indexes, you can save the indexes at the same time that you save the array:
Saved_X := X<\code>
Enable comment auto-refresher