help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Please help with error: can't perform indexing operations for <unknown t


From: shirley123
Subject: Please help with error: can't perform indexing operations for <unknown type> type
Date: Sat, 1 Nov 2014 14:56:50 -0700 (PDT)

Hi, I just started using octave last week as my professor asked me to use
MPI. This is my second code. It has a main code and a function to call. I
found this forum by googling this error. So please tell me if this is not
the right place. I use the code to test the change of the convergence of a
model under change of two parameters. The function to call is one random
path of the model given a pair of the parameters. I need many paths to see
the distribution so every other machine in the system is supposed to report
me result of 10 paths. But the code just stops with the  "can't perform
indexing operations" error. Thanks for any help. 

This is the information I got:
$ mpirun -np 4 octave -q --eval 'pkg load mpi; model_con_mpi.m'
we are at rank 0 that is master..
we are at rank 0 that is master..
we are at rank 0 that is master..
error: can't perform indexing operations for <unknown type> type
error: can't perform indexing operations for <unknown type> type
error: can't perform indexing operations for <unknown type> type
error: can't perform indexing operations for <unknown type> type
--------------------------------------------------------------------------
mpirun noticed that the job aborted, but has no info as to the process
that caused that situation.

I have tested the function I used in the code many times on Matlab, nothing
wrong there. Please help me or I would be killed by the professor...
The code is:
the main code:
function model_con_nominal_mpi %file name

dest=0;
tag=0;
tag1=1;

MPI_Init ();
MPI_COMM_WORLD=MPI_Comm_Load("New");
rank=MPI_Comm_rank(MPI_COMM_WORLD);
p=MPI_Comm_size(MPI_COMM_WORLD);

master=0;
Tgamma=5;
Tpi1=5;
result0=ones(Tpi1,Tgamma-1);
result1=ones(Tpi1,Tgamma-1);
for i=1:Tpi1;
        pi1_local=i*(1/Tpi1);
for j=1:Tgamma-1;
    gamma_local=j*(1/Tgamma);

 %assign runs for slaves   
 result_one_para0=ones(p,1);
 result_one_para1=ones(p,1);
 if rank~=master
 result_local_slave=ones(2,1);
 [result_local_slave(1)
result_local_slave(2)]=slave_nominal(pi1_local,gamma_local);
 MPI_Send(result_local_slave,0,tag1,MPI_COMM_WORLD);
 end
 
 if rank==master
     result_local_master=ones(2,1);
     [result_local_master(1)
result_local_master(2)]=slave_nominal(pi1_local,gamma_local);
     result_one_para0(1)=result_local_master(1);
     result_one_para1(1)=result_local_master(2);

 end
 
 %master receive results
 if rank==master
 for s=1:p-1;
         disp("we are at rank 0 that is master..");
         slaverun=MPI_Recv(s,tag1,MPI_COMM_WORLD);%receive results
         result_one_para0(s+1)=slaverun(1);
         result_one_para1(s+1)=slaverun(2);
 end 
     e=ones(p,1);
     result0(i,j)=e'*result_one_para0;
     result1(i,j)=e'*result_one_para1;
 end
 end
   
end

 result=[result0,result1];

 
save result.mat result -mat7-binary;
MPI_Finalize();
 
end



The function slave_nominal is:

function [M0C_local, M1C_local] = slave_nominal(pi1_local,gamma_local)
T=10;
M1=ones(T,1);
M0=ones(T,1);
for t=1:T;

rand('seed',sum(100*clock));

gamma=gamma_local;
rho=0.99;
sigmaf=0.1; 
sigmas=2;
a22=0.99;
R1= [0 0; 0 0.005];
R0= [0 0; 0 0];         
a21=rho*(1-gamma)*(1-a22)/(1-gamma*rho);

A=[1 0; a21 a22];
betabar=(rho*(1-gamma))/(1-rho*gamma);
rhosf=((1-gamma)+gamma*betabar)*sigmaf^2/(sigmaf^2+((1-gamma)+gamma*betabar)^2*sigmaf^2+sigmas^2);
sigma=sqrt(sigmaf^2+sigmas^2-2*rhosf*sigmaf*sigmas);  
N=15000;
s=zeros(N,1);
f=zeros(N,1);
b0=zeros(N,1);
b1=zeros(N,1);
nu=zeros(N,1);   
P0=repmat(1,[2 2 N]); 
P1=repmat(1,[2 2 N]);                     

                     


nu =randn(N);
nus=randn(N);
beta0=repmat(1,[2 1 N]);
beta1=repmat(1,[2 1 N]);
f(1)=sigmaf*nu(1);
b0(1)=betabar+R1(2,2)^(1/2)*randn;
b1(1)=betabar+R0(2,2)^(1/2)*randn;
beta0(:,:,1)=[1 b0(1)]';
beta1(:,:,1)=[1 b1(1)]';
P0(:,:,1)=[1 0;0 1];
P1(:,:,1)=[1 0;0 1];
pi1=ones(N,1);.
pi1(1)=pi1_local;

for n=2:N;
    
    noisef=sigmaf*nu(n);
     f(n)=rho*f(n-1)+noisef;
   
s(n)=((1-gamma)+gamma*(pi1(n-1)*b1(n-1)+(1-pi1(n-1))*b0(n-1)))*f(n)+sigmas*nus(n);
    
    
    y=[s(n) f(n)]';
    x=f(n-1);
    a=[0 rho*x]';
    H=[0 0;x 0];
    Sigma=[sigma^2 rhosf*sigma*sigmaf; rhosf*sigma*sigmaf sigmaf^2];
    
    K0=P0(:,:,n-1)*H/(H'*P0(:,:,n-1)*H+Sigma);
    betan0=beta0(:,:,n-1)+(K0*(y-a-H'*beta0(:,:,n-1)));
    Pn0=P0(:,:,n-1)-(K0*H'*P0(:,:,n-1));
    betaprediction0=A*betan0;
    beta0(:,:,n)=betaprediction0;
    P0(:,:,n)=A*Pn0*A'+R0;
    b0(n)=betaprediction0(2);


   K1=P1(:,:,n-1)*H/(H'*P1(:,:,n-1)*H+Sigma);
    betan1=beta1(:,:,n-1)+(K1*(y-a-H'*beta1(:,:,n-1)));
    Pn1=P1(:,:,n-1)-(K1*H'*P1(:,:,n-1));
   
    betaprediction1=A*betan1;
    beta1(:,:,n)=betaprediction1;
    P1(:,:,n)=A*Pn1*A'+R1;
 
    b1(n)=betaprediction1(2);
   
    MSE0=H'*P0(:,:,n-1)*H+Sigma;
    det0=det(MSE0);
    MSE1=H'*P1(:,:,n-1)*H+Sigma;
    det1=det(MSE1);
    I=[1 0;0 1];
    inv0=I/MSE0;
    inv1=I/MSE1;
   
A0=exp(-(y-a-H'*beta0(:,:,n-1))'*inv0*(y-a-H'*beta0(:,:,n-1))/2)/((4*pi^2*det0)^(1/2));
   
A1=exp(-(y-a-H'*beta1(:,:,n-1))'*inv1*(y-a-H'*beta1(:,:,n-1))/2)/((4*pi^2*det1)^(1/2));
    pi1(n)=(pi1(n-1)*A1)/(A0-pi1(n-1)*A0+pi1(n-1)*A1);
end
if pi1(N)>0.9999
   M1(t)=1;
   M0(t)=0;
else if pi1(N)<0.0001
        M1(t)=0;
        M0(t)=1;
    else M0(t)=0;
        M1(t)=0;
    end
end
end
i=ones(T,1);  
M0C_local=i'*M0;
M1C_local=i'*M1;





--
View this message in context: 
http://octave.1599824.n4.nabble.com/Please-help-with-error-can-t-perform-indexing-operations-for-unknown-type-type-tp4667186.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]