Hi all, I have a digraph of 81 nodes and I need to find the shortest path from a starting node to all the rest using linear programming. I adopted the idea from this post. But since I wanted from one node to all I set flow of all other nodes to be -1 and the starting node's flow as | V|-1. Adjacency matrix (named B) has size of 81x81 and values >0 if an edge exists between those nodes or Inf if not.
So i proceeded as follows:
V = size(B,1); % V = 81
flow = ones(1,V);
flow = -flow;
flow(startpoint) = V-1;
coeff = zeros(V,V,V);
for i=(1:V)
for j=(1:V)
coeff(i,i,j) = -1;
coeff(i,j,i) = 1;
end
coeff(i,i,i) = 0;
end
intlinprog(B,81*81,[],[],coeff,flow,zeros(1,V^2),ones(1,V^2));
I think this is correct from the documentation although I'm not that sure. But the problem is that when I run it I get this error:
Error using intlinprog (line 142)
INTLINPROG stopped because some objective or constraint matrix coefficients are too large in magnitude.

2 件のコメント

Matt J
Matt J 2017 年 12 月 19 日
編集済み: Matt J 2017 年 12 月 19 日
Hmmm. Well, I suggest you attach adjacencymatrix in a .mat file so that we can try it ourselves.
asdasd asdasdas
asdasd asdasdas 2017 年 12 月 19 日
Done!

サインインしてコメントする。

 採用された回答

Alan Weiss
Alan Weiss 2017 年 12 月 19 日

2 投票

intlinprog restricts coefficients to no more than 1e25. So you cannot formulate things exactly the way you want. Perhaps try 1e20 instead of Inf.
Alan Weiss
MATLAB mathematical toolbox documentation

1 件のコメント

asdasd asdasdas
asdasd asdasdas 2017 年 12 月 19 日
Thank you this will send me towards the right solution to my problem. Apparently since it's my first time dealing with so many dimensions I thought that was the problem so I ignored the part before 'or' in the error.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Graph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by