edge-neighbors of a facet

Questions and problems about using polymake go here.
soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

edge-neighbors of a facet

Postby soeren » 17 Sep 2012, 22:54

Hi,
is there a direct way to determine all edge-neighbors of a facet? That is, given a facet F of a polytope P find all facets of P which share a two-dimensional face with F.
I can extract this from the Hasse diagram, but I wonder if there is a more convenient/faster way to do this.

best regards,
Sören

User avatar
joswig
Main Author
Posts: 282
Joined: 24 Dec 2010, 11:10

Re: edge-neighbors of a facet

Postby joswig » 18 Sep 2012, 17:37

Essentially, this is the way to go. There is no standard function to do what you want. However, it suffices to have VERTICES_IN_FACETS and the 2-skeleton of the face lattice. You do not need to compute the entire face lattice. See here for how to compute partial face lattices.

soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

Re: edge-neighbors of a facet

Postby soeren » 28 Oct 2012, 14:43

Thank your very much.

I'm now trying to this using the callable library. Unfortunately I'm failing to access the desired information:

Code: Select all

// getting the hasse diagram and its faces property is no problem perl::Object hd=P->give("HASSE_DIAGRAM"); perl::Object faces = hd.give("FACES"); perl::ListResult dims1 = hd.ListCallPolymakeMethod("nodes_of_dim",1); for(int i=0, end=dims1.size(); i<end; ++i) Integer k = dims1[i];
The assignment in the for loop throws an exception I do not understand:
terminate called after throwing an instance of 'pm::perl::exception'
what(): Shared module compilation failed; see the error log below

/usr/local/include/polymake/graph/HasseDiagram.h:82:11: error: ‘struct polymake::graph::HasseDiagram::node_exists_pred’ is protected
/tmp/poly18653Taaaa0001.cc:8:4: error: within this context
make: *** [/tmp/poly18653Taaaa0001.o] Error 1
I don't have any idea how to access the data of HASSE_DIAGRAM->FACES, too. According to the ref() function it's of type NodeMap, which is undocumented. Hence I'm struggling to get the information equivalent to a call "print $p->HASSE_DIAGRAM->FACES;" in the polymake shell.

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: edge-neighbors of a facet

Postby gawrilow » 28 Oct 2012, 22:20

perl::Object is an appropriate receptacle for 'big' polymake objects only, not for their properties like FACES.

The easiest and most straightforward way to work with a face lattice in a C++ program is to load it all at once in an object of class graph::HasseDiagram. The class is defined in application graph:

Code: Select all

#include "polymake/graph/HasseDiagram.h" perl::Object hd_obj=P->give("HASSE_DIAGRAM"); const graph::HasseDiagram hd(hd_obj); const graph::HasseDiagram::nodes_of_dim_set dims1=hd.nodes_of_dim(1); for (int i=0, end=dims1.size(); i<end; ++i) ...
Faces are kept in a container with a public interface equivalent to a vector<Set<int>>, indexed by the node number.

soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

Re: edge-neighbors of a facet

Postby soeren » 05 Nov 2012, 21:04

Thank you very much for your reply.

I tried your suggestion and unfortunately

Code: Select all

const graph::HasseDiagram hd(hd_obj);
gives an error:

Code: Select all

/usr/local/include/polymake/graph/HasseDiagram.h:262: undefined reference to `polymake::graph::HasseDiagram::fromObject(pm::perl::Object const&)'
Does this mean that something with my polymake installation is wrong? I've been able to use the callable library normally until now.

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: edge-neighbors of a facet

Postby gawrilow » 05 Nov 2012, 23:43

...
Does this mean that something with my polymake installation is wrong?
No, but you are the first pioneer trying to call a function residing in an application shared module directly from an external program. The usual compiler/linker flags are not sufficient in this case. You should add the module graph.so (or .dylib if you are building on a Mac) to your linker command. It is located together with other applications' shared modules in the subdirectory polymake/lib (relative to the location of your libpolymake.so).

soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

Re: edge-neighbors of a facet

Postby soeren » 07 Nov 2012, 01:10

Thank you once again. I linked with the graph.so (building on ubuntu).
I'm getting a 'segmentation fault (core dumped)' error now, when starting the program.
I tried gdb and valgrind to figure out what went wrong(but eventually failed to do so)

gdb output:

Code: Select all

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff58e53fe in Perl_newSV_type () from /usr/lib/libperl.so.5.14
valgrind output:

Code: Select all

[...] ==9920== Invalid read of size 8 ==9920== at 0x71233FE: Perl_newSV_type (in /usr/lib/libperl.so.5.14.2) ==9920== by 0x54E66B3: pm::perl::ArrayHolder::init_me(int) (in /usr/local/lib/libpolymake.so) ==9920== by 0x59EC329: pm::perl::TypeListUtils<pm::Integer (pm::IncidenceMatrix<pm::NonSymmetric> const&)>::get_types(int) [clone .isra.140] (in /usr/local/lib/polymake/lib/graph.so) ==9920== by 0x59EC3AE: _GLOBAL__sub_I_wrap_altshuler_det.cc (in /usr/local/lib/polymake/lib/graph.so) ==9920== by 0x400F305: call_init.part.0 (dl-init.c:85) ==9920== by 0x400F3DE: _dl_init (dl-init.c:52) ==9920== by 0x40016E9: ??? (in /lib/x86_64-linux-gnu/ld-2.15.so) ==9920== Address 0x648 is not stack'd, malloc'd or (recently) free'd ==9920== ==9920== ==9920== Process terminating with default action of signal 11 (SIGSEGV) ==9920== Access not within mapped region at address 0x648 ==9920== at 0x71233FE: Perl_newSV_type (in /usr/lib/libperl.so.5.14.2) ==9920== by 0x54E66B3: pm::perl::ArrayHolder::init_me(int) (in /usr/local/lib/libpolymake.so) ==9920== by 0x59EC329: pm::perl::TypeListUtils<pm::Integer (pm::IncidenceMatrix<pm::NonSymmetric> const&)>::get_types(int) [clone .isra.140] (in /usr/local/lib/polymake/lib/graph.so) ==9920== by 0x59EC3AE: _GLOBAL__sub_I_wrap_altshuler_det.cc (in /usr/local/lib/polymake/lib/graph.so) ==9920== by 0x400F305: call_init.part.0 (dl-init.c:85) ==9920== by 0x400F3DE: _dl_init (dl-init.c:52) ==9920== by 0x40016E9: ??? (in /lib/x86_64-linux-gnu/ld-2.15.so) ==9920== If you believe this happened as a result of a stack ==9920== overflow in your program's main thread (unlikely but ==9920== possible), you can try to increase the size of the ==9920== main thread stack using the --main-stacksize= flag. ==9920== The main thread stack size used in this run was 8388608. [...]

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: edge-neighbors of a facet

Postby gawrilow » 07 Nov 2012, 12:00

Oh... probably my last suggestion was not the best one. I've never tried this myself. Indeed, trying to load graph.so too early (as one of the pre-requisit shared modules for your program) can lead to all kinds of nastiness.

Please try the following: remove graph.so from the linker command line and add an option -Wl,--warn-unresolved-symbols instead. The linker would still complain about unresolved methods of HasseDiagram class but at least won't stop building your program. Let's look where it crashes then...

soeren
Posts: 23
Joined: 12 Jul 2012, 22:25

Re: edge-neighbors of a facet

Postby soeren » 13 Nov 2012, 00:14

Sorry for the late post, I've been busy the last few days. After doing what you have suggested, the program compiles with the output:

Code: Select all

In function `HasseDiagram': /usr/local/include/polymake/graph/HasseDiagram.h:262: warning: undefined reference to `polymake::graph::HasseDiagram::fromObject(pm::perl::Object const&)
Now, the program actually starts running and crashes at the line with

Code: Select all

const graph::HasseDiagram hd(hd_obj);
Here is the relevant part of the stack trace from gdb:

#0 0x00007ffff752ba0f in pm::perl::glue::canned_container_access(interpreter*, sv*, magic*, sv*, char const*, int) ()
from /usr/local/lib/libpolymake.so
#1 0x00007ffff5bfc20f in Perl_mg_copy () from /usr/lib/libperl.so.5.14
#2 0x00007ffff5c1063c in Perl_av_fetch () from /usr/lib/libperl.so.5.14
#3 0x00007ffff751f8c8 in pm::perl::ArrayHolder::operator[](int) const () from /usr/local/lib/libpolymake.so
#4 0x00007fffb619ebf5 in pm::enable_if<void, (pm::perl::check_for_magic_storage<std::vector<int, std::allocator<int> > >::value)&&(pm::is_parseable<std::vector<int, std::allocator<int> > >::value)>::type pm::perl::Value::retrieve_nomagic<std::vector<int, std::allocator<int> > >(std::vector<int, std::allocator<int> >&) const () from /usr/local/lib/polymake/lib/graph.so
#5 0x00007fffb619c30b in polymake::graph::HasseDiagram::fromObject(pm::perl::Object const&) () from /usr/local/lib/polymake/lib/graph.so
#6 0x000000000041f82e in polymake::graph::HasseDiagram::HasseDiagram (this=0x7fffffffdb70, o=...)
at /usr/local/include/polymake/graph/HasseDiagram.h:262

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: edge-neighbors of a facet

Postby gawrilow » 13 Nov 2012, 23:50

This looks indeed dramatic. I'll try to reproduce this on the coming weekend. Sorry for the endless mess...


Return to “Helpdesk”