Message Boards Message Boards

0
|
2864 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Abort calculation and get unfinished result

Posted 4 years ago

Hello everyone, I am using Mathematica quite often to do calculations over nested tables with many iterators/parameters such as, generally speaking,

Table[f[a,b,c,d,e],{a,a_min,a_max},{b,b_min,b_max},{c,c_min,c_max},{d,d_min,d_max},{e,e_min,e_max}]

In this particular case, I have to do this since I couldn't find a way to make the built-in fit functions work for a very restricted parameter space, so I had to design a brute-force least-square fit myself, but that's another story.

I was now wondering, since such evaluations can naturally take very long, if there is any way of aborting a function in Mathematica but still getting the (unfinished) result. In case of a table, it should be pretty obvious what such a result could be: just a table with the first values of f[a,b,c,d,e] where i.e. only the parameter a has taken all values a_min to a_max and the other parameters are only evaluated for values close to their minimal values, i.e. the final table has a lot of empty entries.

I'd be grateful for any ideas.

3 Replies

Please add cross-post links to this and the corresponding MSE post.

POSTED BY: Daniel Lichtblau
Anonymous User
Anonymous User
Posted 4 years ago

Mathematica now has several ways to do this.

You could write a For loop and optional Break for each leg.

You can do timed calculation; storing the Table results in an array

You can use a number of debug features to "step into code" thus interrupting it (partial values). ie, breakpoint

And as the person above mentioned - parallelization is yet another angle.

MAYBE THE BEST WAY is that when you build your table your evaluating expressions. The expression in the table could check to see if it is time to quit according to yourself.

POSTED BY: Anonymous User
Posted 4 years ago

Hi Sebastian,

You could try ParallelTable if you are able to run multiple kernels. For an interruptible solution take a look at this MSE post.

POSTED BY: Rohit Namjoshi
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