May-18-2020, 05:04 PM
Using function variable C from the previous iteration and then calculate VB for the current iteration. Then Use VB to calculate C from the next iteration.
I am facing the problem to sync the loop and updating VB and C in each iteration. I have tried some coding.
Thanks in advance.
I am facing the problem to sync the loop and updating VB and C in each iteration. I have tried some coding.
Thanks in advance.
L=9 N=10 M=5 VB=[] C=[] K=[] C=[] P=np.zeros((1,L,L)) omega=[] def g(): ## A function to calculate C for i in range(0,M): if(i%M==0): ###### getting a max in a interval for j in range(0,L): for k in range(0,L): P[0][j][k]=K[i][j][k] ##### the K is comeing from the main body elif(i%M!=0): for j in range(0,L): for k in range(0,L): if (K[i][j][k]>P[0][j][k]): ##### getting max value P[0][j][k]=K[i][j][k] if((i+1)%M==0): #### saving max value for the current interval C=P.copy() return C ###### get C for the interation for NJ in (0,10): for nstep in np.arange(N): V=[] for i in range(0,L): U=[] for j in range(0,L): m=18+5*i*nstep/2-6*j*i*nstep U.append(m) V.append(U) VB.append(V)### calculate VB for the current iteration C=g() ### calling C from the last iteration K[NJ]=np.array(VB) ### Use C from the last iteration and mulitying in the current iteration # use this K again usded in function g return C for the next iteration