 |
|
| Science Forum Index » Fractals Science Forum » Continuous Gray code optimization - scale free... |
|
Page 1 of 1 |
|
| Author |
Message |
| Lemon Tree... |
Posted: Tue Sep 22, 2009 4:17 pm |
|
|
|
Guest
|
I recently found a paper about a really simple but effective numerical
optimization algorithm based on extending the idea of Gray codes to
the continuous domain.
I've put the paper and some sample code here:
http://code.google.com/p/lemontree/downloads/list
Gray codes seem related to fractals to me. Is their any fractal system
I can use to get similar scale free, self similar effects. Of course
it would need a high probability density near the center and low
density further away.
Sean O'Connor |
|
|
| Back to top |
|
|
|
| Roger Bagula... |
Posted: Fri Sep 25, 2009 10:44 am |
|
|
|
Guest
|
On Sep 22, 7:17 pm, Lemon Tree <bitterlemo... at (no spam) yahoo.ie> wrote:
[quote:4b9cadf13e]I recently found a paper about a really simple but effective numerical
optimization algorithm based on extending the idea of Gray codes to
the continuous domain.
I've put the paper and some sample code here:
http://code.google.com/p/lemontree/downloads/list
Gray codes seem related to fractals to me. Is their any fractal system
I can use to get similar scale free, self similar effects. Of course
it would need a high probability density near the center and low
density further away.
Sean O'Connor
Sean O'Connor[/quote:4b9cadf13e]
Back in the late 90's Gary Adamson came up with an algorithm for gray
code
in terms of binary Pascal's triangles and I extended it to
what I called a corner dragon IFS ( scale 2):
Mathematica using Mark McClure's DigraphFracttals.m file:
f = {{{1/2,0},{0,1/2}},{0,0}};
g = {{{0,1/2},{-1/2,-0}},{0,-1/2}};
h = {{{0,-1/2},{1/2,0}},{-1/2,0}};
Needs["DigraphFractals`"];
terdragonDigraph = {{{f, g, h}}}
ShowDigraphFractals[terdragonDigraph, 7];
True basic code:
SET MODE "color"
SET WINDOW 0,1026,0,750
SET BACKGROUND COLOR "white"
LET x=rnd
LET y=rnd
LET a=0
LET s1=1200/1.5
LET s2 =s1*750/1026
RANDOMIZE
PRINT" corner DRAGON I.F.S.( Gray Code) "
PRINT" BY R.L.BAGULA 20 March 1999 ©"
LET s0=1/3
FOR n= 1 TO 2560000
LET a =RND
IF a <= 1/3 THEN
LET x1=x/2
LET y1=y/2
END IF
IF a<= 2/3 AND a>1/3 THEN
LET x1= y/2
LET y1=-x/2 -1/2
END IF
IF a<= 1 AND a>2/3 THEN
LET x1= -y/2-1/2
LET y1=x/2
END IF
SET COLOR 255
LET x=x1
LET y=y1
IF n>10 THEN PLOT 1026/2+s1*x+155,750/2+s2*y+115
NEXT n
END
Here's a link to a Mathworld/Mathematica site:
Weisstein, Eric W. "Gray Code." From
MathWorld--A Wolfram Web Resource.
http : // mathworld.wolfram.com/GrayCode.html
Here is Adamson's algorithm applied to a Hadamard self similar fractal
in True Basic:
LIBRARY "truectrl.tru"
DIM vals(6)
SET MODE "color256"
CALL TC_Init
CALL tc_setunitstopixels
CALL tc_show_default (0)
CALL TC_GETSCREENSIZE(XL,XR,YB,YT)
CALL tc_getsysinfo("MENU HEIGHT",VAL$,VALS())
LET menuheight = vals(1)
LET winbar=vals(1)
LET taskbar = int(1.4*menuheight)
CALL tc_getsysinfo("TITLE BAR HEIGHT",VAL$,VALS())
LET winbar=winbar+vals(1)
CALL TC_Get(0,"FONT METRICS",val$,vals)
LET fsm = vals(2)
CALL TC_WIN_Create(DISPLAY,"title|close",0,XR-1,YB-taskbar-1,winbar)
CALL tc_win_settitle (DISPLAY,"Hadamard Gray Code")
CALL TC_SHOW(DISPLAY)
CALL TC_Win_RealizePalette(DISPLAY)
CALL TC_WIN_NOHIDE(DISPLAY,1)
ASK PIXELS XM,YM
set mode" color"
SET WINDOW 1,XM,1,ym
SET COLOR MIX(0) 1,1,1
SET COLOR MIX(1) 0,0,0
PRINT" Hadamard/Sylvester matrix as 0's and ones Gray Code"
PRINT " input binary power n:2^n maximum 1024= 2^10"
INPUT n
DIM b(0 to 1024,0 to 11)
FOR i= 0 to 2^n
FOR k=0 to n
LET b(i,k)=int(mod(i/2^k,2))
NEXT k
NEXT i
REM BINARY TO GRAY CODE AS ONE HIGHER BIT VECTOR XOR
FOR i= 0 to 2^n
FOR k=0 to n
LET ab=b(i,k)
LET bb=b(i,k+1)
IF ab =0 and bb=0 then LET CC=0
IF ab =0 and bb=1 then LET CC=1
IF ab =1 and bb=0 then LET CC=1
IF ab =1 and bb=1 then LET CC=0
LET b(i,k)=cc
NEXT k
NEXT i
FOR i= 0 to 2^n
if i>xm then exit for
FOR j=0 to 2^n
IF j> ym then EXIT FOR
LET sum =0
FOR k=0 to n
LET sum=sum +b(i,k)*b(j,k)
NEXT k
if sum =0 then SET COLOR 1 else set color 0
PLOT i,j
NEXT j
NEXT i
BOX KEEP 1,XM,1,ym in box$
CALL write_Image( "pict",box$, "c500:HadamardGrayCode.pict")
GET KEY d
CALL tc_cleanup
END
I hope that helps.
Respectfully, Roger L. Bagula
11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 :http://
www.geocities.com/rlbagulatftn/Index.html
alternative email: rlbagula at (no spam) sbcglobal.net |
|
|
| Back to top |
|
|
|
| Lemon Tree... |
Posted: Sun Sep 27, 2009 1:48 am |
|
|
|
Guest
|
Thanks. I'll have to think more. That Continuous Gray code algorithm
is significant and should be of great use in open-ended evolution. It
is also susceptible to considerable improvement, you can do better.
Why does it work so well? What are the most rational improvements that
can be made? I'll look at the code you provided and see if there are
any new ideas for me. |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Wed Dec 02, 2009 4:09 pm
|
|