Running simultaneous computation in mathematica

Click For Summary

Discussion Overview

The discussion revolves around issues related to running heavy computations in Mathematica, specifically the inability to perform additional calculations while a heavy computation is ongoing and the challenge of retaining results after closing and reopening the software. Participants explore potential solutions and workarounds for these problems.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that Mathematica's kernel processes one calculation at a time, which prevents simultaneous computations.
  • Another participant mentions that Mathematica version 8 introduced limited parallel computing capabilities, but questions whether this meets the user's needs.
  • There is a suggestion that purchasing additional kernel licenses may allow for multiple computations to run simultaneously, though this remains unverified by participants.
  • Participants discuss the limitation of Mathematica not retaining the state of computations after closing, suggesting alternatives like using DumpSave or manually creating assignment statements to restore variables.
  • One participant proposes saving results to a file and loading them upon restarting Mathematica as a solution to retain computed results.
  • Another participant suggests using the Put and Get functions for saving and retrieving data, although they caution about potential performance issues with large datasets.
  • A later reply recommends using Save and Get for saving matrices and other objects to avoid recalculating them in future sessions.

Areas of Agreement / Disagreement

Participants generally agree on the limitations of Mathematica regarding simultaneous computations and the retention of results, but multiple competing views and proposed solutions remain without consensus on the best approach.

Contextual Notes

Some solutions depend on the specific version of Mathematica being used, and there may be limitations based on the size of data being handled. The discussion does not resolve the effectiveness of the suggested methods.

yashar
Messages
31
Reaction score
0
hi
when i run a heavy computation on mathematica in the same time even if i want to calculate 2+2 , mathematica does not calculate it until calculating of heavy computation finishes.
why?

another problem is that when i do a heavy computation and obtain results , after closing mathematica and opening it again mathematica do not remember its calculations in that notebook.
for example if the result of calculation is a matrix then after closing and opening of mathematica for manipulating that matrix , for example multiplication it by itself i have to run the heavy computation again and obtain the resulting matrix again.
is there any solution that mathematica without running again a notebook remember calculation of that notebook?
sorry for my bad English writing.
thanks
 
Physics news on Phys.org
Mathematica has a front end, which formats and displays results, and a kernel, which does almost all the computation. The kernel does one calculation at a time. That is why you can do <shift><enter> on two or more expressions on the screen and those will be passed to the kernel to complete when the kernel has finished the previous calculation.

With version 8 there have been some limited abilities to do parallel calculations
http://reference.wolfram.com/mathematica/guide/ParallelComputing.html
but I suspect this may not be what you want done.

There is one other possible solution. You can purchase a license for additional kernels from Wolfram. Then I believe you can run all the kernels you have license for at the same time. Or you can purchase Premier Support. That should provide you with one additional license and you might be able to run both of those at the same time. I have never tried this so you should make certain this will do what you need before paying your money.

For your second question, it is true that Mathematica does not remember all the state of a computation. You might look at the documentation for DumpSave and see if that will accomplish what you need.

You can manually create assignment statements in your notebook. Then the next time you start the notebook you can evaluate those assignment statements to restore the value of variables.

Mathematica, and almost all other software, forgets all current work, all open windows, all open files, all variable assignments, etc. when you exit and restart, even when you reload a saved file. I wonder if this might be because Windows and window software had a long history of bugs and errors and being unstable and the programmers thought they might make this somewhat less visible and a problem if they did not restore everything after a shut down or restart and made you manually begin again.

Good mathematics is more important than good English, just as long as we can both understand. Your use of English is almost certainly better than my use of any other human language. For that I am also sorry.
 
yashar said:
hi
is there any solution that mathematica without running again a notebook remember calculation of that notebook?
sorry for my bad English writing.
thanks

How about saving the results to a file then just loading it's contents when you start up again?
 
jackmell said:
How about saving the results to a file then just loading it's contents when you start up again?

Bill Simpson thanks for your comments.

jackmell i do not know how to do that.

however i think i should define the results of computation in new variables.
for example if after a computation i obtain a matrix i define it for another variable.
 
Try Put and Get although if it's a lot of data, might be slow:

mymatrix = {{1, 2}, {3, 4}};
Put[mymatrix, "myfile.dat"]
fromfile = Get["myfile.dat"]

There are also other file operations to use to save and retrieve data. Look into them with the help function.
 
A better solution is to use Save and Get. After doing the heavy calculation, you have the new matrix - suppose it is called M. Use

Save["MyMatrix.m",M]

The next time you run the notebook, add:
Get["MyMatrix.m"]

The matrix will be loaded without having to recalculate. You can save multiple objects:

Save["MyStuff.m",{M,N,P,Q,R}]
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 13 ·
Replies
13
Views
8K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K