Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: infinite while loop
Replies: 3   Last Post: Jul 6, 2013 2:25 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Marc

Posts: 108
Registered: 7/2/10
Re: infinite while loop
Posted: Jul 6, 2013 11:18 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.