ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 28 Sep 2013 03:48:29 -0500Sage Cloud - RAM and CPUhttp://ask.sagemath.org/question/10576/sage-cloud-ram-and-cpu/Hi experts!!
When I run a script on SAGE Cloud. Where does it execute? Consume my PC RAM memory and CPU or use a Server RAM and CPU?
Thans a lot!!mresimulatorSat, 28 Sep 2013 03:48:29 -0500http://ask.sagemath.org/question/10576/Use memory profile (python module) in SAGEhttp://ask.sagemath.org/question/10460/use-memory-profile-python-module-in-sage/Hi experts.
I want to use memory profile (decoretor module) for see a RAM memory porfile of my scipt:
https://pypi.python.org/pypi/memory_profiler
in sage.
Following the web page instructions and the post
http://ask.sagemath.org/question/1382/how-do-i-install-python-modules-or-use-a-different
I installed doing:
$ sudo sage --python setup.py install
When I run the scrip with @profile decorator, I obtain
Filename: <string>
ERROR: Could not find file <string>
What am I doing wrong?
Please explain this to me step by step (i'm a totally newby linux and python user).
Thanks a lot!mresimulatorTue, 20 Aug 2013 11:43:29 -0500http://ask.sagemath.org/question/10460/Stick (line segments) percolation - graph theory?http://ask.sagemath.org/question/10466/stick-line-segments-percolation-graph-theory/Hi experts!
I wrote an algorithm for study stick percolation (i.e.: networks between line segments that intersect between them). In my algorithm N sticks (line segments) are created inside a rectanglar box of sides 'b' and 'h' and then, one by one, the algorithm explores the intersection between all line segments. This is a Monte Carlo simulation, so the 'experiment' is executed many times (no less than 100 times).
Writen like that, very much RAM is consumed:
array_x1=uniform.rvs(loc=-b/2, scale=b, size=N)
array_y1=uniform.rvs(loc=-h/2, scale=h, size=N)
array_x2=uniform.rvs(loc=-b/2, scale=b, size=N)
array_y2=uniform.rvs(loc=-h/2, scale=h, size=N)
M = np.zeros([N,N])
for u in xrange(100): ----> This '100' is the number of experiments.
for j in xrange(N):
if j>0:
x_A1B1 = array_x2[j]-array_x1[j]
y_A1B1 = array_y2[j]-array_y1[j]
x_A1A2 = array_x1[0:j]-array_x1[j]
y_A1A2 = array_y1[0:j]-array_y1[j]
x_A2A1 = -1*x_A1A2
y_A2A1 = -1*y_A1A2
x_A2B2 = array_x2[0:j]-array_x1[0:j]
y_A2B2 = array_y2[0:j]-array_y1[0:j]
x_A1B2 = array_x2[0:j]-array_x1[j]
y_A1B2 = array_y2[0:j]-array_y1[j]
x_A2B1 = array_x2[j]-array_x1[0:j]
y_A2B1 = array_y2[j]-array_y1[0:j]
p1 = x_A1B1*y_A1A2 - y_A1B1*x_A1A2
p2 = x_A1B1*y_A1B2 - y_A1B1*x_A1B2
p3 = x_A2B2*y_A2B1 - y_A2B2*x_A2B1
p4 = x_A2B2*y_A2A1 - y_A2B2*x_A2A1
condition_1=p1*p2
condition_2=p3*p4
for k in xrange (j):
if condicion_1[k]<=0 and condicion_2[k]<=0:
M[j,k]=1
if j+1<N+4:
x_A1B1 = array_x2[j]-array_x1[j]
y_A1B1 = array_y2[j]-array_y1[j]
x_A1A2 = array_x1[j+1:]-array_x1[j]
y_A1A2 = array_y1[j+1:]-array_y1[j]
x_A2A1 = -1*x_A1A2
y_A2A1 = -1*y_A1A2
x_A2B2 = array_x2[j+1:]-array_x1[j+1:]
y_A2B2 = array_y2[j+1:]-array_y1[j+1:]
x_A1B2 = array_x2[j+1:]-array_x1[j]
y_A1B2 = array_y2[j+1:]-array_y1[j]
x_A2B1 = array_x2[j]-array_x1[j+1:]
y_A2B1 = array_y2[j]-array_y1[j+1:]
p1 = x_A1B1*y_A1A2 - y_A1B1*x_A1A2
p2 = x_A1B1*y_A1B2 - y_A1B1*x_A1B2
p3 = x_A2B2*y_A2B1 - y_A2B2*x_A2B1
p4 = x_A2B2*y_A2A1 - y_A2B2*x_A2A1
condicion_1=p1*p2
condicion_2=p3*p4
for k in xrange (N-j-1):
if condicion_1[k]<=0 and condicion_2[k]<=0:
M[j,k+j+1]=1
Here, the element Mij=1 if stick i intersect stick j and Mij=0 if not.
How can i optimize my algorithm? Graph theory is usefull in this case?
Waiting for your answers.
Thanks a lot!
Best regardsmresimulatorFri, 23 Aug 2013 11:37:20 -0500http://ask.sagemath.org/question/10466/RAM problem in script executionhttp://ask.sagemath.org/question/10462/ram-problem-in-script-execution/Hi experts!
I wrote the next code. In 1-2 hours of execution time the RAM of my laptop (8gb) is filled and the sistem crash:
from scipy.stats import uniform
import numpy as np
cant_de_cadenas=[400,600,700,800]
os.makedirs('directory')
np.savetxt(here 'cant_de_cadenas' is saved as .csv in folder 'directory')
A1=mp.array([])
...
A6=mp.array([])
import time
for N in cant_de_cadenas:
start=time.clock()
B1=mp.array([])
...
B6=mp.array([])
for u in srange (100):
array_1 = uniform.rvs(loc=-2,scale=4, size=N)
array_2 = uniform.rvs(loc=-2,scale=4, size=N)
array_3 = uniform.rvs(loc=-1,scale=7, size=N)
array_4 = 1/np.tan(array_3)
array_5 = uniform.rvs(loc=-1,scale=1, size=N)
array_6 = function(array_5)
array_7 = function(array_6, array_5 and array_4)
array_8 = function(array_1 and array_7)
array_9 = function(array_2 and array_7)
M=np.zeros([N+4,N+4])
for j in srange(N+4):
if j>0:
two arrays (C and D) with len=j-1 are created
for k in srange (j):
if C[k]<=0 and D[k]<=0:
M[j,k]=1
if j+1<N+4:
two arrays (C and D) with len=((N+4)-j-1) are created
for k in srange ((N+4)-j-1):
if C[k]<=0 and D[k]<=0:
M[j,k+j+1]=1
An algorithm with matrix M is executed and values 'b1' and 'b2' are generated
M_hor=M.copy()
Some values in M_hor are changed and an algorithm with matrix M_hor is executed and values 'b3' and 'b4' are generated
M_ver=M.copy()
Some values in M_hor are changed and an algorithm with matrix M_hor is executed and values 'b5' and 'b6' are generated
B1=np.append(B1,b1)
...
B6=np.append(B6,b6)
A1=np.append(A1,sum(B1)/100)
...
A6=np.append(A6,sum(B6)/100)
Like you can see, len(A1)=...=len(A6)=len( cant_de_cadenas) (because in An are the average values of 100 repetitions -included in Bn-).
While many arrays are created (array_1,array_2 etc , with lenght N), in each one of the 100 cycles 'for u in srange (100)' these arrays are overwritten (with the same name).
The same applies to B1,...,B6 arrays: in each one of the len(cant_de_cadenas) cyles 'for N in srange (cant_de_cadenas)' these arrays are overwritten (with the same name).
I tryed with gc and gc.collect() and nothing work!
In addition, i cant use memory_profiler module in sage.
What am I doing wrong? Why the memory becomes full while running (starts with 10% of RAM used and in 1-2hour is totally full used)?
Please help me, I'm totally stuck!
Thanks a lot!mresimulatorThu, 22 Aug 2013 05:19:50 -0500http://ask.sagemath.org/question/10462/Array of graphs consuming too much memory?http://ask.sagemath.org/question/10048/array-of-graphs-consuming-too-much-memory/I want to work in Sage with a large array of small graphs.
To create this array, I load a textfile that has 100000 lines of the following form
gs = []
gs.append(Graph([(0,1,0),(0,1,1),(0,1,2),(0,1,3),(2,3,4),(2,3,5),(2,3,6),(4,5,7),(4,5,8),(4,5,9),(0,1,10), (0,1,11),(0,1,12),(0,1,13),(0,1,14)]))
gs.append(Graph([(0,1,0),(0,1,1),(0,1,2),(0,1,3),(2,3,4),(2,3,5),(2,3,6),(4,5,7),(4,5,8),(4,5,9),(0,1,10),(0,1,11),(0,1,12),(0,1,13),(0,2,14)]))
gs.append(Graph([(0,1,0),(0,1,1),(0,1,2),(0,1,3),(2,3,4),(2,3,5),(2,3,6),(4,5,7),(4,5,8),(4,5,9),(0,1,10),(0,1,11),(0,1,12),(0,1,13),(2,3,14)]))
The textfile occupies a total of 14Mb of diskspace only, but when imported into Sage, the memory usage of the process jumps by nearly 800Mb, and indeed at intermediate stages of the importing, it jumps to over 5Gb before dropping back down again. (Presumably this is due to some sort of memory allocation strategy that keeps doubling the memory required?)
Clearly I am doing something wrong, because an array of 100000 graphs should be no trouble at all to a modern computer, but I don't know **what** I am doing wrong and how to fix it.GordonSun, 21 Apr 2013 21:20:57 -0500http://ask.sagemath.org/question/10048/how to increase memory used by sagehttp://ask.sagemath.org/question/9406/how-to-increase-memory-used-by-sage/Hello
I want to use sage with RAM memory 4Go because my programm is to late.
it's possible at sage? how can I do this? sezzouakTue, 09 Oct 2012 07:22:12 -0500http://ask.sagemath.org/question/9406/