Mona Lisa in Circles

User projects written in or related to FreeBASIC.

Mona Lisa in Circles

Postby sean_vn » Dec 25, 2013 1:12

I have 2 new ideas relating to optimization. One is a short cut to creating multi-scale mutations. If you take a 32 bit random number and clear the second most significant bit then as a floating point number it is multi-scale mutation between -2 and 2. Put another way it is equally likely that you will get a mutation of 0.1, 0.01, 0.001, 0.0001....
That means you don't need to find a characteristic scale where mutations are likely to be effective.
Also I have implemented as similar idea in terms of the number of population elements the mutation is applied to. This should greatly help evolving really big sets of parameters.

Mutations in the range -2 to 2 are ideal for mutating parameters in the range -1 to 1, so that's the way I've set it up.

http://www.mediafire.com/download/ub87v52cla51buf/MonaLisaInCircles.zip

If you are affected by strobing lights maybe you don't want to run the Mona Lisa in Circles demo, and just look at the source code instead. Anyway as is typically the case in such matters you need to run the demo for a fairly long time to see results. Also for whatever reason I couldn't get transparency working, which would have helped the demo work better.
Sean O'Connor
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Dec 25, 2013 2:25

I've been running the code for a couple of hours now and I can see a skewed image of Ms. Mona Lisa. Clearly I set up the cost function( image comparison) a bit wrong. Anyway I am still impressed, that is really rather good.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Dec 25, 2013 5:20

Ok, I've stopped making so many assumptions about where pointers actually point to and other "shortcuts'.

http://www.mediafire.com/download/031c3eh5t8zvo3m/MonaLisaInCircles3.zip

Edited again, so...:<
Last edited by sean_vn on Dec 26, 2013 3:21, edited 1 time in total.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Dec 25, 2013 6:32

sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Dec 30, 2013 2:50

I did a little more work on the idea:
http://www.mediafire.com/download/ppkdm4wy51urr2o/Twilight
I'll try the algorithm with a few other things and see how far I get. Certainly polka-dots are very annoying.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Dec 30, 2013 8:04

For the moment this is where I am:
http://www.mediafire.com/download/bdcphy68hwxx1g5/Rainbow.zip
However, I understand exactly what further improvements I have to make. I just need a little time.

31 December 2013:
http://www.mediafire.com/download/v6r770hm988c0v0/Flutter
I should mention that the random number library is by Agner Fog.

1 January 2014:
http://www.mediafire.com/download/we5rm5napahqys5/Pinkie.zip
The basic idea is to sculpt the probability distribution of mutations in such a way that evolution can proceed rapidly and in a way that is (more or less) oblivious to scale.
In the last item I have used grandparent,parent,child optimization. It may be advantageous. I have not put the actual optimization algorithm code inside a function block. It is so simple that I think it is cumbersome to enclose it that way. You would have to pass a lot of parameters etc.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Jan 06, 2014 4:11

The latest version:
http://www.mediafire.com/download/m61bn61kueo4jjp/Rarity.zip
I found the shr= operator is modulo 32 when used with uinteger which was a little unexpected in a higher level language.
But many things are unexpected.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Jan 06, 2014 8:50

Image
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby BasicCoder2 » Jan 06, 2014 18:31

Can you explain in words, not code, what your algorithm is actually supposed to be doing?
Is the Mona Lisa pixel array the goal state you are trying to mutate toward or what?
BasicCoder2
Master
 
Posts: 965
Joined: Jan 01, 2009 7:03
Has thanked: 6 times
Been thanked: 17 times

Re: Mona Lisa in Circles

Postby sean_vn » Jan 07, 2014 1:29

The goal is to reproduce the original Mona Lisa picture as closely as possible using small circles.
The cost function is the pixel array difference of the Mona Lisa picture image and the circles image.
There are 2 arrays that contain information about how to draw the circles, a parent and a child.
Just to start things the parent is given an absurdly large cost value (higher than anything than can be returned by the cost function), which will cause it to be replaced on the first round. Alternatively it could just be given its true cost by calling the cost function with the parent array.
The cost function is the used to determine if a mutated child array produces a circles image that is closer (pixel difference-wise) to the Mona Lisa picture image than the parent array. If so, the parent is replaced by the child.

I don't know how strong the algorithm is compared to the current offerings of computer science. It could be so-so to state of the art.
Anyway, I have never seen before the idea of deliberately tailoring the mutations using a structured probability distribution.
I have only seen simple mutations used such as from the Gaussian distribution, maybe Levy flight is the most complex one used.
Anyway, the algorithm is provided completely on a hobby basis. You can try it with different problems if you want.
I have written the code in such a way that I can turn it into a C library easily.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby OlDosLover » Jan 07, 2014 10:05

Hi all,
Very impressive picture. Not that i understand the code but never the less something to study for the future i think.
OlDosLover.
OlDosLover
 
Posts: 10
Joined: Jan 05, 2014 23:13
Has thanked: 0 time
Been thanked: 0 time

Re: Mona Lisa in Circles

Postby sean_vn » Jan 08, 2014 3:28

This is the latest version:
http://www.mediafire.com/download/h7ylcqpi6yhropi/Canterlot.zip
I will leave the mutation/optimization code there at the moment and look at some applications for it. All the better to see how useful it actually is or not. I think it should work quite well with other difficult problems. However I think it is also necessary to pose problems in a form evolution can actually solve. There is really no point in posing problems that are so brittle that most any mutation is destructive. I think the combination of powerful evolutionary solvers together with deliberately facile problems could yield interesting results.
28 January:
I have this preliminary facile programming language for evolutionary algorithms:
http://www.mediafire.com/download/m4sm9 ... nguage.zip
It's in the C language at the moment and hardly tested. I can see however that the evolutionary algorithm is able to use it.
I'll do a version in FB and test it more extensively.
sean_vn
 
Posts: 61
Joined: Aug 06, 2012 8:26
Has thanked: 0 time
Been thanked: 0 time


Return to Projects

Who is online

Users browsing this forum: No registered users and 2 guests