minimiztion the distance travel

1 vue (au cours des 30 derniers jours)
PRAVEEN GUPTA
PRAVEEN GUPTA le 1 Sep 2019
Modifié(e) : Bruno Luong le 1 Sep 2019
hi everyone
i have to write a code such that the time reaching the two points is minimum where different different routes are available to reach the point
for example :
A=[ 0 2 100 2 10 100 100;
2 0 3 100 100 100 100;
100 3 0 100 100 5 2;
100 100 100 0 4 3 100;
10 100 100 2 0 2 1;
100 100 5 3 2 0 4;
100 100 2 100 1 4 0];
the above matrix denotes the time to reach from one point to other (for example: from point(1) to point(5) time will 10 sec) but when the time is 100 (point(1) and point(3)) that way has to b skipped and we have to find another route (ex: to reach point 1 fro 3 the new route can be (3-->2-->1)or(3-->6-->4-->1)) the another route must have minimum time travel.
can we use optimization technique??
  1 commentaire
Walter Roberson
Walter Roberson le 1 Sep 2019
If you need to calculate the shortest path from each point to each other point then you will need to call one of the above multiple times.

Connectez-vous pour commenter.

Réponse acceptée

Bruno Luong
Bruno Luong le 1 Sep 2019
Modifié(e) : Bruno Luong le 1 Sep 2019
Checkout function distances
Warning : Your adjacent matrix is not symmetric !
>> A
A =
0 2 100 2 10 100 100
2 0 3 100 100 100 100
100 3 0 100 100 5 2
100 100 100 0 4 3 100
10 100 100 2 0 2 1
100 100 5 3 2 0 4
100 100 2 100 1 4 0
>> A==A'
ans =
7×7 logical array
1 1 1 0 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
0 1 1 1 0 1 1
1 1 1 0 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
Apply on symmetrized A
G = graph((A+A')/2);
distances(G)
Result:
ans =
0 2 5 11 8 10 7
2 0 3 9 6 8 5
5 3 0 6 3 5 2
11 9 6 0 3 3 4
8 6 3 3 0 2 1
10 8 5 3 2 0 3
7 5 2 4 1 3 0

Plus de réponses (0)

Catégories

En savoir plus sur Linear Programming and Mixed-Integer Linear Programming dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by