logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
blackcat54  
#1 Posted : Monday, April 12, 2010 5:46:54 PM(UTC)
blackcat54

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/23/2010(UTC)
Posts: 60

My formula, which contains 15 nested "IF" statements and 6 Variables, generated an

"Internal compiler error. Insufficient memory to compute." error message.

Each of the 15 nested "IF's" references two variables each with 8 nested "IF's".

So it seems like there are too many nested "IF's".

Any ideas how to fix this?

My next formula was going to have 44 nested "IF's" in it!

Thank's,

Dennis

wabbit  
#2 Posted : Tuesday, April 13, 2010 1:07:53 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
My suggestion would be to use better logic and write better code, as we cannot see either it is hard to be of more help.


wabbit [:D]

blackcat54  
#3 Posted : Tuesday, April 13, 2010 1:32:15 AM(UTC)
blackcat54

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/23/2010(UTC)
Posts: 60

Wabbit,

Here is the code and an explaination....hope it's clear.

The formula plots a 9 day "Centered Avg", and plots a "Derived Avg" + a correction factor "Dif" during the 4 day blank 1/2 cycle delay period. The formula uses a nest of 5 "IFs" and works. "Dif" is calculated on day 5 (RBC=5), the last day the "Centered Avg" is plotted. The remaining 4 days are calculated by the 2nd, 3rd, 4th, and 5th "IFs" and use the "Dif" calculated on day 5.

The 1st "IF" plots the Centered Avg

The 2nd "IF' plots the Derived Avg + Dif on day RBC=4

The 3rd "IF" plots the Derived Avg+ Dif on day RBC=3

The 4th "IF" plots the Derived Avg + Dif on day RBC=2

The 5th "IF" plots the Derived Avg + Dif on day RBC=1

The problem is, coding a 31 Day Avg ends up overloading the compiler.

CenteredAvg:= Fml( "+ag Avg 9");

DerivedAvg:= Fml( "+ag Derived Avg 9");

Dif:=CenteredAvg-DerivedAvg;

Defineda:= IsDefined(CenteredAvg);


CenteredAvg:= ExtFml( "Forum20.Sum",CenteredAvg,1);

RBC:= LastValue(Cum(1))-Cum(1)+1;


If(Defineda,CenteredAvg,


If( IsDefined(If(rbc=4,Ref(dif,-1),0)),

DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=4,Ref(dif,-1),0),1),


If(IsDefined(If(rbc=3,Ref(dif,-2),0)),

DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=3,Ref(dif,-2),0),1),


If(IsDefined(If(rbc=2,Ref(dif,-3),0)),

DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=2,Ref(dif,-3),0),1),


If(IsDefined(If(rbc=1,Ref(dif,-4),0);),

DerivedAvg +ExtFml( "Forum20.Sum",If(rbc=1,Ref(dif,-4),0);,1),

L)))));

wabbit  
#4 Posted : Tuesday, April 13, 2010 1:44:29 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Try using something along the lines of:
Code:

corr:=valuewhen(1,RBC=5,dif);
corr:=extfml("forum20.sum",corr,1); {remove NA}

{plot}
DerivedAvg + corr;



wabbit [:D]

vienna  
#5 Posted : Tuesday, April 13, 2010 2:01:42 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

there are some examples in this thread:
http://forum.equis.com/forums/thread/2270.aspx


tmp:=If(Defineda,CenteredAvg,0);
tmp:=
If(IsDefined(If(rbc=4,Ref(dif,-1),0)),
DerivedAvg +ExtFml( "Forum20.Sum",
If(rbc=2,Ref(dif,-3),0),1), tmp);

etc...

blackcat54  
#6 Posted : Tuesday, April 13, 2010 2:52:53 AM(UTC)
blackcat54

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/23/2010(UTC)
Posts: 60

This seems to work, although I still needed an "IF" function.

CenteredAvg:= Fml( "+ag Avg 9");

DerivedAvg:= Fml( "+ag Derived Avg 9");

Dif:=CenteredAvg-DerivedAvg;

Dif:=ExtFml("Forum20.Sum", Dif,1);

Defineda:= IsDefined(CenteredAvg);

CenteredAvg:= ExtFml("Forum20.Sum",CenteredAvg,1);

RBC:= LastValue(Cum(1))-Cum(1)+1;

Cor:= ValueWhen(1,rbc=5,Dif);

Cor:= ExtFml("Forum20.Sum",Cor,1);

If(Defineda,CenteredAvg,DerivedAvg+Cor)

Thank's to both Wabbit & vienna for your help.

Dennis

Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.