Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.libs.ppl.MIP_Problem: Add support for integer variables #20351

Closed
mkoeppe opened this issue Apr 3, 2016 · 18 comments
Closed

sage.libs.ppl.MIP_Problem: Add support for integer variables #20351

mkoeppe opened this issue Apr 3, 2016 · 18 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Apr 3, 2016

PPL's solver is a rational MIP solver.
Its support for integer variables should be exposed in Sage.

Reference: http://bugseng.com/products/ppl/documentation/user/ppl-user-1.2-html/classParma__Polyhedra__Library_1_1MIP__Problem.html

For sage.libs.ppl.MIP_Problem, I think one just needs to add a wrapper for this method:

void Parma_Polyhedra_Library::MIP_Problem::add_to_integer_space_dimensions(const Variables_Set &i_vars)	

and then a wrapper class for Variables_Set.

On another ticket (#20354), PPLBackend will be updated accordingly.

CC: @dimpase @videlec @jdemeyer

Component: numerical

Author: Matthias Koeppe

Branch/Commit: 9f35b65

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/20351

@mkoeppe mkoeppe added this to the sage-7.2 milestone Apr 3, 2016
@dimpase
Copy link
Member

dimpase commented Apr 3, 2016

comment:2

Good catch! I wish I knew this when I still had the student, who wrote the Cython bindings for the ppl LP, around. (He is now at Facebook...)

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 3, 2016

comment:5

Replying to @dimpase:

Good catch! I wish I knew this when I still had the student, who wrote the Cython bindings for the ppl LP, around. (He is now at Facebook...)

I'll write it if you review my other tickets ;)

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 4, 2016

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 4, 2016

Commit: 9f35b65

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Apr 4, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

9f35b65Wrap MIP_Problem.add_to_integer_space_dimensions

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 4, 2016

Author: Matthias Koeppe

@mkoeppe mkoeppe changed the title sage.libs.ppl.MIP_Problem and PPLBackend: Add support for integer variables sage.libs.ppl.MIP_Problem: Add support for integer variables Apr 4, 2016
@mkoeppe

This comment has been minimized.

@dimpase
Copy link
Member

dimpase commented Apr 4, 2016

comment:10

Are indices of variables 0-based, 1-based?
Could this info be added to docs?

@dimpase
Copy link
Member

dimpase commented Apr 4, 2016

comment:11

Can one use this to generate integer hull of a polytope defined by inequalities (perhaps after adjusting the corresponding Polyhedron code)?
Or is this optimisation-only thing?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 4, 2016

comment:12

Are indices of variables 0-based, 1-based?
Could this info be added to docs?

This is already documented in the class docstring of Variable. (It's 0-based.)

Can one use this to generate integer hull of a polytope defined by inequalities (perhaps after adjusting the corresponding Polyhedron code)?
Or is this optimisation-only thing?

No, PPL does not have code for computing integer hulls.
The closest that there is in the polyhedron code is the following interesting function:

void Parma_Polyhedra_Library::Polyhedron::drop_some_non_integer_points(Complexity_Class complexity = ANY_COMPLEXITY)	
Possibly tightens *this by dropping some points with non-integer coordinates.

I would be quite interested in having code in Sage that computes a polyhedron given only by a linear optimization oracle [for example, implemented by a MIP solver], see for example http://arxiv.org/pdf/1412.3987.pdf. But this has nothing to do with this ticket.

@dimpase
Copy link
Member

dimpase commented Apr 4, 2016

comment:13

IMHO in add_to_integer_space_dimensions one should have sig_on() inside try: block, not outside. And sig_off() should be immediately after the call to the backend.

see catch_interrupts()

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Apr 5, 2016

comment:14

The code in add_to_integer_space_dimensions matches the last example in the documentation that you cited. I'm assuming it's correct. Besides, it was copy-paste from elsewhere in ppl.pyx.

Alternatively, you can use try/finally which will also catch exceptions raised by subroutines inside the try:

def try_finally_example():
    sig_on()
    try:
        # (some long computation, potentially raising exceptions)
    finally:
        sig_off()
    return something

@dimpase
Copy link
Member

dimpase commented Apr 5, 2016

comment:15

OK, good. Although I am a bit concerned about few def statements that could be cdef or cpdef, for efficiency reasons.

@dimpase
Copy link
Member

dimpase commented Apr 5, 2016

Reviewer: Dima Pasechnik

@vbraun
Copy link
Member

vbraun commented Apr 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants