1 | initial version |
It turns out that the problem has nothing to do with scalar vs. vector variable. The bottom line is that PSage()
takes a single STRING as parameter enclosed in quotes. The following (somewhat awkward) modification makes the parallel interface work properly.
from scipy.optimize import rosen
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
rosen(x0)
848.22000000000003
v = [PSage() for _ in range(3)]
w = [x(eval('rosen(%s)'% str(x0))) for x in v]
w
[848.22, 848.22, 848.22]
2 | No.2 Revision |
It turns out that the problem has nothing to do with scalar vs. vector variable. The bottom line is that PSage()
takes a single STRING as parameter enclosed in quotes. The following (somewhat awkward) modification makes the parallel interface work properly.
from scipy.optimize import rosen
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
rosen(x0)
848.22000000000003
v = [PSage() for _ in range(3)]
w = [x(eval('rosen(%s)'% str(x0))) for x in v]
w
[848.22, 848.22, 848.22]
Unfortunately, using eval()
does not solve the problem. Because the example here is instantaneous to compute, I haven't realized that the calculations were, in fact, executed sequentially and not in parallel. After looking at the PSage()
code it is clear that the argument must be a single string and the fact that this example "worked" although not in parallel, must be some artifact of using an explicit eval()
. Mea culpa, HOWEVER, I created a better example and opened a new ticket, because PSage()
would be an exteremely good tool for this kind of thing.