Sage sandpiles package

4 views
Skip to first unread message

davidp

unread,
Jul 19, 2009, 3:33:12 PM7/19/09
to sage-devel
I have been working on a Sage package for doing computations involving
the
Abelian Sandpile Model. In addition, this summer I am the mentor for
a Google
Summer of Code project which is a java application for visualizing and
analyzing sandpiles. The latest addition to the java program has been
the
ability to interact with Sage. For a glance at what has been going
on, I would
recommend:

www.reed.edu/~davidp/sand

especially

www.reed.edu/~davidp/sand/sage/html/sage_sandpiles.html

and

www.reed.edu/~davidp/sand/program/program.html

It would be great to get feedback from Sage users. The Google Summer
of Code
project will end in August, so if there are any features you would
like us to
add to the java application, please let us know as soon as possible.

Thanks,
Dave

Marshall Hampton

unread,
Jul 20, 2009, 12:25:20 AM7/20/09
to sage-devel
One minor typo: under "Self-organized criticality", "ascpect" should
be "aspect".

The documentation is excellent, that's quite impressive. As I am
unfamiliar with the subject, I haven't absorbed enough of it to make
really helpful comments but I will try to look more closely.

One thing that comes to mind is: could you help to make a 4ti2 package
for Sage? That would make the installation a lot easier. To start,
what platforms have you successfully installed it on? Have you
encountered any difficulties compiling from source?

Cheers,
Marshall

David Joyner

unread,
Jul 20, 2009, 7:59:35 AM7/20/09
to sage-...@googlegroups.com
On Sun, Jul 19, 2009 at 3:33 PM, davidp<dav...@reed.edu> wrote:
>
> I have been working on a Sage package for doing computations involving
> the
> Abelian Sandpile Model.  In addition, this summer I am the mentor for
> a Google
> Summer of Code project which is a java application for visualizing and
> analyzing sandpiles.  The latest addition to the java program has been
> the
> ability to interact with Sage.  For a glance at what has been going
> on, I would
> recommend:
>
>  www.reed.edu/~davidp/sand
>
> especially
>
>  www.reed.edu/~davidp/sand/sage/html/sage_sandpiles.html
>
> and
>
>  www.reed.edu/~davidp/sand/program/program.html
>
> It would be great to get feedback from Sage users.  The Google Summer


I've read the papers on RR spaces of graphs, and related papers using
tropical curves,
so am very happy to see that this is implemented. Long ago, I looked
at the chip-firing papers.
However, I had no idea that these topics were related and have
forgotten what I read
about that aspect anyway.

You asked for comments. Looking at
http://people.reed.edu/~davidp/sand/sage/html/sage_sandpiles.html#discrete-riemann-surfaces
and
http://people.reed.edu/~davidp/sand/sage/html/sage_sandpiles.html#projective
(in other words looking at the *output* of your code and not the code itself),
I have a few observations (which may or may not be useful or correct:-):

1) it seems to me that you have implemented rather hackish methods for
constructing and manipulating divisors on graphs. It would be nice if
they were implemented
in a way similar to divisors on curves (ie, as a class with methods
for addition, etc).

2) It seems you have a included some print statements for the r_of_D function:

sage: r_of_D = S.r_of_D(D)[0]
0
1
2
sage: r_of_F = S.r_of_D(F)[0]
0

though I am not sure. I would suggest having r_of_D return r(D) by
default and then
have an option 'algorithm = "verbose"' or something if you want to
output the divisor F
as well. I suggest eliminating the print statements. Typically and assignment
in Python (such as r_of_D = S.r_of_D(D)[0]) has no values printed to the screen.

3) You seem to have a non-standard method of describing a ring in Sage:

sage: g = {0:{},1:{0:1,3:1,4:1},2:{0:1,3:1,5:1},
3:{2:1,5:1},4:{1:1,3:1},5:{2:1,3:1}}
sage: S = Sandpile(g, 0)
sage: S.ring()

// characteristic : 0
// number of vars : 6
// block 1 : ordering dp
// : names x_5 x_4 x_3 x_2 x_1 x_0
// block 2 : ordering C


It seems to me the print method should, again, mirror that of the
base_ring method for an algebraic curve.


Overall though I think this is extremely interesting code and I'm
looking forward
to playing with it a lot more! This week I'm helping with advising new freshmen
who will be starting classes this fall, but will try to give you more detailed
comments as soon as I can.

davidp

unread,
Jul 20, 2009, 11:02:08 PM7/20/09
to sage-devel
Marshall and David: thanks very much for these suggestions.

Dave
> You asked for comments. Looking athttp://people.reed.edu/~davidp/sand/sage/html/sage_sandpiles.html#dis...
> andhttp://people.reed.edu/~davidp/sand/sage/html/sage_sandpiles.html#pro...

David Joyner

unread,
Jul 27, 2009, 5:30:55 PM7/27/09
to sage-...@googlegroups.com
I'm having trouble with 4ti installation. Maybe I'm just too impatient.
Do you have an spkg for it?

Marshall Hampton

unread,
Jul 31, 2009, 12:03:43 PM7/31/09
to sage-devel
I am trying to make an spkg for 4ti2, but I am having trouble getting
it to recognize GMP. I'm sure many people on this list are more
qualified than I am to figure that out.

t4i2 requires the linear programming package glpk, which I think I did
succeed in making an spkg for - at least it works on my mac, and its
pretty minimal so I would think it works on linux.

My current attempts are at:

http://www.d.umn.edu/~mhampton/4ti2.p0.spkg
http://www.d.umn.edu/~mhampton/glpk.p0.spkg

in case anyone wants to take a look and fix or improve them.

-Marshall

On Jul 27, 4:30 pm, David Joyner <wdjoy...@gmail.com> wrote:
> I'm having trouble with 4ti installation. Maybe I'm just too impatient.
> Do you have an spkg for it?
>
> On Mon, Jul 20, 2009 at 11:02 PM, davidp<dav...@reed.edu> wrote:
>
> > Marshall and David: thanks very much for these suggestions.
>
> > Dave
>
> > On Jul 20, 4:59 am, David Joyner <wdjoy...@gmail.com> wrote:
> >> On Sun, Jul 19, 2009 at 3:33 PM, davidp<dav...@reed.edu> wrote:
>
> >> > I have been working on a Sage package for doing computations involving
> >> > the
> >> > AbelianSandpileModel. In addition, this summer I am the mentor for
> >> sage: S =Sandpile(g, 0)

Marshall Hampton

unread,
Jul 31, 2009, 12:15:59 PM7/31/09
to sage-devel
I'm just editing the subject line to attract attention from people
like Mike Hansen who might have done overlapping work.

-Marshall

On Jul 31, 11:03 am, Marshall Hampton <hampto...@gmail.com> wrote:
> I am trying to make an spkg for 4ti2, but I am having trouble getting
> it to recognize GMP. I'm sure many people on this list are more
> qualified than I am to figure that out.
>
> t4i2 requires the linear programming package glpk, which I think I did
> succeed in making an spkg for - at least it works on my mac, and its
> pretty minimal so I would think it works on linux.
>
> My current attempts are at:
>
> http://www.d.umn.edu/~mhampton/4ti2.p0.spkghttp://www.d.umn.edu/~mhampton/glpk.p0.spkg

Marshall Hampton

unread,
Jul 31, 2009, 12:18:27 PM7/31/09
to sage-devel
OK, that was stupid of me, I should have looked in the experimental
packages first. There are older ones for 4ti2 and glpk, which might
solve my problems.

-Marshall

On Jul 31, 11:15 am, Marshall Hampton <hampto...@gmail.com> wrote:
> I'm just editing the subject line to attract attention from people
> like Mike Hansen who might have done overlapping work.
>
> -Marshall
>
> On Jul 31, 11:03 am, Marshall Hampton <hampto...@gmail.com> wrote:
>
> > I am trying to make an spkg for 4ti2, but I am having trouble getting
> > it to recognize GMP. I'm sure many people on this list are more
> > qualified than I am to figure that out.
>
> > t4i2 requires the linear programming package glpk, which I think I did
> > succeed in making an spkg for - at least it works on my mac, and its
> > pretty minimal so I would think it works on linux.
>
> > My current attempts are at:
>
> >http://www.d.umn.edu/~mhampton/4ti2.p0.spkghttp://www.d.umn.edu/~mham...

Dr. David Kirkby

unread,
Jul 31, 2009, 1:13:38 PM7/31/09
to sage-...@googlegroups.com
Marshall Hampton wrote:
> I am trying to make an spkg for 4ti2, but I am having trouble getting
> it to recognize GMP. I'm sure many people on this list are more
> qualified than I am to figure that out.
>
> t4i2 requires the linear programming package glpk, which I think I did
> succeed in making an spkg for - at least it works on my mac, and its
> pretty minimal so I would think it works on linux.
>
> My current attempts are at:
>
> http://www.d.umn.edu/~mhampton/4ti2.p0.spkg
> http://www.d.umn.edu/~mhampton/glpk.p0.spkg
>
> in case anyone wants to take a look and fix or improve them.
>
> -Marshall

I decided to download glpk and try it on Solaris.

I was going to congratulate you on there being no warnings messages from
the compiler, then thought I'd suggest the -Wall flag was added if the
compiler was the GNU one.

But then I see that any warnings are thrown to /dev/null

e.g.

gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT glpipp01.lo -MD
-MP -MF .deps/glpipp01.Tpo -c glpipp01.c -o glpipp01.o >/dev/null 2>&1

Personally I'd like to see all errors reported, not copied to /dev/null.

Dr. David Kirkby

unread,
Jul 31, 2009, 1:19:36 PM7/31/09
to sage-...@googlegroups.com
Dr. David Kirkby wrote:
> Marshall Hampton wrote:
>> I am trying to make an spkg for 4ti2, but I am having trouble getting
>> it to recognize GMP. I'm sure many people on this list are more
>> qualified than I am to figure that out.
>>
>> t4i2 requires the linear programming package glpk, which I think I did
>> succeed in making an spkg for - at least it works on my mac, and its
>> pretty minimal so I would think it works on linux.
>>
>> My current attempts are at:
>>
>> http://www.d.umn.edu/~mhampton/4ti2.p0.spkg
>> http://www.d.umn.edu/~mhampton/glpk.p0.spkg
>>
>> in case anyone wants to take a look and fix or improve them.
>>
>> -Marshall
>
> I decided to download glpk and try it on Solaris.
>
> I was going to congratulate you on there being no warnings messages from
> the compiler, then thought I'd suggest the -Wall flag was added if the
> compiler was the GNU one.

Sorry, I realised it was probably not you that wrote the glpk package,
and so it is not you throwing warnings to /dev/null.

But IMHO it would be worth removing the junk that throws warnings away,
then see what warnings there are on each OS and fix them. There seems to
be a few packages in Sage that hide warning messages - I'm not so sure
its a good idea to add more that do this.

Marshall Hampton

unread,
Jul 31, 2009, 4:18:58 PM7/31/09
to sage-devel
I agree, that doesn't sound good. At the moment, I just want to check
out the sandpile functionality, so I don't think I will wade in and
try to improve glpk, or bug the author to do so.

On the positive side, I think I now have packages that install
correctly, at least on my own mac. They are at:


http://www.d.umn.edu/~mhampton/4ti2.p0.spkg
http://www.d.umn.edu/~mhampton/glpk.p0.spkg

i.e. I have overwritten my previous broken versions.
This is also now trac ticket #6663 (http://trac.sagemath.org/sage_trac/
ticket/6663).

-Marshall

On Jul 31, 12:19 pm, "Dr. David Kirkby" <david.kir...@onetel.net>
wrote:

Dr. David Kirkby

unread,
Jul 31, 2009, 5:04:17 PM7/31/09
to sage-...@googlegroups.com
Marshall Hampton wrote:
> I agree, that doesn't sound good. At the moment, I just want to check
> out the sandpile functionality, so I don't think I will wade in and
> try to improve glpk, or bug the author to do so.
>
> On the positive side, I think I now have packages that install
> correctly, at least on my own mac. They are at:
>
>
> http://www.d.umn.edu/~mhampton/4ti2.p0.spkg
> http://www.d.umn.edu/~mhampton/glpk.p0.spkg
>
> i.e. I have overwritten my previous broken versions.
> This is also now trac ticket #6663 (http://trac.sagemath.org/sage_trac/
> ticket/6663).
>
> -Marshall

I'm not a mathematician, don't have a clue what this does, so I am
probably looking at this from a very different point of view to most.
But I don't think it's a good idea to include code that hides warnings.

Again, it's a personal thing but when I look at web sites, like Wolfram
Research's, which has 42 errors:

http://validator.w3.org/check?uri=www.wolfram.com&charset=%28detect+automatically%29&doctype=Inline&group=0

it always makes me wonder how seriously quality is taken.

In contrast the Sage site has zero errors:

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.sagemath.org%2F&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.654

Mathematicians I've worked worth have always paid a lot of attention to
detail - far more than I think engineers tend to. If someone covers up
their compiler errors, it makes me wonder whether sufficient attention
to detail is applied elsewhere.

If someone like WRI, Maplesoft etc wanted to try to point out the
disadvantages of Sage, showing how we hide warnings would be like giving
them ammunition to blow us up with.

I'm sure a lot of people will disagree with me, but personally I would
avoid adding things to sage that rely on code that is built like that.


Dave

William Stein

unread,
Jul 31, 2009, 5:21:08 PM7/31/09
to sage-...@googlegroups.com

I agree with you.  It is difficult to disagree with such a natural technical way to improve quality.

 -- William

Marshall Hampton

unread,
Jul 31, 2009, 5:38:20 PM7/31/09
to sage-devel
I'm not disagreeing, I just don't know how to quickly change that. If
someone can give me some tips I will at least patch the spkgs.

-Marshall

On Jul 31, 4:21 pm, William Stein <wst...@gmail.com> wrote:
> On Fri, Jul 31, 2009 at 2:04 PM, Dr. David Kirkby
> <david.kir...@onetel.net>wrote:
>
>
>
>
>
> > Marshall Hampton wrote:
> > > I agree, that doesn't sound good. At the moment, I just want to check
> > > out the sandpile functionality, so I don't think I will wade in and
> > > try to improve glpk, or bug the author to do so.
>
> > > On the positive side, I think I now have packages that install
> > > correctly, at least on my own mac. They are at:
>
> > >http://www.d.umn.edu/~mhampton/4ti2.p0.spkg<http://www.d.umn.edu/%7Emhampton/4ti2.p0.spkg>
> > >http://www.d.umn.edu/~mhampton/glpk.p0.spkg<http://www.d.umn.edu/%7Emhampton/glpk.p0.spkg>
>
> > > i.e. I have overwritten my previous broken versions.
> > > This is also now trac ticket #6663 (http://trac.sagemath.org/sage_trac/
> > > ticket/6663).
>
> > > -Marshall
>
> > I'm not a mathematician, don't have a clue what this does, so I am
> > probably looking at this from a very different point of view to most.
> > But I don't think it's a good idea to include code that hides warnings.
>
> > Again, it's a personal thing but when I look at web sites, like Wolfram
> > Research's, which has 42 errors:
>
> >http://validator.w3.org/check?uri=www.wolfram.com&charset=%28detect+a...
>
> > it always makes me wonder how seriously quality is taken.
>
> > In contrast the Sage site has zero errors:
>
> >http://validator.w3.org/check?uri=http%3A%2F%2Fwww.sagemath.org%2F&ch...

Willem Jan Palenstijn

unread,
Jul 31, 2009, 5:51:15 PM7/31/09
to sage-...@googlegroups.com
On Fri, Jul 31, 2009 at 01:18:58PM -0700, Marshall Hampton wrote:
>
> I agree, that doesn't sound good. At the moment, I just want to check
> out the sandpile functionality, so I don't think I will wade in and
> try to improve glpk, or bug the author to do so.
>
> On the positive side, I think I now have packages that install
> correctly, at least on my own mac. They are at:
>
>
> http://www.d.umn.edu/~mhampton/4ti2.p0.spkg
> http://www.d.umn.edu/~mhampton/glpk.p0.spkg
>
> i.e. I have overwritten my previous broken versions.
> This is also now trac ticket #6663 (http://trac.sagemath.org/sage_trac/
> ticket/6663).

There is also a more recent GLPK spkg at http://trac.sagemath.org/sage_trac/ticket/6602 , I believe.

-Willem Jan

Dr. David Kirkby

unread,
Jul 31, 2009, 6:08:07 PM7/31/09
to sage-...@googlegroups.com
Marshall Hampton wrote:
> I'm not disagreeing, I just don't know how to quickly change that. If
> someone can give me some tips I will at least patch the spkgs.
>
> -Marshall

There may be no quick fix, though the code did not look very large, so I
doubt it would be a huge job to do it properly.

The stages I would take would be:

1) Remove the copies to /dev/null.

2) Add -Wall to see all warning reported.

3) Build with the warnings displayed.

4) Contact the original author saying you would like to get his/her
package into Sage, but some are objecting since the warnings were
hidden. Point out what warnings you get.

5) Sort out why the compiler is complaining. That will take some time I
expect. Though you have the advantage the package is not very large.

Newsgroups are a good place to get help on how best to re-write code in
a portable way that avoids warnings. You could ask on gcc-help, saying
"this bit of code generates a warning, but I'm not sure why"



Dave

Marshall Hampton

unread,
Jul 31, 2009, 7:10:45 PM7/31/09
to sage-devel
Thanks for pointing that out. I am somewhat disturbed by the positive
review for that becoming a standard package, which seems inconsistent
with previous policy. In #6663 I am merely suggesting 4ti2 and glpk
as experimental packages, with the idea of transitioning them to
optional, and then maybe standard eventually.

Just to be clear, I have felt that in the past the hurdle for becoming
a standard package is too high. I just want the process to be
consistent.

-Marshall

David Joyner

unread,
Jul 31, 2009, 7:20:44 PM7/31/09
to sage-...@googlegroups.com
On Fri, Jul 31, 2009 at 7:10 PM, Marshall Hampton<hamp...@gmail.com> wrote:
>
> Thanks for pointing that out.  I am somewhat disturbed by the positive
> review for that becoming a standard package, which seems inconsistent


I don't know where you got that. I was the reviewer and I clearly said

"Positive review from me as far as I can tell, as an optional package."

Marshall Hampton

unread,
Jul 31, 2009, 7:32:01 PM7/31/09
to sage-devel
I got from Minh's comment:

"Once #6502 gets positive review, this SPKG could then be merged in
the Sage standard packages repository."

-Marshall

On Jul 31, 6:20 pm, David Joyner <wdjoy...@gmail.com> wrote:

Minh Nguyen

unread,
Jul 31, 2009, 7:41:45 PM7/31/09
to sage-...@googlegroups.com
Hi Marshall,

On Sat, Aug 1, 2009 at 9:32 AM, Marshall Hampton<hamp...@gmail.com> wrote:
>
> I got from Minh's comment:
>
> "Once #6502 gets positive review, this SPKG could then be merged in
> the Sage standard packages repository."

That was a typo on my part. It should be "optional" instead of
"standard". My apology for any inconveniences caused.

--
Regards
Minh Van Nguyen

David Joyner

unread,
Jul 31, 2009, 8:06:31 PM7/31/09
to sage-...@googlegroups.com
Thanks for trying this Marshall. Unfortunately, your spkg, and the
older experimental spkg,
for 4ti2, both fail to install on my amd64 ubuntu 9.04 machine. I have
N Cohen's version of the
glpk spkg installed.

Marshall Hampton

unread,
Jul 31, 2009, 8:26:54 PM7/31/09
to sage-devel
Can you put the source of the failure up at http://trac.sagemath.org/sage_trac/ticket/6663?

Thanks for trying it out!

Marshall

On Jul 31, 7:06 pm, David Joyner <wdjoy...@gmail.com> wrote:
> Thanks for trying this Marshall. Unfortunately, your spkg, and the
> older experimental spkg,
> for 4ti2, both fail to install on my amd64 ubuntu 9.04 machine. I have
> N Cohen's version of the
> glpk spkg installed.
>

David Joyner

unread,
Jul 31, 2009, 11:40:04 PM7/31/09
to sage-...@googlegroups.com
On Fri, Jul 31, 2009 at 8:26 PM, Marshall Hampton<hamp...@gmail.com> wrote:
>
> Can you put the source of the failure up at http://trac.sagemath.org/sage_trac/ticket/6663?


This failure I had was fake! Here's what I did. I first tried the evil
experimental
4ti2*.spkg. That deleted N Cohen's "good" glpk install from the sage tree
and installed its own version of glpk. The subsequent 4ti2 install failed.
(I posted the log to
http://sage.math.washington.edu/home/wdj/patches/4ti2-install1.log
if you care.)

I then tried to install your 4ti2, thinking I had the "good" glpk
installed but actually
I had the evil glpk installed. That install failed. That is the "fake" failure.

I think forced a reinstall of the good glpk, which happily destroyed
the evil one.
At this point, your 4ti2 installed sucessfully.

Because of all this craziness, I think in experimental
(1) the old 4ti2 should be removed and replaced by yours.
(2) the old glpk should be replaced by N Cohen's.
Reply all
Reply to author
Forward
0 new messages