minimiztion the distance travel
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Walter Roberson
2019 年 9 月 1 日
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.
採用された回答
Bruno Luong
2019 年 9 月 1 日
編集済み: Bruno Luong
2019 年 9 月 1 日
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
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear Programming and Mixed-Integer Linear Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!