Message Boards Message Boards

1
|
12830 Views
|
7 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Hold Dynamic updates until after changes have been made to all controls

Posted 11 years ago
I have a notebook that has a very large number of sliders within a manipulate and I want to have Mathematica hold off on recalculating the values of the various compuations till after I have made all the adjustments.  The reason for this is it takes 1.5 min for the calculation to run and I sometimes have to make 5+ changes to the sliders so it would be nice to be able to make all the adjustments I want to make and then envoke the re-evaluation of the notebook.
POSTED BY: Tim Heger
7 Replies
Posted 11 years ago
Works great!  Thanks to you both for your help.

Tim
POSTED BY: Tim Heger
This very neat, Michael, excellent usage of syntax and functionality.
POSTED BY: Vitaliy Kaurov
I often do this sort of thing with a trick.  I use a button to change a dummy variable, called update for example.  I put a dummy expression, update, in the body of the Manipulate, which will make the body be updated whenever the variable update changes value.  Finally, I put only the variables whose changes should cause an update in the list of TrackedSymbols, which should include update, or else clicking the button will have no effect.
Manipulate[
update;
{a, b},
{a, 0, 1}, {b, 0, 1},
Button["update", update = 1 - update],
{{update, 0}, ControlType -> None},
TrackedSymbols :> {update}
]
POSTED BY: Michael Rogers
Michael, I like this approach. I think it is cleaner than mine because we do not introduce an extra Dynamic inside Manipulate in addition to its default one. Thanks for sharing!
POSTED BY: Vitaliy Kaurov
Thanks, Vitaliy!  Each of ours has a different functionality so they are both good in their own ways.  Here's a variation on yours that uses Refresh instead of Dynamic (and takes advantage of the default Dynamic applied by Manipulate):
Manipulate[
Refresh[{a, b}, Sequence @@ s],
{a, 0, 1, Appearance -> "Labeled"},
{b, 0, 1, Appearance -> "Labeled"},
{{s, {None}}, {{} -> "ON", {None} -> "OFF"}}]
POSTED BY: Michael Rogers
If you wanted to do this for just a single Manipulate, I think it's simplest just to set ContinuousAction -> None, as mentioned in the Manipulate docs.
Manipulate[{a,b}, {a,0,1}, {b,0,1}, ContinuousAction -> None]



One reason you might want to do this explicitly via an approach like Michael's is that you can adjust the controls of several different Manipulates, and then have a single update button to trigger all of them, rather than having to trigger them one at a time.
Manipulate[update; a, {a,0,1}, TrackedSymbols :> {update}]
Manipulate[update; b, {b,0,1}, TrackedSymbols :> {update}]
update = 0; Button["update", update = 1 - update]
POSTED BY: Lou D'Andria
Solution that came to my mind is TrackedSymbols. They can control what is and what is not updated.
Manipulate[
Dynamic[{a, b}, TrackedSymbols -> s],
{a, 0, 1, Appearance -> "Labeled"},
{b, 0, 1, Appearance -> "Labeled"},
{{s, {}}, {All -> "ON", {} -> "OFF"}}]

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract