Ask Your Question

Szabolcs's profile - activity

2019-10-16 02:05:55 -0500 commented answer Sage stalls during computation

@tomteil 2692 iterations, well over a day, and still going. We can safely say that with Coin it does not stall. However, using Coin would be a significant step-down because its worse performance. I am still puzzled about why there is no performance difference on your computer.

2019-10-14 14:36:23 -0500 commented answer Sage stalls during computation

@tmonteil Wow, that's weird! Do you have any idea what could explain this difference? I verified that only a single CPU core is in use with both. I am using Sage 8.9, built from source without changing any options. The solutions that both GLPK and Coin return seem to be the same ones that you quote.

I also tried the calculation with GLPK on a Mac laptop (where I have not yet managed to install CBC), and it took 20 seconds, which is consistent with the 27 s timing I got on the Linux machine. Why would it be taking a full minute on your computer?

P.S. It does not look like it's going to stall with Coin, but let me keep it running for 24 hrs to be sure.

2019-10-14 10:53:59 -0500 commented answer Sage stalls during computation

@tomteil It's running, I'll let you know. In the meantime, could you please try if 'Coin' is faster for you on smaller graphs too? I have not found a graph on which 'Coin would be faster than 'GLPK', but I only tried easy ones on which even Coin finishes within 5 min. Your example took much longer than that.

2019-10-14 06:05:00 -0500 commented answer Sage stalls during computation

@tmonteil You are right that the code of feedback_edge_set does not seem to select (or mention) GLPK. Maybe MixedIntegerLinearProgram(solver=None) initializes to use GLPK by default despite default_mip_solver() returning 'Coin'. I don't know how to check what MixedIntegerLinearProgram() has actually initialized to. All I can see is that the timing with solver=None is the same as the timing with solver='GLPK'.

2019-10-14 05:56:52 -0500 commented answer Sage stalls during computation


sage: set_random_seed(1234)
sage: g=digraphs.RandomDirectedGNM(200,500)
sage: %time g.feedback_edge_set(solver='GLPK')
CPU times: user 27.6 s, sys: 28 ms, total: 27.7 s
Wall time: 27.7 s
sage: %time g.feedback_edge_set(solver='Coin')
CPU times: user 1min 19s, sys: 1.25 s, total: 1min 21s
Wall time: 1min 19s
2019-10-14 05:52:29 -0500 commented answer Sage stalls during computation

@david Yes, I am sure. If I run %time g.feedback_edge_set(solver='GLPK') then the timing is the same as with %time g.feedback_edge_set(). If I run %time g.feedback_edge_set(solver='Coin') then the timing is several times longer. Therefore, I want to use GLPK for this application.

2019-10-13 13:42:00 -0500 received badge  Nice Question (source)
2019-10-13 04:59:34 -0500 commented question Sage stalls during computation

@tmonteil It's not because of a specific graph. The stalling appears to be random. I know this because I normally run this on a set of pre-computed graphs, so I could easily re-try on the graph where it stalled. Also, running it twice on the same data won't stall at the same step.

2019-10-12 13:04:00 -0500 commented answer Sage stalls during computation

@tmonteil I added a minimal example. Can you try to reproduce the problem?

2019-10-11 13:18:18 -0500 commented answer Sage stalls during computation

Some comments on sage -i cbc: this appears to set the default_mip_solver() to "Coin", but feedback_edge_set still uses GLPK by default. I can set it to use Coin manually, but GLPK is far faster. GLPK is also much faster than Gurobi when using this specific function. Perhaps this function uses some feature which is GLPK-specific and that's why it'll have better performance with GLPK. I don't know.

2019-10-11 13:07:27 -0500 commented answer Sage stalls during computation

Sure—I'll get back to you when I have a small example that reliably fails. It'll take time as it usually takes hours for it to fail.

2019-10-11 12:57:21 -0500 commented answer Building Sage 8.9 from source fails

I asked libreadline-dev, libncurses5-dev and libncursesw5-dev to be installed on this computer. Now Sage 8.9 compiles successfully. libreadline-dev alone was not sufficient. I did this based on the linked Google Groups thread before Dima posted here.

2019-10-11 10:57:00 -0500 received badge  Commentator
2019-10-11 10:57:00 -0500 commented answer Building Sage 8.9 from source fails

Checking the log file more carefully revealed this line:

*** WARNING: renaming "readline" since importing it failed: /home/szhorvat/sage-8.9/local/lib/ undefined symbol: UP

2019-10-11 10:48:57 -0500 commented answer Building Sage 8.9 from source fails

It fails with the same message.

The output of ls /lib/x86_64-linux-gnu/libreadline* is

/lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/

2019-10-11 10:37:57 -0500 commented answer Building Sage 8.9 from source fails

make configure would say make: 'configure' is up to date. even if I start with a clean source tree. Did I miss anything in the build instructions? I now deleted configure, did make configure, ./configure, and now waiting for the build to finish ...

2019-10-11 06:06:28 -0500 asked a question Building Sage 8.9 from source fails

I am trying to build Sage 8.9 from source on Linux (Ubuntu 16.04, gcc 6). It fails. I could build Sage 8.8 on the same machine without problems.

It says that python2 and python3 failed to build, and suggests to look at the log files. The log files contain:

ImportError: No module named readline
readline module failed to import


ModuleNotFoundError: No module named 'readline'
readline module failed to import

Has anyone experienced the same and is there a simple solution?

Unfortunately, I do not have root access myself, thus I can't quickly try to install the readline dev package.

2019-10-11 04:00:38 -0500 commented answer Sage stalls during computation

It is not that trivial to boil down the code to a minimal example. If I put in the work to do that, would you be willing to try to reproduce the problem? Trying to reproduce would also be some trouble: It would involve leaving Sage running for up to a day (or running multiple Sage processes for several hours to increase the likelihood that one of them would stall).

2019-10-11 02:27:37 -0500 asked a question Sage stalls during computation

I was using SageMath 8.8's feedback_edge_set function on a large dataset. The calculation would take a couple of days to finish.

Unfortunately, Sage would keep stalling every few hours. The CPU usage of the process would simply drop to zero, and it would stop doing anything. I had to kill the process (a simple kill worked, no kill -9 necessary).

Has anyone else experienced this? Is it a known problem? Is there a workaround? It is very frustrating to have to keep manually killing and restarting the process. This problem also prevents me from running a calculation overnight: in the morning I might find that it stopped merely an hour after I started it (if I'm unlucky).

More information:

  • I was using Sage on Linux
  • This function uses MixedIntegerLinearProgram. I used the default GLPK (didn't change settings)
  • I used alarm() to set a time limit on each computation.
  • I always believed GLPK not to be interruptible, so I am not even sure which interruption (either manual or alarm) work on Sage with this function. This may be relevant.
  • The memory usage of the process stayed low. It did not stall because the memory got filled and the machine started swapping.

Minimal example:

Put this in a source file:

import datetime
while True:
        fes = dg.feedback_edge_set()
    except AlarmInterrupt:
    i = i+1

Run it as sage sourcefile.sage.

In my last test, it took 291 iterations and ~4-5 hours before it stalled.

It appears to stall only when GLPK is used as the MIP solver (i.e. feedback_edge_set(solver='GLPK'), which is also the default). If I use solver='Coin' (which needs to be installed first using sage -i cbc) then it does not stall. However, the calculation is several times slower with Coin than with GLPK.

2019-10-11 02:18:03 -0500 commented answer Sage takes very long to start—why?

And with Sage 8.8 and Sage 8.9 too ...

2019-08-01 11:17:10 -0500 received badge  Notable Question (source)
2019-06-05 19:24:01 -0500 received badge  Popular Question (source)
2019-03-01 07:09:23 -0500 commented answer Importing Python packages into Sage or Vice Versa

This does not work for the same reason edenharder said. I am using Sage on macOS, and Sage is supposed to be fully self-contained. It should contain all libraries needed. The problem is not that the OS is missing them.

2019-02-28 08:55:04 -0500 received badge  Good Question (source)
2019-02-25 07:09:24 -0500 commented question Sage takes very long to start—why?

@Juanjo There is no entry in the log that looks relevant. The entries start appearing only after it has started up. Also: I think you misunderstood me: it does not get stuck on the "currently starting" page. That page does not even appear until a couple of minutes after the app was started. Once that page appears at all, everything is fast.

2019-02-25 06:52:24 -0500 received badge  Supporter (source)
2019-02-20 19:53:06 -0500 received badge  Nice Question (source)
2019-02-19 08:16:22 -0500 asked a question Sage takes very long to start—why?

I am using the app version of Sage on macOS 10.14.3. Both version 8.5 and 8.6 take very long to start up. As I remember, previous versions were fine.

Does anyone else experience this problem (on the same OS with the same versions) and is there a simple solution? How can I debug what is happening?

By "slow to start" I mean that after starting the app, nothing at all happens for 1-2 minutes (!). Only _after_ that do I see a browser window with "The SageNB server or Jupyter is currently starting".

The command line executable within the app bundle starts very quickly (but this one does not launch the notebook interface). If I start, startup is also very fast (and this time I do get the notebook). The problem appears only when I launch the app by double-clicking it.

2018-01-18 10:42:29 -0500 received badge  Famous Question (source)
2016-09-27 05:25:49 -0500 received badge  Notable Question (source)
2016-04-06 19:26:03 -0500 received badge  Nice Question (source)
2016-02-06 15:21:03 -0500 received badge  Famous Question (source)
2016-01-18 13:55:44 -0500 received badge  Popular Question (source)
2015-04-29 10:42:25 -0500 received badge  Notable Question (source)
2015-03-26 22:09:36 -0500 marked best answer How to plot histogram from list?

Given a list of numbers, such as [5,3,6,1,...], how can I create a histogram from them and show it directly in the notebook interface?

Clarification: 5, 3, 6, 1, ... should not be used for the heights of bars. Instead, the data should be binned first to create a histogram.

Given a list of pairs, such as [[2,3], [4,5], ...], how can I create a 2D histogram form them and show it as a plot similar to this? (I.e. clearly distinguish zero counts from small non-zero counts, and show it as a matrix plot, not as a 3D bar chart.)

Clarification: How can I use a colour scheme in matrix_plot that will clearly differentiate between zero and non-zero values? E.g. use white for zero and some colour gradient for non-zero. 0 and 0.0001 should show clearly differently. How do I achieve this with the cmap parameter?

2015-02-26 15:22:17 -0500 received badge  Popular Question (source)
2014-11-16 18:36:57 -0500 marked best answer How to simplify with Sage?

Does Sage have a function to simplify symbolic expressions in a similar way to how the other major CAS do it? I.e. use heuristics to try to come up with a form which is likely to seem simpler to humans, which is certainly subjective and cannot be done perfectly, but it's also certainly very useful.

simplify doesn't do this, and the documentation is a bit confusing: it says that f = I + x - x; simplify(f) gives I, but so does just printing f. So what's the point of simplify?

I'm sure there must be a function that does this, as I beieve Sage includes several good CAS, I just can't find it.

Some examples to try:

(sqrt(2) - 1)*(sqrt(2)+1)

1/(3*(1 + x)) - (2*x - 1)/(6*(x^2 - x + 1)) + 2/(3*(1 + ((2*x - 1)^2)/3))

(Second one taken from Mathematica documentation.)

I know I can play with expand and factor but is there a less manual way?