GPLK time limit

39 views
Skip to first unread message

hapm

unread,
Apr 6, 2014, 2:49:56 PM4/6/14
to sage-s...@googlegroups.com
Hi all,

I am trying to use the interface to use the Mixed Integer Programming features in Sage. One of the things I would like to do is to limit the execution time to a certain number of seconds and return the current best valid solution.

When trying to follow the instructions here: http://www.sagemath.org/doc/reference/numerical/sage/numerical/backends/glpk_backend.html#sage.numerical.backends.glpk_backend.GLPKBackend.solver_parameter
I run into problems.

When setting the timelimit parameter to 10 seconds for example and checking the value of the parameter afterwards, I can see it has been updated, but the program execution ignores the setting and just keeps running for a long time.
I tried setting instead to set the timelimit_intopt parameter to 10000, but when I do this, I get "ValueError: This parameter is not available."
I went to the code to check I was using the correct string and I see nothing wrong.

Can someone point me in the right direction?

I am using Sage 6.1.1 on Ubuntu 64 bits.

Thank you in advance for your valuable help

Nathann Cohen

unread,
Apr 8, 2014, 8:27:49 AM4/8/14
to sage-s...@googlegroups.com
Helloooooooooo !!

I am trying to use the interface to use the Mixed Integer Programming features in Sage. One of the things I would like to do is to limit the execution time to a certain number of seconds and return the current best valid solution.

This should be possible.
 
When setting the timelimit parameter to 10 seconds for example and checking the value of the parameter afterwards, I can see it has been updated, but the program execution ignores the setting and just keeps running for a long time.
I tried setting instead to set the timelimit_intopt parameter to 10000, but when I do this, I get "ValueError: This parameter is not available."
I went to the code to check I was using the correct string and I see nothing wrong.

Can someone point me in the right direction?

Can you give a shortest possible example of code that produces this problem ? 

Nathann

Hugo Monteiro

unread,
Apr 9, 2014, 5:29:12 PM4/9/14
to sage-s...@googlegroups.com
Hi,

Thank you for getting back to me.
it seems the problem lies in me using too small times. If I increase it to a few minutes, instead of a few seconds, it then interrupts computation as expected (although I still have to use the timelimit parameter, as the timelimit_intopt still gives an error)

My problem now is that I don't know how to access the best valid solution it managed to find within the time it ran.

How do you suggest I should proceed?

Hugo


--
You received this message because you are subscribed to a topic in the Google Groups "sage-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/F8dWJ_w3Mtg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Nathann Cohen

unread,
Apr 11, 2014, 6:53:59 AM4/11/14
to sage-s...@googlegroups.com
Hello Hugo !

I see, then perhaps this parameter from GLPK has no effect for such short times. Did you check whether  they know that it should only be set for longer times, I.e. is it mentioned somewhere in their documentation ?

I am answering your message with a mobile phone right now, unfortunately I have no working computer at the moment :-)

I do not know how you can access the "best solution it found" at that time, if getting the answers with the "get_values" method does not work. It depends on the internals of GLPK, and perhaps they do not store the best solution when the computations ended because of the time limit. If you need a temporary workaround, maybe you can try to set an approximation ratio instead of a time limit : the process will stop once the solver has found a solution which is not too far away from the optimal one, and in this case I remember that the solution can be accessed.

Well. I cannot do much at the moment without a computer, but the key to that is probably in the interface between Sage and GLPK, and possibly not very hard to solve : if GLPK has the feature, it can usually be exposed in Sage very quickly. Try to take a look at file sage/numerical/backends/glpk_backend.pyx, this is where everything happens and maybe you can solve your problem. And please submit a patch to Sage if you find the key to it, this would definitely be useful to others. Have fuuuuuun !!!!  Nathann

Hugo Monteiro

unread,
Apr 11, 2014, 7:01:17 AM4/11/14
to sage-s...@googlegroups.com
Thanks for the tips, I'll have a look.

Hugo
Reply all
Reply to author
Forward
0 new messages