SlideShare a Scribd company logo
ALGORITHM TO USED ROUTING USING MATLAB
Our online Tutors are available 24*7 to provide Help with Algorithm to Used Routing
Homework/Assignment or a long term Graduate/Undergraduate Algorithm to Used Routing
Project. Our Tutors being experienced and proficient in Algorithm to Used Routing ensure to
provide high quality Algorithm to Used Routing Homework Help. Upload your Algorithm to Used
Routing Assignment at ‘Submit Your Assignment’ button or email it
to info@assignmentpedia.com. You can use our ‘Live Chat’ option to schedule an Online
Tutoring session with our Algorithm to Used Routing Tutors.
MINIMAL NEAREST-NEIGHBOR
This sample assignments shows how to Connect Randomly Ordered 2D Points into a Minimal
Nearest-Neighbor Closed Contour Connects randomly ordered 2D points into a minimal nearest
neighbor contour.
[Xout,Yout,varargout]=points2contour(Xin,Yin,P,direction,varargin)
%points2contour
%Tristan Ursell
%July 2013
%
%[Xout,Yout]=points2contour(Xin,Yin,P,direction)
%[Xout,Yout]=points2contour(Xin,Yin,P,direction,dlim)
%[Xout,Yout,orphans]=points2contour(Xin,Yin,P,direction,dlim)
%[Xout,Yout,orphans,indout]=points2contour(Xin,Yin,P,direction,dlim)
%
%Given any list of 2D points (Xin,Yin), construct a singly connected
%nearest-neighbor path in either the 'cw' or 'ccw' directions. The code
%has been written to handle square and hexagon grid points, as well as any
%non-grid arrangement of points.
%
%'P' sets the point to begin looking for the contour from the original
%ordering of (Xin,Yin), and 'direction' sets the direction of the contour,
%with options 'cw' and 'ccw', specifying clockwise and counter-clockwise,
%respectively.
%
%The optional input parameter 'dlim' sets a distance limit, if the distance
%between a point and all other points is greater than or equal to 'dlim',
%the point is left out of the contour.
%
%The optional output 'orphans' gives the indices of the original (Xin,Yin)
%points that were not included in the contour.
%
%The optional output 'indout' is the order of indices that produces
%Xin(indout)=Xout and Yin(indout)=Yout.
%
%There are many (Inf) situations where there is no unique mapping of points
%into a connected contour -- e.g. any time there are more than 2 nearest
%neighbor points, or in situations where the nearest neighbor matrix is
%non-symmetric. Picking a different P will result in a different contour.
%Likewise, in cases where one point is far from its neighbors, it may be
%orphaned, and only connected into the path at the end, giving strange
%results.
%
%The input points can be of any numerical class.
%
%Note that this will *not* necessarily form the shortest path between all
%the points -- that is the NP-Hard Traveling Salesman Problem, for which
%there is no deterministic solution. This will, however, find the shortest
%path for points with a symmetric nearest neighbor matrix.
%
%see also: bwtraceboundary
%
%Example 1: continuous points
%N=200;
%P=1;
%theta=linspace(0,2*pi*(1-1/N),N);
%[~,I]=sort(rand(1,N));
%R=2+sin(5*theta(I))/3;
%
%Xin=R.*cos(theta(I));
%Yin=R.*sin(theta(I));
%
%[Xout,Yout]=points2contour(Xin,Yin,P,'cw');
%
%figure;
%hold on
%plot(Xin,Yin,'b-')
%plot(Xout,Yout,'r-','Linewidth',2)
%plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15)
%plot(Xout(1),Yout(1),'g.','Markersize',15)
%plot(Xout(end),Yout(end),'r.','Markersize',15)
%xlabel('X')
%ylabel('Y')
%axis equal tight
%title(['Black = original points, Blue = original ordering, Red = new ordering, Green = starting
points'])
%box on
%
%
%Example 2: square grid
%P=1;
%
%Xin=[1,2,3,4,4,4,4,3,2,1,1,1];
%Yin=[0,0,0,0,1,2,3,3,2,2,1,0];
%
%[Xout,Yout]=points2contour(Xin,Yin,P,'cw');
%
%figure;
%hold on
%plot(Xin,Yin,'b-')
%plot(Xout,Yout,'r-','Linewidth',2)
%plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15)
%plot(Xout(1),Yout(1),'g.','Markersize',15)
%plot(Xout(end),Yout(end),'r.','Markersize',15)
%xlabel('X')
%ylabel('Y')
%axis equal tight
%box on
%
%Example 3: continuous points, pathological case
%N=200;
%P=1;
%theta=linspace(0,2*pi*(1-1/N),N);
%[~,I]=sort(rand(1,N));
%R=2+sin(5*theta(I))/3;
%
%Xin=(1+rand(1,N)/2).*R.*cos(theta(I));
%Yin=(1+rand(1,N)/2).*R.*sin(theta(I));
%
%[Xout,Yout]=points2contour(Xin,Yin,P,'cw');
%
%figure;
%hold on
%plot(Xin,Yin,'b-')
%plot(Xout,Yout,'r-','Linewidth',2)
%plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15)
%plot(Xout(1),Yout(1),'g.','Markersize',15)
%plot(Xout(end),Yout(end),'r.','Markersize',15)
%xlabel('X')
%ylabel('Y')
%axis equal tight
%title(['Black = original points, Blue = original ordering, Red = new ordering, Green = starting
points'])
%box on
%
%Example 4: continuous points, distance limit applied
%N=200;
%P=1;
%theta=linspace(0,2*pi*(1-1/N),N);
%[~,I]=sort(rand(1,N));
%R=2+sin(5*theta(I))/3;
%R(2)=5; %the outlier
%
%Xin=(1+rand(1,N)/16).*R.*cos(theta(I));
%Yin=(1+rand(1,N)/16).*R.*sin(theta(I));
%
%[Xout,Yout,orphans,indout]=points2contour(Xin,Yin,P,'cw',1);
%
%figure;
%hold on
%plot(Xin,Yin,'b-')
%plot(Xin(orphans),Yin(orphans),'kx')
%plot(Xin(indout),Yin(indout),'r-','Linewidth',2)
%plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15)
%plot(Xout(1),Yout(1),'g.','Markersize',15)
%plot(Xout(end),Yout(end),'r.','Markersize',15)
%xlabel('X')
%ylabel('Y')
%axis equal tight
%title(['Black = original points, Blue = original ordering, Red = new ordering, Green = starting
points'])
%box on
%
function [Xout,Yout,varargout]=points2contour(Xin,Yin,P,direction,varargin)
%check to make sure the vectors are the same length
if length(Xin)~=length(Yin)
error('Input vectors must be the same length.')
end
%check to make sure point list is long enough
if length(Xin)<2
error('The point list must have more than two elements.')
end
%check distance limit
if ~isempty(varargin)
dlim=varargin{1};
if dlim<=0
error('The distance limit parameter must be greater than zero.')
end
else
dlim=-1;
end
%check direction input
if and(~strcmp(direction,'cw'),~strcmp(direction,'ccw'))
error(['Direction input: ' direction ' is not valid, must be either "cw" or "ccw".'])
end
%check to make sure P is in the right range
P=round(P);
npts=length(Xin);
if or(P<1,P>npts)
error('The starting point P is out of range.')
end
%adjust input vectors for starting point
if size(Xin,1)==1
Xin=circshift(Xin,[0,1-P]);
Yin=circshift(Yin,[0,1-P]);
else
Xin=circshift(Xin,[1-P,0]);
Yin=circshift(Yin,[1-P,0]);
end
%find distances between all points
D=zeros(npts,npts);
for q1=1:npts
D(q1,:)=sqrt((Xin(q1)-Xin).^2+(Yin(q1)-Yin).^2);
end
%max distance
maxD=max(D(:));
%avoid self-connections
D=D+eye(npts)*maxD;
%apply distance contraint by removing bad points and starting over
if dlim>0
D(D>=dlim)=-1;
%find bad points
bad_pts=sum(D,1)==-npts;
orphans=find(bad_pts);
%check starting point
if sum(orphans==P)>0
error('The starting point index is a distance outlier, choose a new starting point.')
end
%get good points
Xin=Xin(~bad_pts);
Yin=Yin(~bad_pts);
%number of good points
npts=length(Xin);
%find distances between all points
D=zeros(npts,npts);
for q1=1:npts
D(q1,:)=sqrt((Xin(q1)-Xin).^2+(Yin(q1)-Yin).^2);
end
%max distance
maxD=max(D(:));
%avoid self-connections
D=D+eye(npts)*maxD;
else
orphans=[];
end
%tracking vector (has this original index been put into the ordered list?)
track_vec=zeros(1,npts);
%construct directed graph
Xout=zeros(1,npts);
Yout=zeros(1,npts);
indout0=zeros(1,npts);
Xout(1)=Xin(1);
Yout(1)=Yin(1);
indout0(1)=1;
p_now=1;
track_vec(p_now)=1;
for q1=2:npts
%get current row of distance matrix
curr_vec=D(p_now,:);
%remove used points
curr_vec(track_vec==1)=maxD;
%find index of closest non-assigned point
p_temp=find(curr_vec==min(curr_vec),1,'first');
%reassign point
Xout(q1)=Xin(p_temp);
Yout(q1)=Yin(p_temp);
%move index
p_now=p_temp;
%update tracking
track_vec(p_now)=1;
%update index vector
indout0(q1)=p_now;
end
%undo the circshift
temp1=find(~bad_pts);
indout=circshift(temp1(indout0),[P,0]);
%%%%%%% SET CONTOUR DIRECTION %%%%%%%%%%%%
%contour direction is a *global* feature that cannot be determined until
%all the points have been sequentially ordered.
%calculate tangent vectors
tan_vec=zeros(npts,3);
for q1=1:npts
if q1==npts
tan_vec(q1,:)=[Xout(1)-Xout(q1),Yout(1)-Yout(q1),0];
tan_vec(q1,:)=tan_vec(q1,:)/norm(tan_vec(q1,:));
else
tan_vec(q1,:)=[Xout(q1+1)-Xout(q1),Yout(q1+1)-Yout(q1),0];
tan_vec(q1,:)=tan_vec(q1,:)/norm(tan_vec(q1,:));
end
end
%determine direction of contour
local_cross=zeros(1,npts);
for q1=1:npts
if q1==npts
cross1=cross(tan_vec(q1,:),tan_vec(1,:));
else
cross1=cross(tan_vec(q1,:),tan_vec(q1+1,:));
end
local_cross(q1)=asin(cross1(3));
end
%figure out current direction
if sum(local_cross)<0
curr_dir='cw';
else
curr_dir='ccw';
end
%set direction of the contour
if and(strcmp(curr_dir,'cw'),strcmp(direction,'ccw'))
Xout=fliplr(Xout);
Yout=fliplr(Yout);
end
%varargout
if nargout==3
varargout{1}=orphans;
end
if nargout==4
varargout{1}=orphans;
varargout{2}=indout;
end
visit us at www.assignmentpedia.com or email us at info@assignmentpedia.com or call us at +1 520 8371215

More Related Content

Similar to Algorithm To Build A Routing Project

Final Design Project - Memo (with GUI)
Final Design Project - Memo (with GUI)Final Design Project - Memo (with GUI)
Final Design Project - Memo (with GUI)
Alex Larcheveque
 
Control Systems Using Matlab
Control Systems Using MatlabControl Systems Using Matlab
Control Systems Using Matlab
Assignmentpedia
 
Curvefitting
CurvefittingCurvefitting
Curvefitting
Philberto Saroni
 
Radar cross section project
Radar cross section projectRadar cross section project
Radar cross section project
Assignmentpedia
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
Merve Cvdr
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programs
Elsayed Hemayed
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
ESUG
 
Vinay
VinayVinay
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Ahmed Gamal Abdel Gawad
 
Computational Intelligence Assisted Engineering Design Optimization (using MA...
Computational Intelligence Assisted Engineering Design Optimization (using MA...Computational Intelligence Assisted Engineering Design Optimization (using MA...
Computational Intelligence Assisted Engineering Design Optimization (using MA...
AmirParnianifard1
 
GradientDescent.pptx
GradientDescent.pptxGradientDescent.pptx
GradientDescent.pptx
Dhiraj7023
 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inference
Kemal İnciroğlu
 
greedy algorithm.pptx good for understanding
greedy algorithm.pptx good for understandinggreedy algorithm.pptx good for understanding
greedy algorithm.pptx good for understanding
HUSNAINAHMAD39
 
Recognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesRecognition of unistroke gesture sequences
Recognition of unistroke gesture sequences
Arvind Krishnaa
 
K fold validation
K fold validationK fold validation
K fold validation
Masrur Ahmed
 
Seminar Report (Final)
Seminar Report (Final)Seminar Report (Final)
Seminar Report (Final)
Aruneel Das
 
2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data 2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data
Malik Hassan Qayyum 🕵🏻‍♂️
 
SURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVES
SURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVESSURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVES
SURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVES
Zac Darcy
 
Approximation Data Structures for Streaming Applications
Approximation Data Structures for Streaming ApplicationsApproximation Data Structures for Streaming Applications
Approximation Data Structures for Streaming Applications
Debasish Ghosh
 
working with python
working with pythonworking with python
working with python
bhavesh lande
 

Similar to Algorithm To Build A Routing Project (20)

Final Design Project - Memo (with GUI)
Final Design Project - Memo (with GUI)Final Design Project - Memo (with GUI)
Final Design Project - Memo (with GUI)
 
Control Systems Using Matlab
Control Systems Using MatlabControl Systems Using Matlab
Control Systems Using Matlab
 
Curvefitting
CurvefittingCurvefitting
Curvefitting
 
Radar cross section project
Radar cross section projectRadar cross section project
Radar cross section project
 
Matlab kod taslağı
Matlab kod taslağıMatlab kod taslağı
Matlab kod taslağı
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programs
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
Vinay
VinayVinay
Vinay
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
 
Computational Intelligence Assisted Engineering Design Optimization (using MA...
Computational Intelligence Assisted Engineering Design Optimization (using MA...Computational Intelligence Assisted Engineering Design Optimization (using MA...
Computational Intelligence Assisted Engineering Design Optimization (using MA...
 
GradientDescent.pptx
GradientDescent.pptxGradientDescent.pptx
GradientDescent.pptx
 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inference
 
greedy algorithm.pptx good for understanding
greedy algorithm.pptx good for understandinggreedy algorithm.pptx good for understanding
greedy algorithm.pptx good for understanding
 
Recognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesRecognition of unistroke gesture sequences
Recognition of unistroke gesture sequences
 
K fold validation
K fold validationK fold validation
K fold validation
 
Seminar Report (Final)
Seminar Report (Final)Seminar Report (Final)
Seminar Report (Final)
 
2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data 2. diagnostics, collinearity, transformation, and missing data
2. diagnostics, collinearity, transformation, and missing data
 
SURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVES
SURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVESSURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVES
SURVEY ON POLYGONAL APPROXIMATION TECHNIQUES FOR DIGITAL PLANAR CURVES
 
Approximation Data Structures for Streaming Applications
Approximation Data Structures for Streaming ApplicationsApproximation Data Structures for Streaming Applications
Approximation Data Structures for Streaming Applications
 
working with python
working with pythonworking with python
working with python
 

More from Assignmentpedia

Transmitter side components
Transmitter side componentsTransmitter side components
Transmitter side components
Assignmentpedia
 
Single object range detection
Single object range detectionSingle object range detection
Single object range detection
Assignmentpedia
 
Sequential radar tracking
Sequential radar trackingSequential radar tracking
Sequential radar tracking
Assignmentpedia
 
Resolution project
Resolution projectResolution project
Resolution project
Assignmentpedia
 
Radar application project help
Radar application project helpRadar application project help
Radar application project help
Assignmentpedia
 
Parallel computing homework help
Parallel computing homework helpParallel computing homework help
Parallel computing homework help
Assignmentpedia
 
Network costing analysis
Network costing analysisNetwork costing analysis
Network costing analysis
Assignmentpedia
 
Matlab simulation project
Matlab simulation projectMatlab simulation project
Matlab simulation project
Assignmentpedia
 
Matlab programming project
Matlab programming projectMatlab programming project
Matlab programming project
Assignmentpedia
 
Links design
Links designLinks design
Links design
Assignmentpedia
 
Image processing project using matlab
Image processing project using matlabImage processing project using matlab
Image processing project using matlab
Assignmentpedia
 
Help with root locus homework1
Help with root locus homework1Help with root locus homework1
Help with root locus homework1
Assignmentpedia
 
Transmitter subsystem
Transmitter subsystemTransmitter subsystem
Transmitter subsystem
Assignmentpedia
 
Theory of computation homework help
Theory of computation homework helpTheory of computation homework help
Theory of computation homework help
Assignmentpedia
 
Econometrics Homework Help
Econometrics Homework HelpEconometrics Homework Help
Econometrics Homework Help
Assignmentpedia
 
Video Codec
Video CodecVideo Codec
Video Codec
Assignmentpedia
 
Radar Spectral Analysis
Radar Spectral AnalysisRadar Spectral Analysis
Radar Spectral Analysis
Assignmentpedia
 
Pi Controller
Pi ControllerPi Controller
Pi Controller
Assignmentpedia
 
Help With Digital Communication Project
Help With  Digital Communication ProjectHelp With  Digital Communication Project
Help With Digital Communication Project
Assignmentpedia
 
Fpga Design Project
Fpga Design ProjectFpga Design Project
Fpga Design Project
Assignmentpedia
 

More from Assignmentpedia (20)

Transmitter side components
Transmitter side componentsTransmitter side components
Transmitter side components
 
Single object range detection
Single object range detectionSingle object range detection
Single object range detection
 
Sequential radar tracking
Sequential radar trackingSequential radar tracking
Sequential radar tracking
 
Resolution project
Resolution projectResolution project
Resolution project
 
Radar application project help
Radar application project helpRadar application project help
Radar application project help
 
Parallel computing homework help
Parallel computing homework helpParallel computing homework help
Parallel computing homework help
 
Network costing analysis
Network costing analysisNetwork costing analysis
Network costing analysis
 
Matlab simulation project
Matlab simulation projectMatlab simulation project
Matlab simulation project
 
Matlab programming project
Matlab programming projectMatlab programming project
Matlab programming project
 
Links design
Links designLinks design
Links design
 
Image processing project using matlab
Image processing project using matlabImage processing project using matlab
Image processing project using matlab
 
Help with root locus homework1
Help with root locus homework1Help with root locus homework1
Help with root locus homework1
 
Transmitter subsystem
Transmitter subsystemTransmitter subsystem
Transmitter subsystem
 
Theory of computation homework help
Theory of computation homework helpTheory of computation homework help
Theory of computation homework help
 
Econometrics Homework Help
Econometrics Homework HelpEconometrics Homework Help
Econometrics Homework Help
 
Video Codec
Video CodecVideo Codec
Video Codec
 
Radar Spectral Analysis
Radar Spectral AnalysisRadar Spectral Analysis
Radar Spectral Analysis
 
Pi Controller
Pi ControllerPi Controller
Pi Controller
 
Help With Digital Communication Project
Help With  Digital Communication ProjectHelp With  Digital Communication Project
Help With Digital Communication Project
 
Fpga Design Project
Fpga Design ProjectFpga Design Project
Fpga Design Project
 

Recently uploaded

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
S. Raj Kumar
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 

Recently uploaded (20)

The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching AptitudeUGC NET Exam Paper 1- Unit 1:Teaching Aptitude
UGC NET Exam Paper 1- Unit 1:Teaching Aptitude
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 

Algorithm To Build A Routing Project

  • 1. ALGORITHM TO USED ROUTING USING MATLAB Our online Tutors are available 24*7 to provide Help with Algorithm to Used Routing Homework/Assignment or a long term Graduate/Undergraduate Algorithm to Used Routing Project. Our Tutors being experienced and proficient in Algorithm to Used Routing ensure to provide high quality Algorithm to Used Routing Homework Help. Upload your Algorithm to Used Routing Assignment at ‘Submit Your Assignment’ button or email it to info@assignmentpedia.com. You can use our ‘Live Chat’ option to schedule an Online Tutoring session with our Algorithm to Used Routing Tutors. MINIMAL NEAREST-NEIGHBOR This sample assignments shows how to Connect Randomly Ordered 2D Points into a Minimal Nearest-Neighbor Closed Contour Connects randomly ordered 2D points into a minimal nearest neighbor contour. [Xout,Yout,varargout]=points2contour(Xin,Yin,P,direction,varargin) %points2contour %Tristan Ursell %July 2013 % %[Xout,Yout]=points2contour(Xin,Yin,P,direction) %[Xout,Yout]=points2contour(Xin,Yin,P,direction,dlim) %[Xout,Yout,orphans]=points2contour(Xin,Yin,P,direction,dlim) %[Xout,Yout,orphans,indout]=points2contour(Xin,Yin,P,direction,dlim) % %Given any list of 2D points (Xin,Yin), construct a singly connected %nearest-neighbor path in either the 'cw' or 'ccw' directions. The code %has been written to handle square and hexagon grid points, as well as any %non-grid arrangement of points. % %'P' sets the point to begin looking for the contour from the original %ordering of (Xin,Yin), and 'direction' sets the direction of the contour, %with options 'cw' and 'ccw', specifying clockwise and counter-clockwise, %respectively. % %The optional input parameter 'dlim' sets a distance limit, if the distance %between a point and all other points is greater than or equal to 'dlim', %the point is left out of the contour. % %The optional output 'orphans' gives the indices of the original (Xin,Yin) %points that were not included in the contour. % %The optional output 'indout' is the order of indices that produces %Xin(indout)=Xout and Yin(indout)=Yout. %
  • 2. %There are many (Inf) situations where there is no unique mapping of points %into a connected contour -- e.g. any time there are more than 2 nearest %neighbor points, or in situations where the nearest neighbor matrix is %non-symmetric. Picking a different P will result in a different contour. %Likewise, in cases where one point is far from its neighbors, it may be %orphaned, and only connected into the path at the end, giving strange %results. % %The input points can be of any numerical class. % %Note that this will *not* necessarily form the shortest path between all %the points -- that is the NP-Hard Traveling Salesman Problem, for which %there is no deterministic solution. This will, however, find the shortest %path for points with a symmetric nearest neighbor matrix. % %see also: bwtraceboundary % %Example 1: continuous points %N=200; %P=1; %theta=linspace(0,2*pi*(1-1/N),N); %[~,I]=sort(rand(1,N)); %R=2+sin(5*theta(I))/3; % %Xin=R.*cos(theta(I)); %Yin=R.*sin(theta(I)); % %[Xout,Yout]=points2contour(Xin,Yin,P,'cw'); % %figure; %hold on %plot(Xin,Yin,'b-') %plot(Xout,Yout,'r-','Linewidth',2) %plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15) %plot(Xout(1),Yout(1),'g.','Markersize',15) %plot(Xout(end),Yout(end),'r.','Markersize',15) %xlabel('X') %ylabel('Y') %axis equal tight %title(['Black = original points, Blue = original ordering, Red = new ordering, Green = starting points']) %box on % % %Example 2: square grid %P=1; % %Xin=[1,2,3,4,4,4,4,3,2,1,1,1]; %Yin=[0,0,0,0,1,2,3,3,2,2,1,0];
  • 3. % %[Xout,Yout]=points2contour(Xin,Yin,P,'cw'); % %figure; %hold on %plot(Xin,Yin,'b-') %plot(Xout,Yout,'r-','Linewidth',2) %plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15) %plot(Xout(1),Yout(1),'g.','Markersize',15) %plot(Xout(end),Yout(end),'r.','Markersize',15) %xlabel('X') %ylabel('Y') %axis equal tight %box on % %Example 3: continuous points, pathological case %N=200; %P=1; %theta=linspace(0,2*pi*(1-1/N),N); %[~,I]=sort(rand(1,N)); %R=2+sin(5*theta(I))/3; % %Xin=(1+rand(1,N)/2).*R.*cos(theta(I)); %Yin=(1+rand(1,N)/2).*R.*sin(theta(I)); % %[Xout,Yout]=points2contour(Xin,Yin,P,'cw'); % %figure; %hold on %plot(Xin,Yin,'b-') %plot(Xout,Yout,'r-','Linewidth',2) %plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15) %plot(Xout(1),Yout(1),'g.','Markersize',15) %plot(Xout(end),Yout(end),'r.','Markersize',15) %xlabel('X') %ylabel('Y') %axis equal tight %title(['Black = original points, Blue = original ordering, Red = new ordering, Green = starting points']) %box on % %Example 4: continuous points, distance limit applied %N=200; %P=1; %theta=linspace(0,2*pi*(1-1/N),N); %[~,I]=sort(rand(1,N)); %R=2+sin(5*theta(I))/3; %R(2)=5; %the outlier %
  • 4. %Xin=(1+rand(1,N)/16).*R.*cos(theta(I)); %Yin=(1+rand(1,N)/16).*R.*sin(theta(I)); % %[Xout,Yout,orphans,indout]=points2contour(Xin,Yin,P,'cw',1); % %figure; %hold on %plot(Xin,Yin,'b-') %plot(Xin(orphans),Yin(orphans),'kx') %plot(Xin(indout),Yin(indout),'r-','Linewidth',2) %plot(Xout(2:end-1),Yout(2:end-1),'k.','Markersize',15) %plot(Xout(1),Yout(1),'g.','Markersize',15) %plot(Xout(end),Yout(end),'r.','Markersize',15) %xlabel('X') %ylabel('Y') %axis equal tight %title(['Black = original points, Blue = original ordering, Red = new ordering, Green = starting points']) %box on % function [Xout,Yout,varargout]=points2contour(Xin,Yin,P,direction,varargin) %check to make sure the vectors are the same length if length(Xin)~=length(Yin) error('Input vectors must be the same length.') end %check to make sure point list is long enough if length(Xin)<2 error('The point list must have more than two elements.') end %check distance limit if ~isempty(varargin) dlim=varargin{1}; if dlim<=0 error('The distance limit parameter must be greater than zero.') end else dlim=-1; end %check direction input if and(~strcmp(direction,'cw'),~strcmp(direction,'ccw')) error(['Direction input: ' direction ' is not valid, must be either "cw" or "ccw".']) end %check to make sure P is in the right range
  • 5. P=round(P); npts=length(Xin); if or(P<1,P>npts) error('The starting point P is out of range.') end %adjust input vectors for starting point if size(Xin,1)==1 Xin=circshift(Xin,[0,1-P]); Yin=circshift(Yin,[0,1-P]); else Xin=circshift(Xin,[1-P,0]); Yin=circshift(Yin,[1-P,0]); end %find distances between all points D=zeros(npts,npts); for q1=1:npts D(q1,:)=sqrt((Xin(q1)-Xin).^2+(Yin(q1)-Yin).^2); end %max distance maxD=max(D(:)); %avoid self-connections D=D+eye(npts)*maxD; %apply distance contraint by removing bad points and starting over if dlim>0 D(D>=dlim)=-1; %find bad points bad_pts=sum(D,1)==-npts; orphans=find(bad_pts); %check starting point if sum(orphans==P)>0 error('The starting point index is a distance outlier, choose a new starting point.') end %get good points Xin=Xin(~bad_pts); Yin=Yin(~bad_pts); %number of good points npts=length(Xin); %find distances between all points
  • 6. D=zeros(npts,npts); for q1=1:npts D(q1,:)=sqrt((Xin(q1)-Xin).^2+(Yin(q1)-Yin).^2); end %max distance maxD=max(D(:)); %avoid self-connections D=D+eye(npts)*maxD; else orphans=[]; end %tracking vector (has this original index been put into the ordered list?) track_vec=zeros(1,npts); %construct directed graph Xout=zeros(1,npts); Yout=zeros(1,npts); indout0=zeros(1,npts); Xout(1)=Xin(1); Yout(1)=Yin(1); indout0(1)=1; p_now=1; track_vec(p_now)=1; for q1=2:npts %get current row of distance matrix curr_vec=D(p_now,:); %remove used points curr_vec(track_vec==1)=maxD; %find index of closest non-assigned point p_temp=find(curr_vec==min(curr_vec),1,'first'); %reassign point Xout(q1)=Xin(p_temp); Yout(q1)=Yin(p_temp); %move index p_now=p_temp; %update tracking track_vec(p_now)=1; %update index vector
  • 7. indout0(q1)=p_now; end %undo the circshift temp1=find(~bad_pts); indout=circshift(temp1(indout0),[P,0]); %%%%%%% SET CONTOUR DIRECTION %%%%%%%%%%%% %contour direction is a *global* feature that cannot be determined until %all the points have been sequentially ordered. %calculate tangent vectors tan_vec=zeros(npts,3); for q1=1:npts if q1==npts tan_vec(q1,:)=[Xout(1)-Xout(q1),Yout(1)-Yout(q1),0]; tan_vec(q1,:)=tan_vec(q1,:)/norm(tan_vec(q1,:)); else tan_vec(q1,:)=[Xout(q1+1)-Xout(q1),Yout(q1+1)-Yout(q1),0]; tan_vec(q1,:)=tan_vec(q1,:)/norm(tan_vec(q1,:)); end end %determine direction of contour local_cross=zeros(1,npts); for q1=1:npts if q1==npts cross1=cross(tan_vec(q1,:),tan_vec(1,:)); else cross1=cross(tan_vec(q1,:),tan_vec(q1+1,:)); end local_cross(q1)=asin(cross1(3)); end %figure out current direction if sum(local_cross)<0 curr_dir='cw'; else curr_dir='ccw'; end %set direction of the contour if and(strcmp(curr_dir,'cw'),strcmp(direction,'ccw')) Xout=fliplr(Xout); Yout=fliplr(Yout); end %varargout if nargout==3
  • 8. varargout{1}=orphans; end if nargout==4 varargout{1}=orphans; varargout{2}=indout; end visit us at www.assignmentpedia.com or email us at info@assignmentpedia.com or call us at +1 520 8371215