Polymakes integer linear programming as callable library

Questions and problems about using polymake go here.
ren
Posts: 38
Joined: 03 May 2011, 15:21

Polymakes integer linear programming as callable library

Postby ren » 01 Feb 2012, 18:04

Hi,
I am trying to use some of Polymake's ilp routines through the callable library functionality, but I get an error message which I don't really tells me anything.
This is the piece of code I try to get working:

Code: Select all

#include <polymake/Main.h> #include <polymake/Matrix.h> #include <polymake/SparseMatrix.h> #include <polymake/Rational.h> #include <polymake/IncidenceMatrix.h> int main(){ try { perl::Object p("Polytope<Rational>"); p.take("VERTICES") << (ones_vector<Rational>() | 3*unit_matrix<Rational>(3)); Vector<Integer> lo(4); lo[0]=0; lo[1]=1; lo[2]=1; lo[3]=1; perl::Object o("LinearProgram<Rational>"); o.take("LINEAR_OBJECTIVE") << lo; p.take("LP") << o; IncidenceMatrix<NonSymmetric> inc = p.give("LP.MAXIMAL_FACE"); } catch (const std::exception& ex) { std::cerr << "ERROR: " << ex.what() << endl; return 1; } return 0; }
However upon running, it simply yields an segmentation error, and I don't know why.
Not sure whether the following piece of information will be useful to you, but this is what gdb is telling me:

Code: Select all

ren@mandelbrot:~/callable$ gdb smalltest GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/ren/callable/smalltest...(no debugging symbols found)...done. (gdb) r Starting program: /home/ren/callable/smalltest [Thread debugging using libthread_db enabled] Program received signal SIGSEGV, Segmentation fault. 0x00007ffff797c66f in pm::perl::ObjectType::find_type(char const*, unsigned long) () from /usr/local/lib/libpolymake.so (gdb) bt #0 0x00007ffff797c66f in pm::perl::ObjectType::find_type(char const*, unsigned long) () from /usr/local/lib/libpolymake.so #1 0x000000000040de1b in pm::perl::ObjectType::ObjectType<19ul>(char const (&) [19ul]) () #2 0x000000000040cc34 in pm::perl::Object::Object<19ul>(char const (&) [19ul]) () #3 0x000000000040a235 in main () (gdb)
thanks in advance, Yue.

blorenz
Developer
Posts: 139
Joined: 10 Jan 2011, 17:21

Re: Polymakes integer linear programming as callable library

Postby blorenz » 01 Feb 2012, 19:16

Hi,
Before you use anything from the callable library you need to initialize polymake::Main; and set the correct application. In your case you need to add the following lines to the beginning of main:

Code: Select all

Main pm; pm.set_application("polytope");
Furthermore LP.MAXIMAL_FACE has type Set<int>:

Code: Select all

Set<int> s = p.give("LP.MAXIMAL_FACE");
Ben

ren
Posts: 38
Joined: 03 May 2011, 15:21

Re: Polymakes integer linear programming as callable library

Postby ren » 02 Feb 2012, 10:57

thanks for the quick reply, I see where me error was.


Return to “Helpdesk”