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??

采纳的回答

Bruno Luong
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 个)

类别

Help CenterFile 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!

Translated by