help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-glpk] first model using GNU MathProg (a newbie question)


From: Duilio Foschi
Subject: [Help-glpk] first model using GNU MathProg (a newbie question)
Date: Tue, 29 Jul 2003 01:06:29 +0200

I wrote my first model using GNU MathProg.

It is a set covering model and it should give me the best driver rostering
for a small bus line.

The bus line must "cover" M trips.

Using euristic methods, I have deviced N possible shifts. Each shift has a
cost, Ci (i=1..N).

Each shift covers some trips and does not covers others.

A binary matrix Aij has value 1 if shift i covers trip j, otherwise has
value 0.

I wrote:

set S;
/* shifts */

set T;
/* trips */

param C{s in S};
/* cost of shift s */

param A{s in S, t in T}, binary;  
/* 1 if shift s covers trip T, 0 otherwise */

var X(s in S}, binary;
/* 1 if shift s is choosen, 0 otherwise */

minimize cost: sum{s in S} C[s]*X[s];
/* total cost */

s.t. covers{t in T}: sum{s in S} A[s,t]*X[s]>=1;

data;

set S := one two three four five;

set T := A B C D E F G;

param C :=      one   100
                two   200
                three 300
                four  400
              five  400 ;

data;

set S := one two three four five;

set T := A B C D E F G;

param C :=      one   100
                two   200
                three 300
                four  400
              five  400 ;

param A :         A B C D E F G     :=
                      one   1 1 1 1 0 1 1
                      two   1 0 1 0 0 0 0
                      three 0 1 1 0 1 0 0
                      four  1 1 1 0 1 1 0
                      five  0 1 0 0 1 1 1  ;

end;

I was overjoyed to see that my model was happily compiled and run by GLPSOL
and the expected result (i.e. 400) given.

But how can I get what I want most, i.e. the X values that provided the
optimal result ?

In this sample code, it is easy to see that only shift "one" and "three"
were used, but in the real case, the shifts will be thousands...

Thank you

Duilio Foschi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]