3
$\begingroup$

I'm having a simple problem. Here is the code

Table[Simplify[DifficultFunction[i],assumptions], {i,DifficultSet[1, 2]}]

the correct and simplified answer is

enter image description here

while if I try to parallelize:

Table[Simplify[DifficultFunction[i],assumptions], {i,DifficultSet[1, 2]}]//Parallelize

what I get is

enter image description here

which is still correct but not simplified. I used $Assumptions, but even if i put them as the se second argument of Simplify nothing happen. In my case it would be crucial to let different kernel simplify different expressions since in some cases this is the operation that requires a lot of time. How can I do?

EDIT

The strange point is that if I use

IntermediateResult= Table[DifficultFunction[i], {i,DifficultSet[1, 2]}]

and then

ParallelTable[Simplify[i,assumptions],{i,IntermediateResult}]

it works. How is this possible?

$\endgroup$
  • $\begingroup$ A concrete example would make this problem much easier to work with. $\endgroup$ – Mr.Wizard Dec 19 '16 at 16:34
  • $\begingroup$ It's hard to make concrete examples: my file contains very complicated functions, and if I try to do a MWE it boils down to a triviality. However the edit I did should be independent on what are the definitions of my functions. $\endgroup$ – MaPo Dec 19 '16 at 17:17
  • 2
    $\begingroup$ I understand that creating a minimum working example can be difficult. Nevertheless I think it will be hard to answer your question without one unless someone has already experienced and analyzed this problem. I hope for you that is the case. $\endgroup$ – Mr.Wizard Dec 19 '16 at 17:19
1
$\begingroup$

There can be several causes.

$Assumptions is not active on parallel kernels unless you explicitly set it:

ParallelEvaluate[$Assumptions = ...]

You should explicitly use DistributeDefinitions on any defined symbols that appear in the expression that you assign to $Assumptions. ParallelEvaluate does not auto-distribute before version 10.4 (like most other parallel functions do).

Also keep in mind that the result from Simplify (and many other symbolic functions) may depends on what was previously evaluated. Simplify uses a time limit for trying certain transformations. Whether it reaches that limit depends on the speed of your computer as well as what symbolic results were cached previously. The cache state is not shared between parallel kernels.

$\endgroup$
  • $\begingroup$ Thanks for the reply. I had the suspect that assumptions could not be shered among kernels, so I manully put assumptions in the second argument of Simplify. What astonishes me is what I write afer the EDIT. It seems that if I insert an intermediate step, it works perfectly but this doesn't make any sense. Does it? P.S. My version is 11.0 so I shouldn't have the other issue you mensioned $\endgroup$ – MaPo Dec 19 '16 at 17:27
  • $\begingroup$ @MaPo As Mr Wizard said, without an MWE it's hard to say much ... $\endgroup$ – Szabolcs Dec 19 '16 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.