Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.
|
|
Marc
Posts:
108
Registered:
7/2/10
|
|
Re: infinite while loop
Posted:
Jul 6, 2013 11:18 AM
|
|
"Vithoban Vithoban" wrote in message <kr5o9d$jih$1@newscl01ah.mathworks.com>... > hi ! i am getting an infinite while loop. > > can anyone tell me why? > > while length(visited_list)~=total_num_nodes > > [new_node,new_route]=objective_func_nnb(wait_list,tabu_major,tabu_minor,prev_node,load); > > cap_para=capacity1(load,new_node); > > if cap_para==1 > > [time_para,edprev]=time1(new_node,new_route,prev_node); > > else > time_para=0; > end > > > if time_para==1 > > x=length(visited_list); > visited_list(x+1)=new_node; > > for c=1:length(wait_list) > if wait_list(c)==new_node > wait_list(c)=0; > end % end of if statement > end % end of for loop > > g=length(tour); > tour(g+1)=new_node; > route(g)=new_route; > load=load+demand(new_node); > tabu_minor=zeros(total_num_nodes,3); > tabu_major=0; > > prev_node=new_node; % assigns the newly accepted node as the prev_node ot be used in the next iteration > > disp('updation of node has been done') > > > % end of if > > % if either time/capacity is not satisfied > else > > tabu_minor(new_node+1,new_route)=1; > > p=0; > > for d=1:3 > if tabu_minor(new_node+1,d)==1 > p=p+1; > end % end of if statement > > end % end of for loop > if p==3 % if statement to assign next node as depot if condition satisfied > y=length(tabu_major); > tabu_major(y+1)=new_node; > > length_wait=0; > for c=1:length(wait_list) > if wait_list(c)~=0 > length_wait=length_wait+1; > end > end > > if length(tabu_major)==length_wait % to check if the vehicle has to move to the depot next > %this check is performed only after the tabu_major has been updated. without updation,there is no need to check since more nodes will be available to be searched > x=length(tour); > tour(x+1)=0; > > min=10;% assigns value to min > > carried=capacity-load; > for e=1:3 > if sum(b(prev_node+1,1,e),a(prev_node+1,1,e)*carried)<=min > min=b(prev_node+1,1,e)+a(prev_node+1,1,e)*carried; > fact=e; > end %end of if > end % end of for loop > route(x)=fact; > prev_node=0; > load=0; > tabu_major=0; > tabu_minor=zeros(total_num_nodes,3); > > end % end of if statement > > end % end of if statement > > end > > end % end of while
It is very hard to trouble shoot this without some of the values for length and total_num_nodes.
That said, I don't see where either of these two arrays(?) are being updated in this loop, so why would you expect the condition up front to change if your not changing those values?
I may have missed something but if you can add some values or a snippet of the code before hand, so that we can run on our machines, maybe I can follow it a bit better.
|
|
|
|