Re: [sage-devel] Re: sage and nfs
Hi Pablo >In my university, we have a room with 24 computers and one nfs server >serving the home folders for all of them. SAGE is installed in each of >the computers individually. As the course progresses, we're running into >severe performance problems when using SAGE in this setting. We have now >switched to local access, and we can proceed with the course without >problems, but we'd like to have the home folders shared between the >different computers if at all possible. > * If only one, or a few computers log in, performance is good. > * If all the students use SAGE at once with local access, performance >is good, too. > * When they log into their nfs accounts, performance is poor but, >after a while that is getting longer, students can work normally. > * As a side comment, the nfs server seems to have enough RAM, CPU and >bandwith idle when all the computers struggle to open up SAGE. > So I'd say our problem is related to the big size of the .mozilla and >.sage folders going through the nfs folder (compared to the small >configuration folders of other programs). As the course progresses, >these folders are getting bigger, and that would explain the performance >issues and non-issues. > > My questions are: > * Does this make sense to you? > * Has any of you tried a similar configuration? > * Any hints on how we can get shared folders back? Maybe samba would >do better? Maybe rsync the folders on login and logout? Maybe use a >single SAGE server? I run a Ubuntu Dapper server with 130 NFS clients. The server is a SUN V60X with 6G RAM and 2x 3Ghz xeon chips, 7 years old, still running strong. It has 6x U320 scsi 10KRPM SCSI disks in hardware RAID5. Recently it had problems when 50 users were already on and then a group of 54 students walked into a lab and logged on simutlaneously to start sage. There were problems without SAGE, but this was, I think, worse during the SAGE course. Though CPU usage and RAM usage were low, I/O would spike and I/O wait climb to 30% or 50% or more for 30 minutes, and Load Average would climb from 0.1 to 25 for 30 minutes. Users would have 30s to 120s waits on a click on a gnome desktop (all clients are Linux too), and hard restart machines. This despite the desktop clients recently having been upgraded from 2.4Ghz/512M_RAM/7200RPM_disks to 3.0Ghz/4G_RAM/10KRPM_disks. Running the package sysstat collects stats and commands sar and sar -b showed clearly that I/O was the culprit on the server. The package htop is a great improvement on top though doesn't show the i/o wait by default. I had already fixed a mozilla problem in Ubuntu Jaunty clients downloading 61M .mozilla/firefox/default.87w/urlclassifier3.sqlite (each user stores this huge anti-phishing file, but even when that was solved) mozilla caused server slowdown, more so than just gnome. The versions of sage did not matter, 4.0 through 4.1, patched to save space, /usr/local/src/sage/devel/sage-AIMS-autosave-patch/sage/server/notebook/user_conf.py we set 'max_history_length':10 # default was 100 'autosave_interval':120*60 # default was 60*60 I'm not sure whether less sage auto-saving activity here also helps reduce the load on the NFS server. The sage installs are local to each PC in /usr/local/src/, but the .sage directories are on the central home server. Each student has a desktop icon running sage -notebook on their own PC. I did the following: - upgrade the RAM from 3G to 6G. Services on that server (imap, print, dhcp, some other things run next to NFS) use little RAM, but the kernel file cache fills up all of it! I believe this helps a little to moderate the effects during load. - install the linux-server-kernel from ubuntu, which uses a deadline I/O scheduler and more tweaks: http://www.ubuntu.com/products/whatisubuntu/serveredition/features/kernel This made a massive difference, the load only climbs to 14 after that, and it only climbs for 10 minutes, and the lag on clients is only around 10s during that time. I have not had to make other tweaks. I am looking at two new SUN X4150 with 8G RAM, 8x300G SAS drives on hardware raid 6, and drbd (software network raid 0) over it as upgrades which will probably improve the speed. I can now relax as the kernel scheduler has reduced this problem to be less of a priority. One idea was to move just .sage locally (like your rsync idea). My first reaction as system admin is that it is a bit of a cowboy hack, not a clever tweak. But there may be merit. There is local scracth space on each client. Students tend to sit in the same spot so I may not even have to rsync all the time if they stuck to the same computer. Just make a .sage symlink into local space and let sage create files there. Or to have some preservation make a .sage-on-nfs which rsyncs to/from a local .sage each login/logout. Rsyncing around login time seems clunky, perhaps offload it to the user with a "backup sage history to file server" icon and a reverse one "get sage history fro
[sage-devel] Re: sage and nfs
> > > The worsheets are very small objects; so I guess that the problem is > somewhere else. > Maybe the .mozilla folder is responsible. Or maybe sage attempts to browse the .sage directory and that causes nfs to transfer all the files. My .sage folder is 150mb big. > If your nfs server is a linux machine, try to optimize it. There are > some references about this: have more nfs daemons, have larger packet > size. But may be you an other sort of network problem. > Another colleague has been looking at that. He's puzzled that the server remains responsive at all times, with spare cpu, ram and bandwidth. He tried some performance tuning, but only achieved minor improvements. > > What sort of server? Is it by chance Solaris with ZFS file systems? If > so, I > probably know the answer. No, I think it's Fedora with ext3 > > Which version of Sage is installed? I have to check. We were using 4.1.1, but I'm not sure if we have already updated to 4.2. Thanks Pablo -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: Test sites for NSF education grant
Hi Nicolas, We've been told non-US institutions are possible. Obviously, for logistical reasons, and given the nature of our possible funding, we'll probably favor places in the US that are close to one or more of the main folks on the grant. Please consider sending me a very short description of how you might want to be involved and we will certainly consider it in the mix of what we have already (which at this point isn't a real huge group). Thanks, Rob -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] getting python objects wrapped in symbolic expressions
From IRC: ncohen this is getting really annoying.05:47 ncohen when I have an equation of the form 05:48 ncohen x + 2*y + 3 05:48 ncohen with var('x y') 05:48 ncohen how can I get the "2" which is a coefficient of y ? 05:48 ncohen I mean the real "2" 05:48 ncohen when I try .coefficient(y) 05:48 ncohen what is returned is an expression !!05:48 ncohen I would like to have an integer in this case05:48 ncohen but it may be a float, etc 05:49 Nathann, use .pyobject() on a symbolic constant to get back the wrapped python/Sage object. Check out the following example and some recent sage-devel posts on this subject: sage: eq=RR(2.4)*x+4*y+(1/2)*x^2 sage: eq 1/2*x^2 + 2.4*x + 4*y sage: eq.coefficient(x^2) 1/2 sage: type(eq.coefficient(x^2)) sage: eq.coefficient(x^2).pyobject() 1/2 sage: type(eq.coefficient(x^2).pyobject()) sage: eq.coefficient(x).pyobject() 2.40 sage: type(eq.coefficient(x).pyobject()) sage: eq.coefficient(y).pyobject() 4 sage: type(eq.coefficient(y).pyobject()) Thanks, Jason -- Jason Grout -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: Printing...
Florent Hivert wrote: > Hi there, > > I'll use the excuse that I'm now writing on a laptop in a train for not having > searched if this as already been discussed... > > Is there a limitation somewhere (apart of course the available free time of > the developers) which prevent us from improving the following ugly printing ? > > sage: m = matrix(2,2) > sage: [m, m, m] > > [[0 0] > [0 0], [0 0] > [0 0], [0 0] > [0 0]] > The patch is already done and waiting on trac for several months: http://trac.sagemath.org/sage_trac/ticket/1918 You just have to update a bunch of doctests and review the patch! Here's an output: sage: list(MatrixSpace(GF(2),2)) [ [0 0] [1 0] [0 1] [0 0] [0 0] [1 1] [1 0] [1 0] [0 1] [0 1] [0 0], [0 0], [0 0], [1 0], [0 1], [0 0], [1 0], [0 1], [1 0], [0 1], [0 0] [1 1] [1 1] [1 0] [0 1] [1 1] [1 1], [1 0], [0 1], [1 1], [1 1], [1 1] ] Thanks, Jason -- Jason Grout -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: sage program icons
On Nov 26, 10:13 pm, Christopher Olah wrote: > That's awesome. Thanks ;) The 16x16 one looks ugly, but that's no wonder. But the svg one and since I know they are maybe a bit larger, I also thought about some additional tweaks like shading or offsetting the logo. Any ideas or wishes? H -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
> > Could you elaborate ? What's makes you skeptical ? > > Two things, mostly. The huge amount of code that wasn't being merged > -- that appears to now be merged :) And the whole categories/generic > code effort: while I support the ends, I'm worried that the system > will become so slow that it is unusable in practice. Which is > strange, because I'm not usually the one arguing for efficiency over > clarity! The only thing It could make slow is the creation of some parent, since it only change inheritance. After that whether a methods is inherited from a class or another one shouldn't change anything in the speed. So unless (like me :-) you like creating new parent everything should be alright. Let me explain the smiley. I'm currently testing a conjecture whose input is a monoid so in the next windows on my screen sage it writing a lot of things and in particular creating a new monoid every two second. > >> But if you guys allow me to view a multivariate polynomial ring as a > >> module over its base ring I will be very grateful. > > > > Of course they are ! I have no clue about why you say that ? Could > > you explain > > yourself ? So what ? > > I know they are mathematically, but at the moment it's very hard to > take QQ['x', 'y'] and view it as a vector space over QQ. Essentially, > it's not easy to say that monomials x^i*y^j are the basis for some > free module over QQ, and have sage convert back and forth. But it > sounds like you can do that too! I remember fixing the very same problem in MuPAD a few years ago. I remember fixing it for matrices as well :-). That's typically a problem categories are designed to solve. Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On 26-Nov-09, at 12:23 PM, Florent Hivert wrote: >>> On Thu, Nov 26, 2009 at 08:30:53AM -0800, YannLC wrote: Just a toy implementation as a very thin layer over dict (at least it should be fast) >>> >>> That's precisely what CombinatorialFreeModule elements are :-) >>> >>> Further optimizations to it are most welcome (For example, I am not >>> sure += is implemented there)! >>> >>> Yes, the name is bad: there is nothing combinatorial to it. Merging >>> this into FreeModule so that one could do FreeModule(QQ, >>> Objects()) is >>> part of the future plan. >> >> I have been an observer of the sage-combinat process since its >> inception and, I must say, I have been mildly skeptical (very >> mildly). > > Could you elaborate ? What's makes you skeptical ? Two things, mostly. The huge amount of code that wasn't being merged -- that appears to now be merged :) And the whole categories/generic code effort: while I support the ends, I'm worried that the system will become so slow that it is unusable in practice. Which is strange, because I'm not usually the one arguing for efficiency over clarity! >> But if you guys allow me to view a multivariate polynomial ring as a >> module over its base ring I will be very grateful. > > Of course they are ! I have no clue about why you say that ? Could > you explain > yourself ? So what ? I know they are mathematically, but at the moment it's very hard to take QQ['x', 'y'] and view it as a vector space over QQ. Essentially, it's not easy to say that monomials x^i*y^j are the basis for some free module over QQ, and have sage convert back and forth. But it sounds like you can do that too! Nick -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] sage program icons
That's awesome. You don't know how much time I wasted searching for something like that recently. (OK, not that much, ~20 min). But these are nice. Thanks. Now I have proper icons to set up on some workstations... On Thu, Nov 26, 2009 at 1:38 PM, Harald Schilly wrote: > Hi, I've created some program icons. > > http://sage.math.washington.edu/home/schilly/icon/ > > It might be a good idea to include them in Sage, so that it is easier > to create a launcher with a nice icon. > > H > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel-unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org -- Christopher Olah Email: christopherolah...@gmail.com -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
> > On Thu, Nov 26, 2009 at 08:30:53AM -0800, YannLC wrote: > >> Just a toy implementation as a very thin layer over dict (at least it > >> should be fast) > > > > That's precisely what CombinatorialFreeModule elements are :-) > > > > Further optimizations to it are most welcome (For example, I am not > > sure += is implemented there)! > > > > Yes, the name is bad: there is nothing combinatorial to it. Merging > > this into FreeModule so that one could do FreeModule(QQ, Objects()) is > > part of the future plan. > > I have been an observer of the sage-combinat process since its > inception and, I must say, I have been mildly skeptical (very mildly). Could you elaborate ? What's makes you skeptical ? > But if you guys allow me to view a multivariate polynomial ring as a > module over its base ring I will be very grateful. Of course they are ! I have no clue about why you say that ? Could you explain yourself ? So what ? Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On 26-Nov-09, at 10:18 AM, Nicolas M. Thiery wrote: > On Thu, Nov 26, 2009 at 08:30:53AM -0800, YannLC wrote: >> Just a toy implementation as a very thin layer over dict (at least it >> should be fast) > > That's precisely what CombinatorialFreeModule elements are :-) > > Further optimizations to it are most welcome (For example, I am not > sure += is implemented there)! > > Yes, the name is bad: there is nothing combinatorial to it. Merging > this into FreeModule so that one could do FreeModule(QQ, Objects()) is > part of the future plan. I have been an observer of the sage-combinat process since its inception and, I must say, I have been mildly skeptical (very mildly). But if you guys allow me to view a multivariate polynomial ring as a module over its base ring I will be very grateful. Nick -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Nov 26, 9:31 am, Simon King wrote: > InfinitePolynomialRing has an underlying *finite* polynomial ring, > that changes whenever you need a variable that is not in the finite > ring. Hi, I have seen this thread has various aspects and I don't know the details, but just reading this it reminds me of dynamic arrays. I think it could be enhanced by allocating a bigger new finite polynomial ring. In the end the usecase of adding new variables should be very common. I suggest to increase it by floor(size*0.6) since this is afaik a good value for that type of operation. I have read that there is a penalty with overestimations, probably there should also be a method to compact it? H -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] sage program icons
Hi, I've created some program icons. http://sage.math.washington.edu/home/schilly/icon/ It might be a good idea to include them in Sage, so that it is easier to create a launcher with a nice icon. H -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Thu, Nov 26, 2009 at 05:09:13PM +0100, Florent hivert wrote: > > On Thu, Nov 26, 2009 at 06:54:43AM -0800, Nathann Cohen wrote: > > > Actually, I use these polynomials to emulate what your > > > CombinatorialFreeModule does on a much larger basis : everything that > > > is hashable ;-) > > > > > > I want to be able to index my variables with sets, with edges, with > > > nodes, with almost anything we can come up with in Sage... > > > > sage: F = CombinatorialFreeModule(QQ, Objects()) > > sage: x = F.basis() > > sage: x[1] + x[2.5] + x[Partition([3,2,1])] + x [ QQ ] + x[gap] + > > x[x[3]+x[2]] > > B[2.50] + B[1] + B[B[2] + B[3]] + B[Gap] + B[[3, 2, 1]] + > > B[Rational Field] > > > > Good enough? :-) > > Nice :-) ? > > Now I see the point to not requiring that the basis of a > CombinatorialFreeModule is an EnumeratedSets... Yeah, enumerating Objects() might be an issue :-) Although, technically, there are only a countable number of objects that one can construct in Sage! Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Thu, Nov 26, 2009 at 08:30:53AM -0800, YannLC wrote: > Just a toy implementation as a very thin layer over dict (at least it > should be fast) That's precisely what CombinatorialFreeModule elements are :-) Further optimizations to it are most welcome (For example, I am not sure += is implemented there)! Yes, the name is bad: there is nothing combinatorial to it. Merging this into FreeModule so that one could do FreeModule(QQ, Objects()) is part of the future plan. Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: sage and nfs
Pablo Angulo wrote: > Hello: > In my university, we have a room with 24 computers and one nfs server > serving the home folders for all of them. SAGE is installed in each of > the computers individually. As the course progresses, we're running into > severe performance problems when using SAGE in this setting. We have now > switched to local access, and we can proceed with the course without > problems, but we'd like to have the home folders shared between the > different computers if at all possible. Which version of Sage is installed? Jaap -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] sage and nfs
Pablo Angulo wrote: > Hello: > In my university, we have a room with 24 computers and one nfs server > serving the home folders for all of them. What sort of server? Is it by chance Solaris with ZFS file systems? If so, I probably know the answer. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Just a toy implementation as a very thin layer over dict (at least it should be fast) no doc - first see it in action: sage: x=Test() sage: p=x.zero_element() sage: time for i in range(1): p+=x[i] CPU times: user 0.10 s, sys: 0.00 s, total: 0.10 s Wall time: 0.10 s sage: time q=p*3 CPU times: user 0.04 s, sys: 0.00 s, total: 0.04 s Wall time: 0.05 s sage: time q-(2*p+p) CPU times: user 0.10 s, sys: 0.00 s, total: 0.10 s Wall time: 0.10 s 0 sage: time r=sum([x[i] for i in range(1)],x.zero_element()) CPU times: user 2.69 s, sys: 0.00 s, total: 2.70 s Wall time: 2.70 s sage: time p==r CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s Wall time: 0.00 s True sage: x[1] + x[2.5] + x[Partition([3,2,1])] + x [ QQ ] + x[gap] + x[x [3]+x[2]] 1*B[2.50] + 1*B[1] + 1*B[Gap] + 1*B[ 1*B[2] + 1*B[3] ] + 1*B[[3, 2, 1]] + 1*B[Rational Field] (NB: += is way faster than +) - if it can help, here is the code: class Test(UniqueRepresentation): def __getitem__(self,x): return TestElement(x) def zero_element(self): return TestElement({}) class TestElement: def __init__(self, x): if isinstance(x,dict): self._dict=dict(x) else: self._dict={x:1} def __add__(self,other): out = TestElement(self._dict) return out.__iadd__(other) def __sub__(self,other): out = TestElement(self._dict) return out.__isub__(other) def __mul__(self,k): out = TestElement(self._dict) return out.__imul__(k) def __rmul__(self,k): out = TestElement(self._dict) for x,v in out._dict.iteritems(): out._dict[x]= k*v return out def __div__(self,k): out = TestElement(self._dict) return out.__idiv__(k) def __iadd__(self,other): d = self._dict for i,c in other._dict.iteritems(): if i in d: d[i] += c if not d[i]: del d[i] else: d[i] = c return self def __isub__(self,other): d = self._dict for i,c in other._dict.iteritems(): if i in d: d[i] -= c if not d[i]: del d[i] else: d[i] = c return self def __imul__(self,k): for x,v in self._dict.iteritems(): self._dict[x]=v*k return self def __idiv__(self,k): for x,v in self._dict.iteritems(): self._dict[x]=k/v return self def __getitem__(self,i): return self._dict.get(i,0) def __setitem__(self,x,v): self._dict[x]=v def __repr__(self): if len(self._dict) == 0: return "0" return '+'.join([" %s*B[%s] "%(str(v),str(x)) for x,v in self._dict.iteritems()]) def __hash__(self): return hash(frozenset(self._dict)) def __cmp__(self,other): return self._dict.__cmp__(other._dict) -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
> On Thu, Nov 26, 2009 at 06:54:43AM -0800, Nathann Cohen wrote: > > Actually, I use these polynomials to emulate what your > > CombinatorialFreeModule does on a much larger basis : everything that > > is hashable ;-) > > > > I want to be able to index my variables with sets, with edges, with > > nodes, with almost anything we can come up with in Sage... > > sage: F = CombinatorialFreeModule(QQ, Objects()) > sage: x = F.basis() > sage: x[1] + x[2.5] + x[Partition([3,2,1])] + x [ QQ ] + x[gap] + x[x[3]+x[2]] > B[2.50] + B[1] + B[B[2] + B[3]] + B[Gap] + B[[3, 2, 1]] + > B[Rational Field] > > Good enough? :-) Nice :-) ? Now I see the point to not requiring that the basis of a CombinatorialFreeModule is an EnumeratedSets... Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Google Wave again...
On Wed, Nov 25, 2009 at 10:54 PM, Nathann Cohen wrote: > Hello !! > > I have some invitations for Wave left... If you are interested, leave > your email here ! > Nathann > > Same here. Ask for any if you want. > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel-unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- Tim Joseph Dumol http://timdumol.com -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Thu, Nov 26, 2009 at 06:54:43AM -0800, Nathann Cohen wrote: > Actually, I use these polynomials to emulate what your > CombinatorialFreeModule does on a much larger basis : everything that > is hashable ;-) > > I want to be able to index my variables with sets, with edges, with > nodes, with almost anything we can come up with in Sage... sage: F = CombinatorialFreeModule(QQ, Objects()) sage: x = F.basis() sage: x[1] + x[2.5] + x[Partition([3,2,1])] + x [ QQ ] + x[gap] + x[x[3]+x[2]] B[2.50] + B[1] + B[B[2] + B[3]] + B[Gap] + B[[3, 2, 1]] + B[Rational Field] Good enough? :-) Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] sage and nfs
Here we use NFS and Sage: we have 3 computers. The first one receives all the users'directories in a directory /ws. /ws is exported to the 2nd and 3rd computer and we have no performance problems. But ok, this is not the same configuration as yours where you have a lot of computers and only one nfs server. The worsheets are very small objects; so I guess that the problem is somewhere else. If your nfs server is a linux machine, try to optimize it. There are some references about this: have more nfs daemons, have larger packet size. But may be you an other sort of network problem. t.d. Pablo Angulo a écrit : > Hello: > In my university, we have a room with 24 computers and one nfs server > serving the home folders for all of them. SAGE is installed in each of > the computers individually. As the course progresses, we're running into > severe performance problems when using SAGE in this setting. We have now > switched to local access, and we can proceed with the course without > problems, but we'd like to have the home folders shared between the > different computers if at all possible. > These are the clues to the issue: > * Other courses, running other software, use the nfs mounted home > folders with no problem, and with all the students logging in at the > same time. > * If only one, or a few computers log in, performance is good. > * If all the students use SAGE at once with local access, performance > is good, too. > * When they log into their nfs accounts, performance is poor but, > after a while that is getting longer, students can work normally. > * As a side comment, the nfs server seems to have enough RAM, CPU and > bandwith idle when all the computers struggle to open up SAGE. > So I'd say our problem is related to the big size of the .mozilla and > .sage folders going through the nfs folder (compared to the small > configuration folders of other programs). As the course progresses, > these folders are getting bigger, and that would explain the performance > issues and non-issues. > > My questions are: > * Does this make sense to you? > * Has any of you tried a similar configuration? > * Any hints on how we can get shared folders back? Maybe samba would > do better? Maybe rsync the folders on login and logout? Maybe use a > single SAGE server? > > Thanks > <> smime.p7s Description: S/MIME Cryptographic Signature
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Actually, I use these polynomials to emulate what your CombinatorialFreeModule does on a much larger basis : everything that is hashable ;-) I want to be able to index my variables with sets, with edges, with nodes, with almost anything we can come up with in Sage... Nathann On Nov 26, 3:39 pm, "Nicolas M. Thiery" wrote: > On Thu, Nov 26, 2009 at 05:29:47AM -0800, YannLC wrote: > > If you only want linear terms, you can also use an univariate > > polynomial ring > > > just treat x^i as x_i. > > > it's lightning fast and allow you to easily access coefficients. > > Variant: > > sage: F =CombinatorialFreeModule(QQ, NonNegativeIntegers()) > sage: x = F.basis() > sage: x[3] + 2* x[8] > B[3] + 2*B[8] > sage: f = x[3] + 2* x[8] > sage: f[8] > 2 > > This models more straightforwardly your problem. However, it's > currently (by far) not as fast as polynomials. This slowness will be > fixed as soon as the sparse free module code will have been > generalized to handle FreeModule(QQ, infinity). > > Best, > Nicolas > -- > Nicolas M. Thi ry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Thu, Nov 26, 2009 at 05:29:47AM -0800, YannLC wrote: > If you only want linear terms, you can also use an univariate > polynomial ring > > just treat x^i as x_i. > > it's lightning fast and allow you to easily access coefficients. Variant: sage: F =CombinatorialFreeModule(QQ, NonNegativeIntegers()) sage: x = F.basis() sage: x[3] + 2* x[8] B[3] + 2*B[8] sage: f = x[3] + 2* x[8] sage: f[8] 2 This models more straightforwardly your problem. However, it's currently (by far) not as fast as polynomials. This slowness will be fixed as soon as the sparse free module code will have been generalized to handle FreeModule(QQ, infinity). Best, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Then I think you found the very thing I needed... Thank you !!! :-) I do not need 1 millions variables, but clearly I do not want the computations to be too slow under 1.. If I have something like 1000 variables, I very often have 5000 or more functions to define and work on, so I need the symbolic expression to be handled easily by Sage ! Nathann On Nov 26, 3:15 pm, YannLC wrote: > because you use dense representation. > > Try P.=PolynomialRing(QQ,sparse=True) > > By the way, do you need QQ? RR or ZZ would probably be faster. > > On Nov 26, 3:06 pm, Nathann Cohen wrote: > > > I could cache the results... But I still do not understand why just > > evaluating x^99 takes so much time ! > > You really need 1 million variables?! -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Nov 26, 2:17 pm, Simon King wrote: [...] > However, if I understood correctly, you have a *uni*variate polynomial > ring, right? So, probably you can disregard what I just said, since > univariate polynomial rings are different from multivariate (based on > ntl? not sure...) . Yep, as pointed out by Yann... -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Nathann! On Nov 26, 2:06 pm, Nathann Cohen wrote: > I could cache the results... But I still do not understand why just > evaluating x^99 takes so much time ! I guess this is a limitation of Singular. In Singular, exponents are restricted to 32767. Usually, multivariate polynomial rings in Sage are based on libSingular, and I guess it has the same limitation. Compare http://www.singular.uni-kl.de/Manual/latest/sing_343.htm#SEC384 So, if you have a larger exponent, Sage has to fall back to a different (and probably much slower) implementation. However, if I understood correctly, you have a *uni*variate polynomial ring, right? So, probably you can disregard what I just said, since univariate polynomial rings are different from multivariate (based on ntl? not sure...) . Perhaps there are similar limitations? Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
because you use dense representation. Try P.=PolynomialRing(QQ,sparse=True) By the way, do you need QQ? RR or ZZ would probably be faster. On Nov 26, 3:06 pm, Nathann Cohen wrote: > I could cache the results... But I still do not understand why just > evaluating x^99 takes so much time ! You really need 1 million variables?! -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: Google Wave again...
On 25 nov, 15:54, Nathann Cohen wrote: > Hello !! > > I have some invitations for Wave left... If you are interested, leave > your email here ! > Nathann I would like to try it. My email is mma...@unizar.es Miguel Marco -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
I could cache the results... But I still do not understand why just evaluating x^99 takes so much time ! On Nov 26, 2:54 pm, YannLC wrote: > can you avoid sums for initialisation? > > sage: P.=PolynomialRing(QQ) > sage: time p=P(dict([(i,1) for i in range()])) > CPU times: user 0.07 s, sys: 0.00 s, total: 0.07 s > Wall time: 0.07 s > > On Nov 26, 2:43 pm, Nathann Cohen wrote: > > > R = PolynomialRing(QQ, 'x') > > x = R.gen() > > sum([x^i for i in range(2,)]) > > > This is still very slow ( even if the values are larger ) :-/ > > > Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
can you avoid sums for initialisation? sage: P.=PolynomialRing(QQ) sage: time p=P(dict([(i,1) for i in range()])) CPU times: user 0.07 s, sys: 0.00 s, total: 0.07 s Wall time: 0.07 s On Nov 26, 2:43 pm, Nathann Cohen wrote: > R = PolynomialRing(QQ, 'x') > x = R.gen() > sum([x^i for i in range(2,)]) > > This is still very slow ( even if the values are larger ) :-/ > > Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
R = PolynomialRing(QQ, 'x') x = R.gen() sum([x^i for i in range(2,)]) This is still very slow ( even if the values are larger ) :-/ Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Oops, I misread your message... You're right !! ;-) -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
My problem is that I am dealing with linear functions having an arbitrary large number of variables. Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
If you only want linear terms, you can also use an univariate polynomial ring just treat x^i as x_i. it's lightning fast and allow you to easily access coefficients. On Nov 26, 2:10 pm, Nathann Cohen wrote: > Hello !!! > > I am writing the patch to move from InfinitePolynomialRing to just "var > ()", and I am having several annoying problems : > To obtain the coefficients of each variable, I have to write > for v in expression.variables(): > c = expression.coefficient(v) > > And I wonder if this is not a quadratic algorithm while it should be > linear to get "all" the coefficients > > The coefficients are not assumed to be "real values". They are assumed > to be "expression", and I have to evaluate them using n() to get the > value. > > This things transforms all the equations from 2 * x[1] - 3 * x[2] to > 2.00 x[1] - 3.00 * x[2] which makes all the outputs > clearly unreadable... > > How could I get these values without such things happening ? > > Thank you !!! > > Nathann > > On Nov 26, 12:11 pm, Burcin Erocal wrote: > > > On Thu, 26 Nov 2009 02:51:17 -0800 (PST) > > > Nathann Cohen wrote: > > > Hmm After thinking about it for a bit, is using var() really a > > > good solution ? It is fast and everything, but I use my variables in > > > functions that should not spoil the userspace with them ! When I > > > define symbolic variables, they are global and could even be accessed > > > in the userspace... Can this be avoided ? > > > If you're using Cython you can bypass the global symbol registry and > > construct your symbols using pynac directly. > > > This untested function (based on sage.symbolic.ring.SymbolicRing.symbol) > > might work: > > > def my_symbol(name): > > cdef GSymbol symb > > GSymbol_construct_str(&symb, name) > > cdef Expression e > > e = PY_NEW(Expression) > > GEx_construct_symbol(&e._gobj, symb) > > e._parent = SR > > return e > > > You need to include sage/libs/ginac/decl.pxi to get the declarations of > > GSymbol, GSymbol_construct_str, etc. > > > Cheers, > > Burcin -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hello !!! I am writing the patch to move from InfinitePolynomialRing to just "var ()", and I am having several annoying problems : To obtain the coefficients of each variable, I have to write for v in expression.variables(): c = expression.coefficient(v) And I wonder if this is not a quadratic algorithm while it should be linear to get "all" the coefficients The coefficients are not assumed to be "real values". They are assumed to be "expression", and I have to evaluate them using n() to get the value. This things transforms all the equations from 2 * x[1] - 3 * x[2] to 2.00 x[1] - 3.00 * x[2] which makes all the outputs clearly unreadable... How could I get these values without such things happening ? Thank you !!! Nathann On Nov 26, 12:11 pm, Burcin Erocal wrote: > On Thu, 26 Nov 2009 02:51:17 -0800 (PST) > > Nathann Cohen wrote: > > Hmm After thinking about it for a bit, is using var() really a > > good solution ? It is fast and everything, but I use my variables in > > functions that should not spoil the userspace with them ! When I > > define symbolic variables, they are global and could even be accessed > > in the userspace... Can this be avoided ? > > If you're using Cython you can bypass the global symbol registry and > construct your symbols using pynac directly. > > This untested function (based on sage.symbolic.ring.SymbolicRing.symbol) > might work: > > def my_symbol(name): > cdef GSymbol symb > GSymbol_construct_str(&symb, name) > cdef Expression e > e = PY_NEW(Expression) > GEx_construct_symbol(&e._gobj, symb) > e._parent = SR > return e > > You need to include sage/libs/ginac/decl.pxi to get the declarations of > GSymbol, GSymbol_construct_str, etc. > > Cheers, > Burcin -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Printing...
Hi there, I'll use the excuse that I'm now writing on a laptop in a train for not having searched if this as already been discussed... Is there a limitation somewhere (apart of course the available free time of the developers) which prevent us from improving the following ugly printing ? sage: m = matrix(2,2) sage: [m, m, m] [[0 0] [0 0], [0 0] [0 0], [0 0] [0 0]] Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Test sites for NSF education grant
On Sun, Nov 22, 2009 at 10:36:15PM -0800, Rob Beezer wrote: > A small group is preparing a National Science Foundation education > grant proposal to investigate how to make it easier for faculty to > adopt and integrate mathematics software into undergraduate > mathematics courses. Of course, we think Sage is a great vehicle for > this. We will propose creating a variety of curricular materials > revolving around Sage and typical undergraduate topics, and also > improvements to Sage itself that will directly address classroom needs > at the undergraduate level. If funded, we anticipate having stipends > and small grants for others in the Sage community to participate in > the project. > > We are especially interested in individuals and institutions without > much prior use of Sage that would be interested in commiting to trying > out new materials in their courses, participating in evaluations with > their students, and providing comprehensive reports on their > experiences. A real plus would be physical proximity to one of the > members of the grant group (listed below). We also hope to achieve a > real mix of institutions represented: public/private, big/small, 4- > year/two-year, selective/open-enrollment, etc. Stipends would be > available to compensate for your involvement, and technical support > might also be available. > > If you are interested please consider sending a short expression of > interest. Or maybe you have a colleague at your institution who does > not read the Sage lists, or know of a colleague at another > institution, and you can alert them to the possibility. Send replies > to Rob Beezer at , or post general questions here on > the list. We will follow up with those where it seems the match is > good for the purposes of the grant. Of course, all of this is subject > to eventually having the project funded. > > Rob Beezer, University of Puget Sound, Tacoma, WA > Jason Grout, Drake University, Des Moines, IA > Tom Judson, Stephen Austin Sate University, Nagodoches, TX > William Stein, University of Washington, Seattle, WA > Kiran Kedlaya, UC San Diego (Fall 2010), San Diego, CA Does this concern institutions abroad as well? Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Thu, 26 Nov 2009 02:51:17 -0800 (PST) Nathann Cohen wrote: > Hmm After thinking about it for a bit, is using var() really a > good solution ? It is fast and everything, but I use my variables in > functions that should not spoil the userspace with them ! When I > define symbolic variables, they are global and could even be accessed > in the userspace... Can this be avoided ? If you're using Cython you can bypass the global symbol registry and construct your symbols using pynac directly. This untested function (based on sage.symbolic.ring.SymbolicRing.symbol) might work: def my_symbol(name): cdef GSymbol symb GSymbol_construct_str(&symb, name) cdef Expression e e = PY_NEW(Expression) GEx_construct_symbol(&e._gobj, symb) e._parent = SR return e You need to include sage/libs/ginac/decl.pxi to get the declarations of GSymbol, GSymbol_construct_str, etc. Cheers, Burcin -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Martin! As you have pointed out in the wrong thread, having a smaller ring *has* advantages. But the more I think about it, the more I find it stupid that I let any element of an infinite polynomial "sparse" ring have its own underlying finite polynomial ring. It should be better to have the following model: * The infinite polynomial ring, R, has an underlying polynomial ring R._P, that may change during computations. It has to contain all variables that were created during computations, but not (much) more than that. So, if a generator x of R creates a new variable x[n], then R._P will be updated, and if a permutation acts on an element, R._P will be updated as well. * Any element, t, of R has an underlying polynomial, t._p. At the time when t is created, t._p belongs to R._P. * Later, the underlying ring of R may change. As soon as t is involved in an arithmetic operation, t._p well be updated so that it belongs to the new R._P. Probably that will always be better than the current sparse implementation, and (when doing overallocations) might even replace the dense implementation. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hmm After thinking about it for a bit, is using var() really a good solution ? It is fast and everything, but I use my variables in functions that should not spoil the userspace with them ! When I define symbolic variables, they are global and could even be accessed in the userspace... Can this be avoided ? Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Robert! On Nov 26, 10:20 am, Robert Bradshaw wrote: [...] > With over-allocation one might not even need the dense/sparse > distinction--creating 1000 variables in a "sparse" manner would only > need 10 reallocations. (There could still be the question of how > expensive it is to do arithmetic between very old and very new > variables, without timing and looking at the actual code I'm not sure > if this is a concern.) I just remembered one important detail: In the sparse implementation, any element of an InfinitePolynomialRing has its own underlying polynomial ring. Continuing the example from my post above: sage: x[100].polynomial().parent() Univariate Polynomial Ring in x100 over Real Field with 53 bits of precision sage: x[1].polynomial().parent() Univariate Polynomial Ring in x1 over Real Field with 53 bits of precision sage: x[10].polynomial().parent() Univariate Polynomial Ring in x10 over Real Field with 53 bits of precision sage: (x[1]+x[10]).polynomial().parent() Multivariate Polynomial Ring in x10, x1 over Real Field with 53 bits of precision sage: x[5].polynomial().parent() Univariate Polynomial Ring in x5 over Real Field with 53 bits of precision sage: (x[5]+x[10]).polynomial().parent() Multivariate Polynomial Ring in x10, x5 over Real Field with 53 bits of precision This is why the sparse implementation is so slow. In the dense implementation, the InfinitePolynomialRing has an underlying ring by itself: sage: Y.polynomial_ring() Multivariate Polynomial Ring in b10, b9, b8, b7, b6, b5, b4, b3, b2, b1, b0, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0 over Real Field with 53 bits of precision Perhaps it would be better if the InfinitePolynomialRing had a *common* underlying ring also in the sparse implementation? In the sparse implementation that ring would just be slimmer than in the dense implementation? Provided that I find the time, I'll try to implement it. Thank you for pointing me to it! Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Note that over allocating has a performance hit attached to it: sage: P = PolynomialRing(QQ,500,'x') sage: f = P.random_element() sage: R = PolynomialRing(QQ,1000,'x') sage: g = R(f) sage: %timeit f*f 10 loops, best of 3: 18.2 µs per loop sage: %timeit g*g 1 loops, best of 3: 32.3 µs per loop Also, it does increases the memory requirements for each and every element. Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www: http://www.informatik.uni-bremen.de/~malb _jab: martinralbre...@jabber.ccc.de -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: Re: [sage-devel] Re: should you ever return an error?
Sorry, wrong thread. Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www: http://www.informatik.uni-bremen.de/~malb _jab: martinralbre...@jabber.ccc.de -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: should you ever return an error?
Note that over allocating has a performance hit attached to it: sage: P = PolynomialRing(QQ,500,'x') sage: f = P.random_element() sage: R = PolynomialRing(QQ,1000,'x') sage: g = R(f) sage: %timeit f*f 10 loops, best of 3: 18.2 µs per loop sage: %timeit g*g 1 loops, best of 3: 32.3 µs per loop Also, it does increases the memory requirements for each and every element. Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF _www: http://www.informatik.uni-bremen.de/~malb _jab: martinralbre...@jabber.ccc.de -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: should you ever return an error?
Hi Robert, On Nov 26, 9:16 am, Robert Bradshaw wrote: > > On Nov 26, 8:41 am, Robert Bradshaw > > wrote: > > [...] > >> Though all of the above look like errors to me, not that there is the > >> special value NotImplemented that can be *returned* in certain cases Oops, I did not auto-correct your misspelling. Now I see that you meant to write "*note* that there is ...". I did not know that NotImplemented constant. However, there are several errors that are returned. See ticket http://trac.sagemath.org/sage_trac/ticket/7535 Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Nov 26, 2009, at 2:10 AM, Simon King wrote: > Hi Robert! > > On Nov 26, 9:46 am, Robert Bradshaw > wrote: > [...] I think this makes perfect sense...I'm actually surprised it's not implemented that way already. >> >>> That's impossible. >> >> Over-allocating the number of generators ahead of time whenever you >> need more to achieve O(log(n)) rather than O(n) ring enlargements for >> n used variables (where n is, of course, not know ahead of time) >> seems >> easy enough to me. > > Over-allocation could indeed be a good idea. > > By "impossible" I meant: When you have > sum([x[i] for i in range(1001)] > it is impossible to guess that eventually you will have 1000 variables > already at the time when you create x[0]. Yeah. I think this is just a stress test for how well the ring works with many dynamically created variables, not an actual application. > And when you create x[1000] first, then you have two approaches: > 1) I don't know whether any other variable will be used, thus, I only > create x[1000] and nothing else. That's the sparse implementation. > 2) If x[1000] is used, it is likely that x[999] will be used as well. > So, I create x[0],...,x[1000] at once. That's the dense > implementation. With over-allocation one might not even need the dense/sparse distinction--creating 1000 variables in a "sparse" manner would only need 10 reallocations. (There could still be the question of how expensive it is to do arithmetic between very old and very new variables, without timing and looking at the actual code I'm not sure if this is a concern.) - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Robert! On Nov 26, 9:46 am, Robert Bradshaw wrote: [...] > >> I think this makes perfect sense...I'm actually surprised it's not > >> implemented that way already. > > > That's impossible. > > Over-allocating the number of generators ahead of time whenever you > need more to achieve O(log(n)) rather than O(n) ring enlargements for > n used variables (where n is, of course, not know ahead of time) seems > easy enough to me. Over-allocation could indeed be a good idea. By "impossible" I meant: When you have sum([x[i] for i in range(1001)] it is impossible to guess that eventually you will have 1000 variables already at the time when you create x[0]. And when you create x[1000] first, then you have two approaches: 1) I don't know whether any other variable will be used, thus, I only create x[1000] and nothing else. That's the sparse implementation. 2) If x[1000] is used, it is likely that x[999] will be used as well. So, I create x[0],...,x[1000] at once. That's the dense implementation. [...] > > Or start summation with the highest index, which has the same effect. > > Or use *symbolic* variables right away, since this is what Nathann > > needed anyway. > > I'm clearly not following you--I thought the point was that one didn't > know ahead of time the highest index. Yes. InfinitePolynomialRing can not know the highest index. But if the user happens to know the highest index, (s)he can forward this information to InfinitePolynomialRing, by using the highest index first (in the default implementation). Once more: I think the crucial point is whether in a given application the number of variables can grow by arithmetic operations. For InfinitePolynomialRing, the action of an infinite symmetric group can obviously raise the variable index beyond all bounds. And this is what can happen during symmetric Groebner basis computation. If in Nathann's application there is no such group action (and no shift operator) then he might be better off using symbolic variables right away. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
I do not know in advance the number of variables needed. It can be pre-computed, of course (and it would be equivalent to actually running the whole algorithm), but we are definitely better without this hindrance... Actually, I tried several things using var ("x_"+str(i)) and it is much better in many aspects... I am planning to write a patch for this as soon as ticket #7270 will be reviewed ( and I hope it will happen very soon anybody available ? ;-) ). For the moment, I told my colleagues to print p._x[5000] before their computations which is some good enough temporary fix ;-) I have another bug coming from the same InfinitePolynomial ring when creating too many variables, but I haven't found the way to reproduce it for the moment You'll have a ticket for this as soon as possible !! Thank you very much for your help !!! Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Nathann! On Nov 26, 9:11 am, Nathann Cohen wrote: > Ok, now I understand... ;-) > > The trouble is that obviously, I have no idea of how many variables I > will need. I do no want to ask the user, as not having to say it is -- > really-- a relief ! I don't know exactly what you plan to do. I think the most important question is: Will the number of variables grow *during* your application, or is it possible to determine *in advance* the highest number of variables? In the latter case, ask the user for that number, and create a polynomial ring or a list of symbolic variables that is big enough. Best regards, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Florent! PS: On Nov 26, 9:24 am, Florent Hivert wrote: > On Thu, Nov 26, 2009 at 01:16:09AM -0800, Simon King wrote: > > > On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: > > [...] > > > I think this makes perfect sense...I'm actually surprised it's not > > > implemented that way already. > > > That's impossible. I understood "I'm surprised it's not implemented that way" as follows: "Why don't you always chose an underlying polynomial ring that is big enough, as in the example of summation?" And this is, as I had pointed out, impossible. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Florent! On Nov 26, 9:24 am, Florent Hivert wrote: [...] > I don't understand why what you say here is an answer to the following > sentence of mine: > > Is there a problem in Symmetric Ideals if you have unused variables ? You will always have an infinity of unused variables, of course: In each actual computation, you will use only finitely many of them. And then the problem is, how to implement it? Since part of the Aschenbrenner-Hillar algorithm involves *classical* (finite) Groebner basis computation, it seemed reasonable to have finite polynomial rings as underlying structure, rather than symbolic variables. The underlying finite polynomial ring should of course contain all variables that are used. In the sparse implementation, the underlying ring will contain *only* the used variables. In the dense implementation, it will contain all variables that have at most the highest used index. Example: sage: X. = InfinitePolynomialRing(RR,implementation='sparse') sage: t=x[5] sage: t.polynomial().parent() Univariate Polynomial Ring in x5 over Real Field with 53 bits of precision sage: Y. = InfinitePolynomialRing(RR) sage: s=a[5] sage: s.polynomial().parent() Multivariate Polynomial Ring in b5, b4, b3, b2, b1, b0, a5, a4, a3, a2, a1, a0 over Real Field with 53 bits of precision But when you start doing arithmetic, the underlying ring will, in general, change. And this is also the case when you let the symmetric group over the natural numbers act on the ring: sage: p=Permutation((5,10)) sage: (t^p).polynomial().parent() Multivariate Polynomial Ring in x10, x5 over Real Field with 53 bits of precision sage: (s^p).polynomial().parent() Multivariate Polynomial Ring in b10, b9, b8, b7, b6, b5, b4, b3, b2, b1, b0, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0 over Real Field with 53 bits of precision You see why the sparse implementation is called "sparse". __Consequences:__ - The sparse implementation has the disadvantage that, on average, you will more often change the underlying finite polynomial ring. That slows it down. - The dense implementation in some applications has the disadvantage that the underlying ring is too big. Does this answer your question? Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
On Nov 26, 2009, at 1:16 AM, Simon King wrote: > Hi Robert! > > On Nov 26, 8:43 am, Robert Bradshaw > wrote: >> On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: >>> Though this could be improved by using a similar trick than >>> doubling the size of a list when appending element, I'm not sure >>> that's what we want. >> >> I think this makes perfect sense...I'm actually surprised it's not >> implemented that way already. > > That's impossible. Over-allocating the number of generators ahead of time whenever you need more to achieve O(log(n)) rather than O(n) ring enlargements for n used variables (where n is, of course, not know ahead of time) seems easy enough to me. > The whole point of InfinitePolynomialRing is that you do *not* know in > advance how many variables you will eventually need. Its main purpose > is to compute Groebner bases of so-called Symmetric Ideals, and during > such computation it may very well be that the number of variables > increases during computation. > > And then, as I mentioned in my previous post, there is the problem > that in some cases you will use only very few variables, although the > indices may be very large and, again, you don't know in advance *what* > indices you will need. This is why there is a non-default sparse > implementation. > >>> In the mean time. I have the following workaround: Just start by >>> declaring your last variable: > > Or start summation with the highest index, which has the same effect. > Or use *symbolic* variables right away, since this is what Nathann > needed anyway. I'm clearly not following you--I thought the point was that one didn't know ahead of time the highest index. - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] sage and nfs
Hello: In my university, we have a room with 24 computers and one nfs server serving the home folders for all of them. SAGE is installed in each of the computers individually. As the course progresses, we're running into severe performance problems when using SAGE in this setting. We have now switched to local access, and we can proceed with the course without problems, but we'd like to have the home folders shared between the different computers if at all possible. These are the clues to the issue: * Other courses, running other software, use the nfs mounted home folders with no problem, and with all the students logging in at the same time. * If only one, or a few computers log in, performance is good. * If all the students use SAGE at once with local access, performance is good, too. * When they log into their nfs accounts, performance is poor but, after a while that is getting longer, students can work normally. * As a side comment, the nfs server seems to have enough RAM, CPU and bandwith idle when all the computers struggle to open up SAGE. So I'd say our problem is related to the big size of the .mozilla and .sage folders going through the nfs folder (compared to the small configuration folders of other programs). As the course progresses, these folders are getting bigger, and that would explain the performance issues and non-issues. My questions are: * Does this make sense to you? * Has any of you tried a similar configuration? * Any hints on how we can get shared folders back? Maybe samba would do better? Maybe rsync the folders on login and logout? Maybe use a single SAGE server? Thanks -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi David! On Nov 26, 9:07 am, David Kohel wrote: > Rather I would say that "sparse" should be the default: > > P. = InfinitePolynomialRing(QQ, implementation="sparse") No. The main purpose of InfinitePolynomialRing is the computation of symmetric Groebner bases, and simply it turned out in examples that "sparse" is much slower in Groebner basis computations. > Moreover, this syntax (and for gens, etc.) is inconsistent > with PolynomialRing. Why? One possible way of creating a polynomial ring is sage: R.=PolynomialRing(QQ) So, my syntax is perfectly consistent. > The syntax: > > PolynomialRing(ring, integer, sparse=True) > > would be a more coherent, where integer=Set(ZZ) would give > an infinite polynomial ring. Mathematically, let G be the symmetric group of the natural numbers. Then, PolynomialRing(QQ,x) is the free QQ(G) module with generator x. And, by work of Aschenbrenner and Hillar, it is actually noetherian as a QQ(G) module. And this implies at least three reasons why I don't like your suggestion. 1) An InfinitePolynomialRing is not just a polynomial ring with infinitely many variables. This is a point against using the PolynomialRing constructor for its creation. 2) The variables x[0],x[1],x[2],x[3],... are *not* considered the generators of an infinite polynomial ring. You would have just *one* generator x, and this one generator gives rise to an infinity of variables. So, it simply makes not much sense to define an infinite polynomial ring by an (infinite) list of variables. Again, my syntax is consistent, since InfinitePolynomialRing(QQ,'x') lists the *generators* of the object. 3) Sometimes one wants to have *several* generators of an infinite polynomial ring, and one wants to chose a *name* for the generator. Your suggestion does not address any of these points. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Simon, On Thu, Nov 26, 2009 at 01:16:09AM -0800, Simon King wrote: > > On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: > [...] > > I think this makes perfect sense...I'm actually surprised it's not > > implemented that way already. > > That's impossible. > > The whole point of InfinitePolynomialRing is that you do *not* know in > advance how many variables you will eventually need. Its main purpose > is to compute Groebner bases of so-called Symmetric Ideals, and during > such computation it may very well be that the number of variables > increases during computation. > > And then, as I mentioned in my previous post, there is the problem > that in some cases you will use only very few variables, although the > indices may be very large and, again, you don't know in advance *what* > indices you will need. This is why there is a non-default sparse > implementation. I don't understand why what you say here is an answer to the following sentence of mine: Is there a problem in Symmetric Ideals if you have unused variables ? > > > Though this could be improved by using a similar trick than doubling the > > > size of a list when appending element, I'm not sure that's what we want. > > > > I think this makes perfect sense...I'm actually surprised it's not > > implemented that way already. > > That's impossible. > Running to get my train... Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] Re: should you ever return an error?
On Nov 26, 2009, at 1:06 AM, Simon King wrote: > Hi Robert, > > On Nov 26, 8:41 am, Robert Bradshaw > wrote: > [...] >> Though all of the above look like errors to me, not that there is the >> special value NotImplemented that can be *returned* in certain cases >> >> http://docs.python.org/library/constants.html > > But NotImplementedError is a Python object, and (as any object) it can > be returned. Yes, I understand that it can be returned, but it almost always should be raised. My point (which was somewhat tangential) is that there is an object NotImplemented that's meant to be returned, not raised, under normal circumstances. - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Robert! On Nov 26, 8:43 am, Robert Bradshaw wrote: > On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: [...] > I think this makes perfect sense...I'm actually surprised it's not > implemented that way already. That's impossible. The whole point of InfinitePolynomialRing is that you do *not* know in advance how many variables you will eventually need. Its main purpose is to compute Groebner bases of so-called Symmetric Ideals, and during such computation it may very well be that the number of variables increases during computation. And then, as I mentioned in my previous post, there is the problem that in some cases you will use only very few variables, although the indices may be very large and, again, you don't know in advance *what* indices you will need. This is why there is a non-default sparse implementation. > > In the mean time. I have the following workaround: Just start by > > declaring your last variable: Or start summation with the highest index, which has the same effect. Or use *symbolic* variables right away, since this is what Nathann needed anyway. > If one knows how many variables one needs ahead of time, than what's > the advantage of using the InfinitePolynomialRing over a finite one of > the right size? Sure. *If* one knows it and *if* the number of variables does not increase during computation then a usual polynomial ring is better. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Ok, now I understand... ;-) The trouble is that obviously, I have no idea of how many variables I will need. I do no want to ask the user, as not having to say it is -- really-- a relief ! My other problem is that sometimes computation on symbolic variables take a lot of time, and I think it comes from the fact that they are "so" general. Do you think it could be interesting to create a "custom" variable, just for linear functions ( and perhaps only for this application ) ? Do you think this could be a way to speed it up ? Thanks Nathann On Nov 26, 10:07 am, David Kohel wrote: > Rather I would say that "sparse" should be the default: > > P. = InfinitePolynomialRing(QQ, implementation="sparse") > > Moreover, this syntax (and for gens, etc.) is inconsistent > with PolynomialRing. The syntax: > > PolynomialRing(ring, integer, sparse=True) > > would be a more coherent, where integer=Set(ZZ) would give > an infinite polynomial ring. > > --David > > On Nov 26, 9:43 am, Robert Bradshaw > wrote: > > > On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: > > > > Hi Nathann, > > > >> For Linear Programming, I need to create plenty of symbolic variables > > >> which I use to represent linear functions To do it, I use the > > >> class InfinitePolynomialRing which lets me create them easily ( and > > >> it > > >> is really needed, as my colleagues often have to create Linear > > >> Programs using 1000~2000 variables. This is not a problem for the > > >> solvers, but Sage does not like it : > > >> To understand my problem, just try this code : > > > >> X. = InfinitePolynomialRing(RR) > > >> sum([x[i] for i in range(200)]) > > > >> Don't you think it is a bit long just to generate a sum ? I have to > > >> admit I do not know how this class is coded, and the slowness may be > > >> required for applications different from mine.. But wouldn't there be > > >> a way to speed this up ? If not, do you know of any way to generate > > >> many symbolic variables ( they do not need to be polynomial, just > > >> linear in my case ) ? > > > > This is indeed a problem. I think I know the cause... Each time a > > > new variable > > > is created, the ring itself is somehow changed. Therefore for each new > > > variable in your sum, there is a big computation which convert the > > > former sum > > > to the new ring. Though this could be improved by using a similar > > > trick than > > > doubling the size of a list when appending element, I'm not sure > > > that's what > > > we want. > > > I think this makes perfect sense...I'm actually surprised it's not > > implemented that way already. > > > > In the mean time. I have the following workaround: Just start by > > > declaring your last variable: > > > If one knows how many variables one needs ahead of time, than what's > > the advantage of using the InfinitePolynomialRing over a finite one of > > the right size? > > > - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Rather I would say that "sparse" should be the default: P. = InfinitePolynomialRing(QQ, implementation="sparse") Moreover, this syntax (and for gens, etc.) is inconsistent with PolynomialRing. The syntax: PolynomialRing(ring, integer, sparse=True) would be a more coherent, where integer=Set(ZZ) would give an infinite polynomial ring. --David On Nov 26, 9:43 am, Robert Bradshaw wrote: > On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: > > > > > Hi Nathann, > > >> For Linear Programming, I need to create plenty of symbolic variables > >> which I use to represent linear functions To do it, I use the > >> class InfinitePolynomialRing which lets me create them easily ( and > >> it > >> is really needed, as my colleagues often have to create Linear > >> Programs using 1000~2000 variables. This is not a problem for the > >> solvers, but Sage does not like it : > >> To understand my problem, just try this code : > > >> X. = InfinitePolynomialRing(RR) > >> sum([x[i] for i in range(200)]) > > >> Don't you think it is a bit long just to generate a sum ? I have to > >> admit I do not know how this class is coded, and the slowness may be > >> required for applications different from mine.. But wouldn't there be > >> a way to speed this up ? If not, do you know of any way to generate > >> many symbolic variables ( they do not need to be polynomial, just > >> linear in my case ) ? > > > This is indeed a problem. I think I know the cause... Each time a > > new variable > > is created, the ring itself is somehow changed. Therefore for each new > > variable in your sum, there is a big computation which convert the > > former sum > > to the new ring. Though this could be improved by using a similar > > trick than > > doubling the size of a list when appending element, I'm not sure > > that's what > > we want. > > I think this makes perfect sense...I'm actually surprised it's not > implemented that way already. > > > In the mean time. I have the following workaround: Just start by > > declaring your last variable: > > If one knows how many variables one needs ahead of time, than what's > the advantage of using the InfinitePolynomialRing over a finite one of > the right size? > > - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: should you ever return an error?
Hi Robert, On Nov 26, 8:41 am, Robert Bradshaw wrote: [...] > Though all of the above look like errors to me, not that there is the > special value NotImplemented that can be *returned* in certain cases > > http://docs.python.org/library/constants.html But NotImplementedError is a Python object, and (as any object) it can be returned. Actually I reported a similar bug (when an error was returned instead of raised) before, and I think it got fixed. But apparently we forgot to systematically search for "return *Error". sage: search_src('return NotImplementedError') rings/ring.pyx:687:return NotImplementedError modular/hecke/module.py:706:abstract base class, return NotImplementedError. modular/arithgroup/congroup_gammaH.py:928:return NotImplementedError geometry/polyhedra.py:1068:return NotImplementedError symbolic/expression.pyx:1524:return NotImplementedError symbolic/expression_conversions.py:638:return NotImplementedError("SymPy function '%s' doesn't exist" % f) sage: search_src('return RuntimeError') interfaces/gap.py:580:return RuntimeError, "Error evaluating %s in %s"%(line, self) etc. I think I will create a ticket for it. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] InfinitePolynomialRing is -- very -- slow
On Nov 26, 2009, at 12:35 AM, Florent Hivert wrote: > Hi Nathann, > >> For Linear Programming, I need to create plenty of symbolic variables >> which I use to represent linear functions To do it, I use the >> class InfinitePolynomialRing which lets me create them easily ( and >> it >> is really needed, as my colleagues often have to create Linear >> Programs using 1000~2000 variables. This is not a problem for the >> solvers, but Sage does not like it : >> To understand my problem, just try this code : >> >> X. = InfinitePolynomialRing(RR) >> sum([x[i] for i in range(200)]) >> >> Don't you think it is a bit long just to generate a sum ? I have to >> admit I do not know how this class is coded, and the slowness may be >> required for applications different from mine.. But wouldn't there be >> a way to speed this up ? If not, do you know of any way to generate >> many symbolic variables ( they do not need to be polynomial, just >> linear in my case ) ? > > This is indeed a problem. I think I know the cause... Each time a > new variable > is created, the ring itself is somehow changed. Therefore for each new > variable in your sum, there is a big computation which convert the > former sum > to the new ring. Though this could be improved by using a similar > trick than > doubling the size of a list when appending element, I'm not sure > that's what > we want. I think this makes perfect sense...I'm actually surprised it's not implemented that way already. > In the mean time. I have the following workaround: Just start by > declaring your last variable: If one knows how many variables one needs ahead of time, than what's the advantage of using the InfinitePolynomialRing over a finite one of the right size? - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] should you ever return an error?
On Nov 26, 2009, at 12:21 AM, Florent Hivert wrote: > Hi there, > > On Wed, Nov 25, 2009 at 09:38:23PM -0800, William Stein wrote: >> On Wed, Nov 25, 2009 at 7:26 PM, John H Palmieri > > wrote: >>> In ring.pyx, there is code like this: >>> >>>if proof: >>>return NotImplementedError >>>else: >>>return False >>> >>> I would think that the second line should say "raise >>> NotImplementedError". (Changing it makes some doctests fail, >>> though.) Is there a good reason for doing "return >>> NotImplementedError"? >> >> That's *definitely* a bug (almost certainly my fault). No question >> about it. I made this #7532: >> >> http://trac.sagemath.org/sage_trac/ticket/7532 >> >> It sounds like you have a fix already, so just let us know when there >> is a patch up to review. > > I suspected that this could be a common mistake. So I did a grep... > It seems I > was right... > > Florent > > tomahawk-*ge-combinat/sage $ grep return.\*Error **/*.py* > categories/enumerated_sets.py:``EnumeratedSet()`` it > returns `NotImplementedError` since one does > geometry/polyhedra.py:return NotImplementedError > groups/perm_gps/permgroup_named.py:return ValueError, > "Degree must be 2." > groups/perm_gps/permgroup_named.py:return ValueError, > "Degree must be 2." > groups/perm_gps/permgroup.py:return TypeError, "Group > must be simple." > interfaces/gap.py:return RuntimeError, "Error evaluating > %s in %s"%(line, self) > libs/pari/gen.pyx:return "PariError(%d)"%self.args[0] > misc/latex.py:return "Error" > misc/latex.py:return "Error" > misc/latex.py:return "Error" > misc/latex.py:return "Error" > misc/latex.py:return "Error: dvipng > failed." > misc/latex.py:return "Error latexing slide." > misc/typecheck.py:__all__ = ["takes", "InputParameterError", > "returns", "ReturnValueError"] > modular/abvar/finite_subgroup.py:return ValueError, > "self and other must be in the same ambient Jacobian" > modular/arithgroup/congroup_gammaH.py:return > NotImplementedError > modular/hecke/module.py:abstract base class, return > NotImplementedError. > rings/finite_field_element.py:return > ArithmeticError, "Multiplicative order of 0 not defined." > rings/finite_field_givaro.pyx:return > ArithmeticError, "Multiplicative order of 0 not defined." > rings/number_field/number_field.py:If this function returns > True (and doesn't raise a ValueError), > rings/ring.pyx:return NotImplementedError > rings/ring.pyx:The following example returns a > ``NotImplementedError`` since the > server/notebook/twist.py:return HTMLResponse(stream = > 'Error in introspection -- invalid cell id.') > server/notebook/worksheet.py:return "print 'Error > loading %s -- file not found'"%filename > server/notebook/worksheet.py:return "print > r'''Error compiling cython file:\n%s'''"%msg > structure/element.pyx:return ArithmeticError, > "Multiplicative order of 0 not defined." > structure/factorization.py:This method will return a > TypeError if the coercion is not > symbolic/expression_conversions.py:return > NotImplementedError("SymPy function '%s' doesn't exist" % f) > symbolic/expression.pyx:return NotImplementedError Though all of the above look like errors to me, not that there is the special value NotImplemented that can be *returned* in certain cases http://docs.python.org/library/constants.html - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] InfinitePolynomialRing is -- very -- slow
Hi Nathann, > For Linear Programming, I need to create plenty of symbolic variables > which I use to represent linear functions To do it, I use the > class InfinitePolynomialRing which lets me create them easily ( and it > is really needed, as my colleagues often have to create Linear > Programs using 1000~2000 variables. This is not a problem for the > solvers, but Sage does not like it : > To understand my problem, just try this code : > > X. = InfinitePolynomialRing(RR) > sum([x[i] for i in range(200)]) > > Don't you think it is a bit long just to generate a sum ? I have to > admit I do not know how this class is coded, and the slowness may be > required for applications different from mine.. But wouldn't there be > a way to speed this up ? If not, do you know of any way to generate > many symbolic variables ( they do not need to be polynomial, just > linear in my case ) ? This is indeed a problem. I think I know the cause... Each time a new variable is created, the ring itself is somehow changed. Therefore for each new variable in your sum, there is a big computation which convert the former sum to the new ring. Though this could be improved by using a similar trick than doubling the size of a list when appending element, I'm not sure that's what we want. In the mean time. I have the following workaround: Just start by declaring your last variable: -- | Sage Version 4.2, Release Date: 2009-10-24 | | Type notebook() for the GUI, and license() for information.| -- Loading Sage library. Current Mercurial branch is: combinat sage: X. = InfinitePolynomialRing(RR) sage: x[1000] x1000 sage: time sum([x[i] for i in range(1000)]) CPU times: user 0.66 s, sys: 0.00 s, total: 0.66 s Wall time: 0.66 s [...] Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] Re: InfinitePolynomialRing is -- very -- slow
Hi Nathann! On Nov 26, 8:18 am, Nathann Cohen wrote: [...] > To understand my problem, just try this code : > > X. = InfinitePolynomialRing(RR) > sum([x[i] for i in range(200)]) > > Don't you think it is a bit long just to generate a sum ? I have to > admit I do not know how this class is coded, and the slowness may be > required for applications different from mine.. But wouldn't there be > a way to speed this up ? InfinitePolynomialRing has an underlying *finite* polynomial ring, that changes whenever you need a variable that is not in the finite ring. Therefore, sum([x[199-i] for i in range(200)]) is much faster. Reason: InfinitePolynomialRing has a dense and a sparse implementation, that both have advantages and disadvantages. The default is "dense". It means: If x[199] is called, then a polynomial ring with all variables ranging from x0 to x199 is created. So, if you start the sum with x [199] then the ring can be kept. In the sparse implementation, both summation orders would be slow. The advantage of the sparse implementation is that you can have x[10] without creating a ring with 10 generators. > If not, do you know of any way to generate > many symbolic variables ( they do not need to be polynomial, just > linear in my case ) ? Well, you know that InfinitePolynomialRing does not yield symbolic variables. I would consider creating the variable names that you need, and create symbolic variables explicitely: sum([var('x'+str(i)) for i in range(200)]) is fast enough, I guess. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
Re: [sage-devel] should you ever return an error?
Hi there, On Wed, Nov 25, 2009 at 09:38:23PM -0800, William Stein wrote: > On Wed, Nov 25, 2009 at 7:26 PM, John H Palmieri > wrote: > > In ring.pyx, there is code like this: > > > > if proof: > > return NotImplementedError > > else: > > return False > > > > I would think that the second line should say "raise > > NotImplementedError". (Changing it makes some doctests fail, > > though.) Is there a good reason for doing "return > > NotImplementedError"? > > That's *definitely* a bug (almost certainly my fault). No question > about it. I made this #7532: > >http://trac.sagemath.org/sage_trac/ticket/7532 > > It sounds like you have a fix already, so just let us know when there > is a patch up to review. I suspected that this could be a common mistake. So I did a grep... It seems I was right... Florent tomahawk-*ge-combinat/sage $ grep return.\*Error **/*.py* categories/enumerated_sets.py:``EnumeratedSet()`` it returns `NotImplementedError` since one does geometry/polyhedra.py:return NotImplementedError groups/perm_gps/permgroup_named.py:return ValueError, "Degree must be 2." groups/perm_gps/permgroup_named.py:return ValueError, "Degree must be 2." groups/perm_gps/permgroup.py:return TypeError, "Group must be simple." interfaces/gap.py:return RuntimeError, "Error evaluating %s in %s"%(line, self) libs/pari/gen.pyx:return "PariError(%d)"%self.args[0] misc/latex.py:return "Error" misc/latex.py:return "Error" misc/latex.py:return "Error" misc/latex.py:return "Error" misc/latex.py:return "Error: dvipng failed." misc/latex.py:return "Error latexing slide." misc/typecheck.py:__all__ = ["takes", "InputParameterError", "returns", "ReturnValueError"] modular/abvar/finite_subgroup.py:return ValueError, "self and other must be in the same ambient Jacobian" modular/arithgroup/congroup_gammaH.py:return NotImplementedError modular/hecke/module.py:abstract base class, return NotImplementedError. rings/finite_field_element.py:return ArithmeticError, "Multiplicative order of 0 not defined." rings/finite_field_givaro.pyx:return ArithmeticError, "Multiplicative order of 0 not defined." rings/number_field/number_field.py:If this function returns True (and doesn't raise a ValueError), rings/ring.pyx:return NotImplementedError rings/ring.pyx:The following example returns a ``NotImplementedError`` since the server/notebook/twist.py:return HTMLResponse(stream = 'Error in introspection -- invalid cell id.') server/notebook/worksheet.py:return "print 'Error loading %s -- file not found'"%filename server/notebook/worksheet.py:return "print r'''Error compiling cython file:\n%s'''"%msg structure/element.pyx:return ArithmeticError, "Multiplicative order of 0 not defined." structure/factorization.py:This method will return a TypeError if the coercion is not symbolic/expression_conversions.py:return NotImplementedError("SymPy function '%s' doesn't exist" % f) symbolic/expression.pyx:return NotImplementedError -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
[sage-devel] InfinitePolynomialRing is -- very -- slow
Hello everybody For Linear Programming, I need to create plenty of symbolic variables which I use to represent linear functions To do it, I use the class InfinitePolynomialRing which lets me create them easily ( and it is really needed, as my colleagues often have to create Linear Programs using 1000~2000 variables. This is not a problem for the solvers, but Sage does not like it : To understand my problem, just try this code : X. = InfinitePolynomialRing(RR) sum([x[i] for i in range(200)]) Don't you think it is a bit long just to generate a sum ? I have to admit I do not know how this class is coded, and the slowness may be required for applications different from mine.. But wouldn't there be a way to speed this up ? If not, do you know of any way to generate many symbolic variables ( they do not need to be polynomial, just linear in my case ) ? Thank you !!! Nathann -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org