[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-glpk] glpsol ignores tmlim
From: |
xypron |
Subject: |
[Bug-glpk] glpsol ignores tmlim |
Date: |
Thu, 3 Sep 2009 12:14:01 -0700 (PDT) |
Hello Andrew,
when starting glpsol for the model file below with
glpsol -m test.mod --tmlim 100
the solver does not terminate within the required time.
A lot of lines like the following are output:
| 19400: obj = 6.400000000e+001 infeas = 7.062e-014 (2)
| 19600: obj = 6.400000000e+001 infeas = 1.024e-014 (2)
| 19800: obj = 6.400000000e+001 infeas = 5.663e-014 (2)
Best regards
Xypron
# Knight's tour
#
# Determine the longest path a knight can
# cover on a chess field.
#
# glpsol -m test.mod --tmlim 100
# does not terminate for n=8
# size of field
param n;
# closed path
param closed;
# output style
param style;
set X := 1..n;
set S := 1..(n*n);
set F := X cross X;
var p{s in S, (x,y) in F}, binary;
# maximize length of track
maximize obj :
sum {s in S, (x,y) in F} p[s,x,y];
# starting point
s.t. start:
p[1,1,1] = 1;
# for each step the position must be defined
s.t. maxstep{s in S}:
sum{(x,y) in F} p[s,x,y] <= 1;
# for each position the step must be defined
s.t. maxpos{(x,y) in F}:
sum{s in S} p[s,x,y] <= 1;
# allowable moves
s.t. move{ s in S, (x1,y1) in F : s > 1 } :
p[s,x1,y1] <= sum{(x2,y2) in F} p[s-1,x2,y2] *
(if( (abs(x1-x2)==2 && abs(y1-y2)==1) || (abs(x1-x2)==1 && abs(y1-y2)==2)
)
then 1 else 0);
# require cycle covering all fields
s.t. cycl { i in 1..1, (x1,y1) in F : i = closed } :
p[1,x1,y1] <= sum{(x2,y2) in F} p[n*n,x2,y2] *
(if( (abs(x1-x2)==2 && abs(y1-y2)==1) || (abs(x1-x2)==1 && abs(y1-y2)==2)
)
then 1 else 0);
solve;
# output the result
# output without lines
for { i in 1..1 : i = style } {
for {x in X} {
for { y in X } {
printf "%2d ", sum{s in S} s * p[s,x,y];
}
printf "\n";
}
}
# output with lines
for { i in 2..2 : i = style } {
printf "+";
for { y in X } {
printf "--+";
}
printf "\n";
for {x in X} {
printf "|";
for { y in X } {
printf "%2d|", sum{s in S} s * p[s,x,y];
}
printf "\n";
printf "+";
for { y in X } {
printf "--+";
}
printf "\n";
}
}
data;
# size of field
param n:= 8;
# closed path : 0 = open, 1 = closed
param closed := 0;
# output style: 0 = none, 1 = simple, 2 = with lines
param style := 2;
end;
--
View this message in context:
http://www.nabble.com/glpsol-ignores-tmlim-tp25282380p25282380.html
Sent from the Gnu - GLPK - Bugs mailing list archive at Nabble.com.
- [Bug-glpk] glpsol ignores tmlim,
xypron <=