The restart command does not work correctly?

zakyn's picture

This example shows that restart command does not work correctly - it means that it does not clear stack memory(internal memory). The following example shows it. In that procedure there are some mistakes, but I think that the restart command should work correctly whith them.

If you execute the following procedure three times (maybe twice, it depends on the computer memory capacity, but I do not amount to more than three times), the Maple system falls down with out of memory (execution stop - the stack ) - why? You call the restart command, so where the fatal error is. It does not depend on the correct usage of statements in the procedure.


> restart:
stx:=time():
>
> Digits :=15:
>
> test2:=proc(N,n)
> local i,a,xbar,s,R,X;
>
> # the following 3 statements are not correct
> s:=Vector[1..N];
> R:=Vector[1..N];
> xbar:=Vector[1..N];
>
> use Statistics in
> X := RandomVariable(Normal(0,1)):
> for i from 1 to N do
> a:=Sample(X,n):
> xbar[i]:=Mean(a):
> s[i]:=StandardDeviation(a):
> R[i]:=Range(a):
> end do:
> end use;
> printf(" time: %8.2f second \n",time()-stx);
> end proc:

> test2(10000,10);

Does restart do what we expect?

Thank you.

Vladimir

Comments

misunderstanding

I don't understand your complaint. If you call the procedure more than once, the printed result (time of execution) will be incorrect, since stx is not reset with each call (nor is restart called, it cannot be from inside a procedure). If you want to time this procedure, do

time(test2(10000,10));
                           40.419
zakyn's picture

Time is not important.

Hello,

I do not understand that if I try to execute this function for 3 times and between two calling I enter and execute restart, I do not understand, that after the 3rd calling it occures an error with stack limit reached. Why? I think, that restart clear all from internal memory and garbage collector clear everythink of this maple worksheet from pc memory.

Vladimir

roman_pearce's picture

compiled code and restart

I think the Statistics package is using compiled routines (whose memory is not garbage collected by Maple) and they are not releasing the memory when the Maple restart command is used. This is a bug.

For anyone who is interested, the best way to handle this is with a ModuleUnload procedure in your package that calls a routine to free memory. If a package has been loaded (and used) then its ModuleUnload procedure will be called by the restart command.

restart in Maple10 really does not work properly

I tend to agree that there is something is broken with restart.

When I execute the following code in a Maple10 work sheet

> restart;

assume(u1<0);assume(u2>0);assume(U>0);additionally(U<u2);

assume(u0>0);additionally(u0<u2);

u3:=1-u1-u2:

int(1/(u^2*(1-u)*sqrt((u-u1)*(u-u2)*(u-u3))),u=u0..U):

I often have to execute it two or three times before the integral gets evaluated. Frequently I get the following warning:

Warning, unable to determine if 1-u1-u2~ is between u0~ and U~; try to use assumptions or set option _EnvAllSolutions to true

Other times, the integral gets evaluated. So "restart" does not actually clear the slate. Otherwise the result would be the same each time. Either this is a bug, or Maple has an emergent personality.

When I execute the code in Maple8, the integral always gets evaluated with no warning, and the response is MUCH MUCH faster. Maybe things will be better in Maple 11--I honestly hope the regression coefficient is not negative but I am not optimistic.

roman_pearce's picture

bug

Although I can't be completely sure, this looks like an "ordering issue". You should report it as a bug to support@maplesoft.com.

What is happening is this: the time required to solve equations can depend heavily on the order of the variables, where the most significant variables are eliminated first. Most parts of Maple use heuristics to pick "good orders", however these can always produce a tie and in that case the result will be partially random. To further complicate things, the heuristics used by the system change over time as different algorithms are added and also in response to bug reports.

The message about _EnvAllSolutions indicates that solve was called and that it was unable to find a solution for whatever order it was using. The fact that it can sometimes find a solution suggests that the order is partially random, and the fact that Maple 8 always worked tells us that either someone changed something and broke it or the heuristic was just always lucky in Maple 8. That second possibility is actually not a joke, it happens, and it can be hard to deal with.

Your problem looks simple enough that you should report it as a bug. Someone will try to fix it, and in any case it will be added to Maplesoft's massive collection of regression tests.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}