Opened 7 years ago

Closed 7 years ago

#13234 closed enhancement (fixed)

Add Normaliz optional package

Reported by: novoselt Owned by: tbd
Priority: major Milestone: sage-5.6
Component: packages: optional Keywords:
Cc: john_perry Merged in: sage-5.6.beta0
Authors: Andrey Novoseltsev Reviewers: Dmitrii Pasechnik
Report Upstream: Fixed upstream, but not in a stable release. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by dimpase)

Normaliz http://www.mathematik.uni-osnabrueck.de/normaliz/ is one of the dependencies of Macaulay2 (which is also an optional package), but can be of interest on its own as well.

Install the spkg from here

Attachments (4)

t.in (35 bytes) - added by dimpase 7 years ago.
normaliz input for (x2,y2,z3)
t.out (789 bytes) - added by dimpase 7 years ago.
normaliz output
spkg-install (665 bytes) - added by novoselt 7 years ago.
For reviewing only
01-adjust-size-of-input-matrix-fix.patch (562 bytes) - added by novoselt 7 years ago.
For reviewing only

Download all attachments as: .zip

Change History (25)

comment:1 Changed 7 years ago by novoselt

  • Cc john_perry added
  • Status changed from new to needs_review

comment:2 follow-up: Changed 7 years ago by dimpase

  • Status changed from needs_review to needs_work

-static is not supported on MacOSX. There one gets:

...
ar -cr libnormaliz.a cone_property.o hilbert_series.o libnormaliz-templated.o
make normaliz
g++  -I/usr/local/src/sage/sage-5.2.rc0/local/include  -Wall -pedantic -Wno-long-long -O3 -funroll-loops -fopenmp -Wall -pedantic -Wno-long-long -O3 -funroll-loops -fopenmp -static Normaliz.cpp libnormaliz/libnormaliz.a -lgmpxx -lgmp -o normaliz
ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status
make[1]: *** [normaliz] Error 1
make: *** [linknormaliz] Error 2
Error building Normaliz.

It's probably better to build a dynamic library.

comment:3 in reply to: ↑ 2 Changed 7 years ago by dimpase

Replying to dimpase:

-static is not supported on MacOSX.

The file source/Makefile.configuration contains lines

##for mac link libgcc not static
NORMFLAGS = -static
#NORMFLAGS = -static-libgcc

If I set switch NORMFLAGS = -static-libgcc then on MacOSX 10.6.8 the spkg builds OK. It's a trivial matter to add an OS recognition to spkg-install and patch the said file if one happens to be on OSX.

comment:4 Changed 7 years ago by novoselt

  • Status changed from needs_work to needs_review

Winfried has also suggested to just remove this static option, I've updated the spkg and rewrote the installation script based on pyopenssl.

comment:5 Changed 7 years ago by dimpase

  • Status changed from needs_review to needs_info

OK, it builds on MacOSX 10.6. (with Sage 5.4.rc0). However, if I try to use the provided in the spkg Macaulay2 package Normaliz, it does not seem to work. I cd to the directory containing Normaliz.m2, start a standalone M2 version 1.4 within Sage shell, and then I get

i10 : installPackage "Normaliz"
stdio:11:1:(3): error: makeDocumentTag: package cannot be determined: 'Normaliz'
stdio:4:16-4:24: here is the first use of 'Normaliz'

I don't know enough M2 to know how to deal with it.

EDIT: it could be that this just means that a version of Normaliz is already present in this instance of M2 (and indeed, it is). So just ignore this, I guess. We'll sort it out when M2 Sage spkg will be ready.

Last edited 7 years ago by dimpase (previous) (diff)

comment:6 Changed 7 years ago by dimpase

As well, I don't know how to properly handle the Singular interface. Note that Normaliz provides an interface to Singular, in src/Singular/normaliz.lib.

On the other hand, Singular spkg provides normaliz.lib for version 2.7 of Normaliz. (Which is probably useless without Normaliz installed, and ought to be removed, but this is not for this ticket). I think one should make this spkg install normaliz.lib to its proper place in $SAGE_LOCAL.

Regarding M2 support, it can wait, but this one definitely needs work. I'd be happy to have another look after this is implemented.

comment:7 follow-up: Changed 7 years ago by novoselt

It seems to me that M2 just wants to have normaliz executable during installation, the interface package is included in M2 and does not have to be installed from normaliz one. So far my goal was just to have normaliz in sage/local/bin, but I'll look at the Singular library as well. I suspect it may be independent of the rest of normaliz - it is quite a compact program.

comment:8 in reply to: ↑ 7 Changed 7 years ago by dimpase

Replying to novoselt:

It seems to me that M2 just wants to have normaliz executable during installation, the interface package is included in M2 and does not have to be installed from normaliz one. So far my goal was just to have normaliz in sage/local/bin, but I'll look at the Singular library as well. I suspect it may be independent of the rest of normaliz - it is quite a compact program.

not according to the following lines

@*Singular and Normaliz exchange data via files. These files are automatically
created and erased behind the scenes. 

in Singular/singular.lib

So it is not something independent.

comment:9 Changed 7 years ago by novoselt

  • Status changed from needs_info to needs_review

Added library copying - I misunderstood what was going on, I thought it was a library file as in "objective code", not "Singular module".

comment:10 follow-up: Changed 7 years ago by dimpase

  • Status changed from needs_review to needs_work

after installing the spkg, one can call normaliz from Sage's singular_console(), (or just as sage -singular --- the results are the same) but results don't always make sense. E.g.

sage: singular_console()
                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-5
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Jul 2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "normaliz.lib";
// ** loaded /usr/local/src/sage/sage-5.5.rc0/local/share/singular/normaliz.lib $Id$
> ring R=0,(x,y,z,t),dp;
> ideal I=x^2,y^2,z^3;
> list l=intclMonIdeal(I);
> showNuminvs();
hilbert_basis_elements : 2
number_extreme_rays : 2
rank : 2
index : 1
number_support_hyperplanes : 2
size_triangulation : 1
sum_dets : 1
graded : 1
degree_1_elements : 2
grading : 1,-1
grading_denom : 1
multiplicity : 1
multiplicity_denom : 1
hilbert_series_num : 1
hilbert_series_denom : 1,1
primary : 1
ideal_multiplicity : 2
> 

whereas according to Singular docs the output should be

showNuminvs();
==> hilbert_basis_elements : 9
==> number_extreme_rays : 6
==> rank : 4
==> index : 1
==> number_support_hyperplanes : 5
==> homogeneous : 0
==> primary : 1
==> ideal_multiplicity : 12
Last edited 7 years ago by dimpase (previous) (diff)

Changed 7 years ago by dimpase

normaliz input for (x2,y2,z3)

comment:11 Changed 7 years ago by dimpase

If I try running normaliz directly on the input (roughly) corresponding to this example of the monomial ideal (see t.in), I get results consistent with Singular docs, see the t.out. So this looks like an interface problem.

Changed 7 years ago by dimpase

normaliz output

comment:12 Changed 7 years ago by dimpase

I also noticed that some normaliz.lib functions are not working as advertised, e.g.

> startNmz();
   ? open: Error for link _ of type: ASCII, mode: r, name: nmz_sing_exec.path
   ? cannot read from `nmz_sing_exec.path`
   ? error occurred in or before normaliz.lib::startNmz line 292: `    string s=read(inf); `
   ? expected string-expression. type 'help string;'
   ? leaving normaliz.lib::startNmz
   skipping text from `;` error at token `)`

instead of this. This is probably minor, as normaliz executable is found in the PATH. To make it work I can do

> setNmzDataPath("/tmp/");
> setNmzFilename("blah");
> writeNmzPaths();
> startNmz();
nmz_exec_path not set
nmz_data_path is /tmp/

If I then try the Singular input as above to compute intclMonIdeal(I) I can see that the files /tmp/blah.* created do not make sense. E.g. /tmp/blah.in is as follows:

1
1
2 
3

which makes little sense.

I would not be surprised if this is an upstream (i.e. normaliz) bug.

Last edited 7 years ago by dimpase (previous) (diff)

comment:13 in reply to: ↑ 10 Changed 7 years ago by dimpase

Replying to dimpase:

after installing the spkg, one can call normaliz from Sage's singular_console(), (or just as sage -singular --- the results are the same) but results don't always make sense. E.g.

sage: singular_console()
                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-5
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Jul 2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "normaliz.lib";
// ** loaded /usr/local/src/sage/sage-5.5.rc0/local/share/singular/normaliz.lib $Id$
> ring R=0,(x,y,z,t),dp;

If I rather set ring R=0,(x,y,z),dp; then the result is consistent with Singular's manual. So this looks like a documentation bug rather than anything more serious.

comment:14 Changed 7 years ago by dimpase

  • Report Upstream changed from N/A to Reported upstream. No feedback yet.

comment:15 Changed 7 years ago by novoselt

  • Report Upstream changed from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.
  • Status changed from needs_work to needs_review

I've added a patched based on the file sent to me by Christof Söger. Now I am getting

                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-5
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Jul 2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "normaliz.lib";
// ** loaded /home/novoselt/sage-5.5.rc0/local/share/singular/normaliz.lib $Id$
> ring R=0,(x,y,z,t),dp;
> ideal I=x^2,y^2,z^3;
> list l=intclMonIdeal(I);
No grading specified and cannot find one. Disabling some computations!
> showNuminvs();
hilbert_basis_elements : 9
number_extreme_rays : 6
rank : 4
index : 1
number_support_hyperplanes : 5
size_triangulation : 3
sum_dets : 7
graded : 0
primary : 1
ideal_multiplicity : 12
> 

which seems to be consistent with Singular manual.

Changed 7 years ago by novoselt

For reviewing only

Changed 7 years ago by novoselt

For reviewing only

comment:16 Changed 7 years ago by dimpase

OK, good - but could you please bump up the version to 2.8.p0, as this is not vanilla upstream.

comment:17 Changed 7 years ago by dimpase

  • Description modified (diff)
  • Reviewers set to Dmitrii Pasechnik
  • Status changed from needs_review to positive_review

I've made the spkg bumped up version (linked in the ticket description).

comment:18 Changed 7 years ago by novoselt

Thank you for a thorough review and quick responses despite my long pauses, it was a good spkg-exercise for me!

comment:19 Changed 7 years ago by jdemeyer

  • Component changed from packages to optional packages

comment:20 Changed 7 years ago by schilly

I just copied the spkg into the "optional" subdir on the server and mirrors.

comment:21 Changed 7 years ago by jdemeyer

  • Merged in set to sage-5.6.beta0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.