minimiztion the distance travel
1 次查看(过去 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!