Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually, I think I have a rough answer to this.</p> <p>The answer is in the mex functions compiled from C that were called inside the Parfor. Those functions are not very well written, with many global pointers. I think with Parfor and having 8 workers, having to divide the memory, something messed up the mex files. It doesn't happen as often with For, but I found out that sometimes it does.</p> <p>The reason why the code was all hung up is because there was a line that says: if something is NaN, then pause. Pause should not be in a parfor because the multiple workers won't know what to do with it. Hence I thought the parfor loop was acting like an infinite loop.</p> <p>Note below: demand_full is a mex file and when I change the 'pause' to 'print circ' it's all NaN when the error happens. </p> <pre><code>for j = 1:NDRAWS pmat_temp = 1:mkt; parfor i = 1:mkt tauvec = [zeros(1, numD(i)) ones(1, numR(i))]; [circ] = demand_full(prices{i}, tauvec, rhoarray(i, j), theta); y = log(mean_mat2D_c(circ(tauvec==1))) - log(mean_mat2D_c(circ(tauvec==0))); pR = exp(rho_param1 + rho_param2 * rhoarray(i, j))... / (1 + exp(rho_param1 + rho_param2 * rhoarray(i, j))); lambda = exp(n_param1 + n_param2 * log(hhld(i)) + n_param3 * rhoarray(i, j) + n_param4 * rhoarray(i, j)^2); pN = lambda^(length(tauvec)) / exp(lambda) / factorial_c(length(tauvec)); p_market_config_temp = nchoosek_c(length(tauvec), numR(i)) * pR^numR(i) * (1 - pR)^numD(i); p_market_config = pN * (p_market_config_temp / (1 - pR^length(tauvec) - (1 - pR)^length(tauvec))); pmat_temp(i) = p_market_config * 1/sigma_q / sqrt(1/numR(i) + 1/numD(i)) * ... exp(-((yhat(i) - y) / sqrt(1/numR(i) + 1/numD(i)))^2 / 2 / sigma_q^2); if isnan(pmat_temp(i)) pause end end pmat(:, j) = pmat_temp; end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload