Ask Your Question
0

Strange result with GLPK

asked 2019-10-16 11:11:25 +0100

Cyrille gravatar image

updated 2023-05-19 22:04:49 +0100

FrédéricC gravatar image

This program

%display latex
m=3
n=2 
A=matrix(m,n,(0,1,1,0,6,18))
bmin=[12,0,70]
bmax=[oo,10,70]
c=matrix(1,n,(4.1,8)) 
show(A,bmin,bmax,c)

p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") 
x = p.new_variable(integer=False, indices=[0..n-1]) # les nouvelles variables seront x[1]... x[7]}
B = A * x # m
for i in range(m):
    p.add_constraint(B[i], min=bmin[i], max=bmax[i])
for i in range(n):
    p.set_min(x[i],0)
p.set_objective(4.1*x[0]+8*x[1])    
p.show()
p.set_min(x[i],0)

p.set_objective(4.1x[0]+8x[1] p.show() p.solve()

has obviously no solution as show by the result of

z=p.polyhedron()
zz=z.vertices()
zz

(There are no vertices)

but

p.solve()

gives 96 and

valeurs=p.get_values(x) valeurs

gives

${0:0.0,1:12.0}$

but $18 *12 =216 \geq 70$ wich shows the assertion

edit retag flag offensive close merge delete

Comments

Please format the posted question so that all code is displayed as code. I am also not respecting the pep8 guiding lines in typing code, but some touch for the readability should be present in the lines, else it is hard to digest. So please let there be some space before and after the equal sign in the definition of variables.

dan_fulea gravatar imagedan_fulea ( 2019-10-16 12:40:59 +0100 )edit

Hello, @Cyrille. This problem has no polyhedron, as far as I can understand. If you see the third constraint in your problem, you will notice it is an equality (bmin[2] $=$ bmax[2]), which makes its plot a line.

On the other hand, I am wondering how you got the result for p.solve(), since I get that the MILP has no feasible solution, as in my answer below.

dsejas gravatar imagedsejas ( 2019-10-28 04:18:39 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-10-16 20:05:29 +0100

dsejas gravatar image

Hello, @Cyrille! I think you forgot to call p.solve(). It indicates me

MIPSolverException: GLPK: Problem has no feasible solution

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-10-16 11:11:25 +0100

Seen: 272 times

Last updated: Oct 16 '19