- Total Downloads37
- Downloads Last Week0

Editor: TSP_GA Traveling Salesman Problem (TSP) Genetic Algorithm (GA)

Finds a (near) optimal solution to the TSP by setting up a GA to search for the shortest route (least distance for the salesman to travel to each city exactly once and return to the starting city)

Summary:

1. A single salesman travels to each of the cities and completes the route by returning to the city he started from

2. Each city is visited by the salesman exactly once

Input:

XY (float) is an Nx2 (or Nx3) Matrix of cities

DMAT (float) is an NxN matrix of point to point distances/costs

POP_SIZE (scalar integer) is the size of the population (should be divisible by 4)

NUM_ITER (scalar integer) is the number of desired iterations for the algorithm to run

SHOW_PROG (scalar logical) shows the GA progress if true

SHOW_RES (scalar logical) shows the GA results if true

Output:

OPT_RTE (integer array) is the best route found by the algorithm

MIN_DIST (scalar float) is the cost of the best route

Example:

n = 50;

xy = 10*rand(n,2);

a = meshgrid(1:n);

dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);

pop_size = 60;

num_iter = 1e4;

show_prog = 1;

show_res = 1;

[opt_rte,min_dist] = tsp_ga(xy,dmat,pop_size,num_iter,show_prog,show_res);

Finds a (near) optimal solution to the TSP by setting up a GA to search for the shortest route (least distance for the salesman to travel to each city exactly once and return to the starting city)

Summary:

1. A single salesman travels to each of the cities and completes the route by returning to the city he started from

2. Each city is visited by the salesman exactly once

Input:

XY (float) is an Nx2 (or Nx3) Matrix of cities

DMAT (float) is an NxN matrix of point to point distances/costs

POP_SIZE (scalar integer) is the size of the population (should be divisible by 4)

NUM_ITER (scalar integer) is the number of desired iterations for the algorithm to run

SHOW_PROG (scalar logical) shows the GA progress if true

SHOW_RES (scalar logical) shows the GA results if true

Output:

OPT_RTE (integer array) is the best route found by the algorithm

MIN_DIST (scalar float) is the cost of the best route

Example:

n = 50;

xy = 10*rand(n,2);

a = meshgrid(1:n);

dmat = reshape(sqrt(sum((xy(a,:)-xy(a',:)).^2,2)),n,n);

pop_size = 60;

num_iter = 1e4;

show_prog = 1;

show_res = 1;

[opt_rte,min_dist] = tsp_ga(xy,dmat,pop_size,num_iter,show_prog,show_res);

Screenshots are not available currently.

Release notes are not available currently.

No additional system requirements.

- Version:N/A
- Updated:
- License:
- Language:English
- File Size:3KB
- Developer:
- Category:
- SubCategory:

- RGBHIST displays a histogram of the overall color balance of an image.
- A Hopfield neural network to identify patterns in a binary image
- The Netlab toolbox is designed to provide the central tools necessary.
- abel plots with spectra. Convert wavelengths to RGB. Functions for color
- It can let you select a dicom series from a DICOMDIR directory.
- Simulink Simulator for a Brushless DC Motor - Complete simulator for brushless d