glpk を使用して、ソース ノードからターゲット ノードまでのすべての可能なパスを列挙しようとしていますが、構文に問題があります。これが私の現在のコードです(最短パスの例から適応):
param n, integer, > 0;
/* number of nodes */
set E, within {i in 0..n, j in 0..n};
/* set of edges */
param s, in {0..n};
/* source node */
param t, in {0..n};
/* target node */
var x{(i,j) in E}, >= 0;
/* x[i,j] = 1 means that edge (i,j) belong to shortest path;
x[i,j] = 0 means that edge (i,j) does not belong to shortest path;
note that variables x[i,j] are binary, however, there is no need to
declare them so due to the totally unimodular constraint matrix */
s.t. r{i in 1..n}: sum{(j,i) in E} x[j,i] + (if i = s then 1) =
sum{(i,j) in E} x[i,j] + (if i = t then 1);
/* conservation conditions for unity flow from s to t; every feasible
solution is a path from s to t */
var test, integer, =0;
minimize Z: sum{(i,j) in E} x[i,j];
/* objective function is the path length to be minimized */
solve;
for {(i,j) in E: x[i,j]>0}{
printf "%d --> %d ", i, j;
}
#printf " tamanho do caminho %d ", count;