itsme

769 Reputation

14 Badges

17 years, 107 days

MaplePrimes Activity


These are replies submitted by itsme

@zippo

note this was a while ago, but i'm pretty sure i had the same problem...

through some trial and error, here is a call i would make after exporting the plot (through a function similar to what i posted)

    system(sprintf("sed 's/^%%%%BoundingBox.*/%%%%BoundingBox:  -500 -500 2000 2000/g' /tmp/%s.eps > /tmp/%s_box.eps  ; ps2pdf14 -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=2400 -dDEVICEHEIGHTPOINTS=2400 -dOptimize=true  -dEPSCrop -sOutputFile=/tmp/%s_box.pdf  /tmp/%s_box.eps; pdfcrop  --margins '5 20 5 20' -clip /tmp/%s_box.pdf %s/%s.pdf; sleep 2; convert %s/%s.pdf %s/%s.png" , v_fileName, v_fileName, v_fileName, v_fileName, v_fileName, v_fileDir, v_fileName, v_fileDir, v_fileName, v_fileDir, v_fileName));

this fixed the issue for me. It might (or might not!) be helpful to you... it should be easy to divide up the commands to see all the things i'm calling in a row. it's *really painful* as you see, but it should't take long to adapt this to your code... of course the last call to convert could be to jpeg or bmp instead of png if that's what you need.

 

 

@zippo

If you're exporting to postscript (which you seem not to be, but possibly if you could do that), then you can edit those files by hand (they are usually plain text). There are fields in there (Look for something like BoundingBox) which control the sizes of all elements, in particular the whitespace around the actual plot - just change those to something that works.

If you're on linux, then there is often an easy way to fix some of the plots in a more "automagical" way. You can export an eps file from maple, and then run it through a program called ps2pdf14 like this:

ps2pdf14 -dEPSCrop -dPDFSETTINGS=/prepress  myfile.eps

that will often fix the issues (although you'll end up with a pdf file, which may or may not be good). Note, I haven't done this in a while, so your millage may vary.

As I said elsewhere in this thread, another external tool might be better suited for this.

@Alejandro Jakubi 

yes... academic contacts must be a large part of this... it would be a fascinating statistic to see the usage/sales numbers for the big three Ms and see how they've changed over the years... but one can only speculate.

The nice part of all of this is that the open source alternatives have (especially recently) been gaining ground and maturing. In some areas (arguably) such as say linear algebra or plotting, they are already on par or more feature complete than the commercial offerings.

The answer may be highly personal and will surely depend on what kind of stuff you're interested in doing. The best way to make this decision might be to try them for yourself!... Pick a project that corresponds to something you "usually" work on, and redo it in all the various software packages you might be interested in (don't forget open source collaborations like SAGE - which have come a long way in the last few years, and hopefully, as far as I'm concerened at least, are the future of mathematical computing). This way you can see for yourself what aspects of a given language/environment you like and which ones you don't.

As a side note, Wolfram's (Mathematica's creator) marketing machine is really unstoppable. I am not quite sure how they do it, by in my community, every time mathematical software comes up, all I hear is how unquestionably Mathematica is "the best" in almost everything it does... this even sometimes comes from people who have never used any other software, and even their Mathematica experience consists of a say one or two simple projects they did as undergrads. So at least as far as marketing goes, Mathematica probably is "the best" ;)

@mehdi jafari

you're describing a debugger. Look into that in maple's help.

 

@Alejandro Jakubi 

thanks for your answer.

>>Generically, the best approach is delaying the introduction of floats to the end.

... yes, i've done variations of that approach initially, with no success.

I did not know about the "Veil" mechanism - seems very useful. Unfortunately here things don't work and seem to confuse maple. I think the _U1s are leftovers of the integration that are not properly handled by the veiling. Setting these to say zero (which is clearly wrong if they are really a dummy integration variables!) gives nonsense answer.

I've tried variations of this (for example not explicitly introducing the drive until after doing the inverse), but also get incorrect results.

I also tried reformulating the problem as simply a convolution integral and "manually" integrating with the 'int' command, but that does not work either.


@Preben Alsholm

thansk for your answer... that is too bad.

@teh_allchemist

note that the heap increase might not work if there is no java process involved when running maple from matlab - i don't how much of maple needs to run for this communication to happen.

before you ask your admin for changes, you might want to check if during a run a java process shows up.

 

@teh_allchemist

yah. let us know how it goes.

one more comment regarding memory... since we're poking in the dark a little, if in fact the error you get is related to maple running out of usable memory, one thing you might want to try is increasing the maple's heap.

I see that you are on linux... to do this you can edit /path_to_maple/bin/maple  (this file will get sourced even if you're runnig a gui via xmaple so it's enough to just edit that). 

change the line:

JAVAHEAP=512

to

JAVAHEAP=3072
or

JAVAHEAP=4096

depending how much physical RAM you have.

*NOTE* if you read the source file bin/maple, it allows for changing the heap via command line arguments, but editing it directly is easy enough.

This is the first thing I do when I install a new version of maple. In one of my projects I have to plot multiple large data sets via listdensityplot(). That worksheet fails to execute with maple staling with the default setting, but making the change above, fixes the issue completely.

 

@teh_allchemist

>>I am using the hybrid approach because, I have a dynamic program algorithm written in MATLAB that accepts the output of this algorithm.

ok... i understand now.

Regarding your "Export solutions to matlab code":

I see, so inside MapleToMatlabMemoryDump() you're looping over your Ans vector and converting the data to a "raw" matrix. I hope you see from the discussion above however, that none of this is strictly speaking necessary. It could all be done the first time you loop to fill in Ans, if you want your code to be more efficient (both as far as speed and memory usage).

You don't show how you actually pass the data to matlab, but I will assume it's in "one-chuck", which as acer suggests should be the way to go. 

EDIT: aghh, i missed the maple call in that line, so you are doing this item-by-item. Much prettier approach would be to prepare your full matrix in maple, only then copy the whole thing over to matlab.

>>I am unsure if this problem is related to the amount of memory that maple is allocating because the segmentation fault seems to occur even when the amount of memory allocated to Maple Kernel is within a reasonable amount of memory (1.2gb).

Does the problem ever occur when you try this with small data sets (say for a 100 solutions of Ans), where memory related issues should absolutely not be a problem? (after a restart).

In the worst case (and assuming you don't have to do this kind of "call-out" to maple often in a given run), you could always export your data to disk (see ExportMatrix in MATLAB format), and then just read in the data in matlab.

@teh_allchemist

Regarding this:

>For 50k systems of solutions, each with 20 variables, Matlab takes 7.63MB in memory to store this system in a Dataset (calculated using this code).  Maple takes ~300MB to store the same data in list form (calculated using maple('evalf(kernelopts(bytesused)/1024/1024)')).

You're comparing apples to oranges. According to the docs, kernelopts(bytesused) tells you how much memory is being used by the full maple kernel (not a single object). The link you provided shows how to estimate the memory used by a single object.

Maple will use its internal memory as it computes stuff... this should not really be an issue, unless it starts going above your physical available memory, and your operating system starts to swap (i.e. use your hard drive as RAM)... but ~300MB doesn't sound very unreasonable for an involved calculation. Furthermore, if you're doing all the math in maple, just returning the results back to matlab, then one would expect the total memory usage by matlab's kernel to be "low" and by maple's kernel "high".


In any case... from your code I see that you're casting the results into int32 in matlab - these are 4 byte integers.

So 500k worth of 4 byte integers will take less than 2MB... you have multiple entries per "record" - say 10.. that should be less than 20MB of raw data...  In your case the memory will probably be higher, because each of the 500k entries, is not just (say) 10 integers, but a maple "set" object. So the first thing I would do, is (as outlined in my other post) to first create an array of 500k x 10 integers (i.e. allocate it before you start the loop). And inside the loop, once you solved for the "Ans", simply fill in the given row of this large array... this would guarantee at the end you just have a "raw" data array for which you *know* the size.

The key question is what you want to do once you have your data... just export it out to a file?

If the data are mostly two digits integers (as i guess it is from your post), then exporting it in a text format to a file should in principle actually be even smaller than 20MB, because on average each entry will take 2bytes + 1byte for delimiter/newline.

So maybe I'm missing something... but I suppose I am not sure why you need to do the hybrid maple/matlab approach?

Exporting directly from maple should work fine. Have you tried that? If so, what was the result?

EDIT:

In the spirit of procrastination and given i have so much of my own work that i don't know where to start... here is a some dummy code that shows what I proposed to you in the text above.

restart:

total_runs:=5;
elems_per_record:=3;

#this could be an Array, but ExportMatrix, likes matrices...
data:=Matrix(1..total_runs, 1..elems_per_record, datatype=integer[4]);

#run the loop
for i from 1 to total_runs do
  #here calculate the solution... i'm using a dummy result
  dummy_result:={ICE_T = 10, BAT_P = 30, EM2_T = 50}:

  #now fill in the data for this "record".
  data[i,1]:=eval(BAT_P, dummy_result):
  data[i,2]:=eval(ICE_T, dummy_result):
  data[i,3]:=eval(EM2_T, dummy_result):
end:

#now data has all the data filled in...
data;

#export the data (for example) as text.
#note, the data on disk actually smaller than in memory as explained above!
#(this command returns the bytecount it wrote to disk)
ExportMatrix("data.txt", data);

 

... you can change to code to 500k runs with 20 elements in each case, and it will run and save the data to disk just fine.


i see form here and your previous post you gave up on doing in this purely in maple.

Regarding this comment:

>The number of values is generally ~500k, and therefore I have a loop that dumps the solutions into MATLAB where the values are parsed and stored more efficiently.

Do you mean you're storing the data in matlab's binary format? i think maple can actually do this directly - see ExportMatrix. Also, 500k worth of 8byte data is under 4MB (raw), so even storing it in a text format, should not be bad for a modern machine.... you know your data better, but i'm just saying there might be an easier way to export it (if that's what you're after).

You might have a hard time getting an answer here based on a stack trace - this is not very informative without access to and at least some knowledge of the source code (of maple and matlab in this case). You're probably better off showing a simplified example of the maple/matlab code that shows the bad behaviour.

not sure if this is helpful to you, but i just use a trivial function for priting output when doing derivations and manipulating systems of equations... guarantees 1 equation per line.

pp:=proc(v_list)
local i;
for i in v_list do print(i); end;
end:

... then when dealing with a system of equations can do:
eq1:=[x + y = 2, x - y = 7]:pp(%);

... of course this doesn't print any curly braces.

 

@Glowing

...note that there is a difference between how maple sees Pi and pi. Try:

 

> sin((1/10)*Pi);    
                                                                                               Pi
                                                                                          sin(----)
                                                                                               10

> convert(%, radical);
                                                                                                  1/2
                                                                                                 5
                                                                                         - 1/4 + ----
                                                                                                  4

@Carl Love @acer

very nice - thanks... that does look better than the original.

First 9 10 11 12 13 14 15 Page 11 of 18