Question

I have a linear programming model, for the problem of minimum path. This is the model:

/* Min path problem

file: minPath.mod */

set V;
set E within V cross V;

param cost{E};
param S symbolic;
param T symbolic;

var flow{E} integer, >= 0;


minimize min_path: sum{(a,b) in E} cost[a,b] * flow[a,b];

s.t. conservazione{v in V: v != S and v != T}:
    sum{(a,b) in E: a == v} flow[a,b] == 
    sum{(a,b) in E: b == v} flow[a,b];
s.t. sorgente: sum{(a,b) in E: a == S} flow[a,b] == 1;
s.t. destinazione: sum{(a,b) in E: b == T} flow[a,b] == 1;

display {(a,b) in E} flow[a,b];

data;

set V := A B C D E;
set E := (A,B) (A,C) (B,D) (B,E) (C,D) (D,E);

param S := A;
param T := D;

param cost := [A,B] 2 [A,C] 1 [B,D] 3 [B,E] 1 [C,D] 1 [D,E] 1;

end;

The objective value is 3 for my example, and the minimum path is:

A -> C -> D -> E

For this reason, the vector flow has to be 1 on the edges, that i written here above. By the way, when i display the vector flow with the statement:

display {(a,b) in E} flow[a,b];

the vector is 0 in all the position.

flow[A,B].val = 0
flow[A,C].val = 0
flow[B,D].val = 0
flow[B,E].val = 0
flow[C,D].val = 0
flow[D,E].val = 0

I tried to change the syntax, but i couldn't force glpsol to print the real value.

Am I missing something?

Was it helpful?

Solution

you have to put the statement:

solve;

before the display statement!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top