I didn't realize until I tried to make some simple code to reproduce it for you, but it only occurs when it's inside my parfor loop, not a regular for loop. I'm using Matlab 7.12 (R2011a) and latest version of YALMIP. Seems like the problem might be due to Matlab changing its random variable generator interface (see code output below).
| Code: |
matlabpool open 2
parfor i1 = 1:2
rng(i1, 'twister');
disp([num2str(i1) ': ' num2str(randn(1,3))]);
rng
Kopt = sdpvar(20,20,'symmetric');
disp([num2str(i1) ': ' num2str(randn(1,3))]);
rng
end
|
Output:
1: -0.64901 1.1812 -0.75845
ans =
Type: 'twister'
Seed: 1
State: [625x1 uint32]
1: 1.2299 -0.21527 1.6798
ans =
Type: 'Legacy'
Seed: 'Not applicable'
State: {1x6 cell}
2: -0.12423 -2.5415 0.27721
ans =
Type: 'twister'
Seed: 2
State: [625x1 uint32]
2: 1.2299 -0.21527 1.6798
ans =
Type: 'Legacy'
Seed: 'Not applicable'
State: {1x6 cell}
Done
Notice 2nd output of each parallel worker is same set of random #'s (1.2299 -0.21527 1.6798).