Archive for the 'computers' Category

Newscientist: Horizontal and vertical: The evolution of evolution

http://www.newscientist.com/article/mg20527441.500-horizontal-and-vertical-the-evolution-of-evolution.html?full=true&print=true

Lately, I’m increasingly thinking, especially after reading this article, that evolutionary computing would benefit greatly from using a more bacterial type of evolution, where genes are shared between often unrelated organisms, rather than brute inheritance. Another way of looking at it, is it might be good to deal with the complexities of subroutine sharing (which functional programming would make easier) than the complexities of sexual reproduction which make my eyes glaze over to read the solutions offered for. Maybe I’m just not clever enough (my earlier post on genetic programming had a little ruby script and it only uses asexual reproduction).

I am skeptical of the article’s claim that the shared genetic code of all organisms must mean that genes were shared between organisms like bacterium do today. Firstly, bacterium don’t all share some common genes due to the passing of genes between species as it is. Secondly, clade evolution – where clades that are just better at evolving edge out others over time could be sufficient explanation. Surely DNA-based life had immense advantages over life with less fault-tolerant code. Just the same, the article makes a good point that biologists are, being human macro-centric – they focus on multi-cellular organisms even though most of the biomass, even more of the variety, along with the vast, vast majority of the history of life on this planet, is prokaryotic.

Exercise 3-6: Sorting Lists & 3-7 Using Library Modules

It looks like there’s one other guy on the internet who’s posting his answers for the exercises in this book. So, I’ll be linking to his so you (and I) can compare our answers. He knows what he’s doing. In his posts, he talks about, e.g., what he’d do in Haskell. I’m not a functional programming guy (lisp gives me the heebie-geebies, my earlier post on evolutionary programming where I used it notwithstanding). So, below are my answers (click to see more if you’re looking at the blog and not this post by itself) and here is the Japanese guy’s answers.

Continue reading ‘Exercise 3-6: Sorting Lists & 3-7 Using Library Modules’

Exercise 3-5: Manipulating Lists

Next installment in my “Thomas does your homework” series…

Continue reading ‘Exercise 3-5: Manipulating Lists’

Exercise 3-4 Database Handling Using Lists

Here’s my clumsy attempt at the database handling exercise. Man, I must be a nerd, but I actually like these exercises.. I’m also enjoying my biology class. Is there something wrong with me?
Continue reading ‘Exercise 3-4 Database Handling Using Lists’

Erlang Exercises – Chapter 3

I learn by doing much more than by reading or listening, so as I go through O’Reilly’s Erlang Programming, I take the exercises at the end seriously. Generally, when I learn a new programming language, while I read, I’ll make a program of my own choosing, perhaps something that will be useful to me or that I could sell. However, with Erlang, I don’t even know where to begin using it yet. I want to get really, really good at it before I even attempt to make anything with it (I think remembering the mistakes I made with my first Ruby on Rails project caused this shift in attitude.. and let’s not forget the triumphs of reading Mastering Regular Expressions in its entirety).

I will be posting my attempts at the exercises, in case others might find it useful or seasoned Erlang programmers might tell me what I may be doing wrong. I’ll be spacing out my answers to chapter 3 over the week to keep things interesting. Here are the first three exercises from Chapter 3:
Continue reading ‘Erlang Exercises – Chapter 3′

Update (on Earlier Post on Evolutionary Programming)

Apparently, without realizing it, I implemented a technique known as grammatical evolution, and the thing I’ve been aiming to do is called a genetic programming problem solver. More on this later, but here is the earlier post.

Ah, now Mac OS X is finally behaving…

I mentioned in a post earlier about my frustrations w/ the mac keyboard. I finally got around to being frustrated enough to google and (pretty simply) solve the issues I had. Basically, as a programmer the craaaazy way home and end work on mac is unacceptable. The Windows & UNIX way is better (home and end of the line, not the document). Here are the relevant, helpful posts:

http://blog.dubh.org/2007/11/configuring-mac-os-x-terminal.html
http://www.starryhope.com/tech/apple/2006/keyfixer/

Old posts, but very, very helpful. There really should just be a system-wide option, something like “home and end keys operate on line, not document”. Indeed, the primary reason I’m making such a banal post is I hope Apple’s marketing research finds this and maybe does something about making the growing UNIX nerd & programmer user base a lot happier..

I Created Life!

Here is a ruby script I quickly whipped up to teach myself genetic programming/evolutionary programming, and also to demonstrate basic principles of biology (please see below to see how it works.. if you’re on my front page, click to read more first). I think I’m going to write something more sophisticated in erlang (I don’t know erlang, but I’m intrigued) after I get further down the road in gp, but here’s what I quickly whipped up. Since writing it, I have started reading A Field Guide to Genetic Programming and already notice some things I should have done a little different. But in some respects, having a simple string of characters change their role in different modes is elegant and I think I prefer that way of doing things, despite shortfalls in statistical bias. Here are some observations I have at this point:

I know the people researching gp are really smart, so there’s probably something I’m missing, but I don’t see how genetic programming is supposed to quickly find solutions. Evolution is as slow as molasses. You need to dig through millions of years of dirt to see actual changes. I can only see gp quickly finding solutions if the process is being run continually, with multiple challenges or “resources”. I was glad to see, after having this thought, mention of multi-objective (5.1.3) and coevolution (5.4) in the book. It makes me think I’m on the right track. I also remember a while back reading in the article Discover had about Avida that when there was only one resource, one species would quickly capitalize on that and then the evolution would stagnate, but having multiple resources would create diversity and even better solutions at attacking that one resource. The ability of organisms to repurpose adaptations is important in evolution and without it, most complexity would not have been possible.

This leads me to another point. It seems gp works best when it works the most like evolution in the real world works. The rate of mutation is low and, despite my initial intuitions that a high mutation rate would lead to a good solution more quickly, I found that it was actually harmful to do so. Even though, in this script, there is a bias towards shorter programs (the longer the chromosomes, the more calories it takes to create just one offspring), when I had a higher mutation rate, like, say, 1 out of 5 copies, the length of the genes would get really, really long as a defense against mutations. This could happen because if the last parenthesis of the mini-lisp program is closed prematurely, the rest of the genes are ignored. Junk dna. In my program, at least, junk dna was a defense against mutation since I would get really short programs that have long tails of junk after them, but decreasing the mutation rate shrunk those tails down to almost insignificant. Weird. Please try downloading this and edit it to see for yourself.

While mutations should be rare, it helps to have variety. I did just substitutions at first and it worked, but it took a while. I also added stutters, insertions and deletions. Once I added stutters, it helped a lot! Even before adding stutters, I found that, when the “challenge” was 6 * x, I would get x + x + x + x + x and something like 7 * x competing with each other for a long time (5x or 7x often becomes the leading candidate after a few generations and it takes forever for any 6x to show up). Adding the stutters seemed to get multiplication through addition happening faster, though.

Download yeasties or copy/paste from below (requires ruby and clisp):

Continue reading ‘I Created Life!’

Bandwidth Detection AS3

ex animo » Blog Archive » Automatic Bandwidth Detection for SMIL + FLVPlayback + Progressive Downloads

I was frustrated trying to get my flash player to do bandwidth detection, then stumbled on this site.. Apparently, there’s a bug in FLVplayback? Psh.

Set up Verizon USB720 BroadbandAccess card on OpenSuse 11

Just wanted to share the settings I used to get it working (because discussion boards are full of things that don’t work, and most people are jerks who never share that they got something working).

Using KNetworkManager (haven’t gotten it working using if-up)

Click on KNetworkManager icon (it’s the one that looks like a globe) in the taskbar. Go to “New connection…” and select ttyUSBX from the submenu (X may be 0, or something higher if you have a USB-RS232 converter like I do). Then, enter these settings:

Number: #777
Username: YOURVERIZONNUMBER@vzw3g.com
Password: vzw

Baud Rate: 230400
Data bits: 8
Parity: None
Stop bits: 1
Send delay: 0

Make sure “no authorization” is checked. Also, in the last screen, you might want to check “auto connect”.

Similar settings should work with Sprint’s usb card, which is pretty much identical.

Install Flash Plugin in Linux x86_64

Download the .tar.gz plugin (even if you’re using an .rpm-based distribution), untar and:

nspluginwrapper -i libflashplayer.so

You don’t have to copy the file first or anything. If that command doesn’t work, install nspluginwrapper, but any self-respecting x86_64 distro will install that plugin by default for your browser.

T-Mobile Web (formerly T-Zones) settings for Samsung/Softbank 707scii

I got me a Softbank 707scii. Some sellers on eBay actually offer gprs unlock. This means, I can surf the internet on my Japanese cell phone! So, anyone who’s trying to figure out the right settings, here they are:

Access name: wap.voicestream.com
Authorization type: Normal
User ID: [blank]
Password: [blank]
Protocol: WAP
Home URL: http://wap.myvoicestream.com (I reckon this optional.. Yahoo is also good)
Gateway address: 216.155.165.050
Secure connection: Off
Log-in timeout (sec.): 90

I might add that the trick seems to be power cycling the device.

One more thing about Mac OS X keyboard suckiness

…they hijack the F keys. I like having a volume key, etc., but why can’t that be additional keys? F5 is refresh! kuh

Earlier Post:
Mac OS X vs. My Keyboard

How to respond to events in a custom WindowSWF panel (Actionscript 3)

One power you have in making custom panels for Flash (or whatever recent Adobe programs that support flash-based panels) that is almost never realized is the ability to respond to events. Does anything like this sound familiar to you: you want to update the panel every time the user changes a document or creates a new one? You want to do something when the document closes? The user moves their mouse (and not directly above the panel)? Fools all over the internet dogmatically claim that it’s impossible. It’s not. Here’s how you do it:

Writing purely in Javascript for Flash (JSFL), you might notice that you can attach events much like you can in actionscript thusly:

someCallback = function () {
    alert('all your bases are belong to us');
    }

fl.addEventListener("documentChanged", someCallback);

To do that in your flash panel, simply enclose that stuff in an MMExecute(); Thusly:

MMExecute("someCallback = function () { alert('all your bases are belong to us'); }");
MMExecute("fl.addEventListener("documentChanged", someCallback);");

And.. it works. Sure enough. But that’s not very interactive. I want FLASH to do something (since javascript just doesn’t do much in the authoring environment), like, say, update the display with new info. Wouldn’t it be cool if I could do this?

MMExecute("fl.addEventListener("documentChanged", SomeAS3Function);");

Alas, not possible. Holy Hell. ExternalInterface can’t even help us out here (right? I’d love to be wrong here…) But here’s what you can do. It’s not terribly pretty, but it does the job and when Adobe comes to their senses and builds AS3 JSFL communication into newer products, it would be very easy to modify the code for a more elegant solution. You can have global variables in the javascript and access them anywhere in the flash document. So, try this:

MMExecute("var updt = false");
MMExecute("updateDoc = function() { updt = true; }");
MMExecute("fl.addEventListener('documentChanged', updateDoc);");

Then, somewhere that is always looping (i.e., where stop() wasn’t called), you’ll want to add an event listener for entering the frame:

this.addEventListener(Event.ENTER_FRAME, updatey);
function updatey(event:Event) {
if(MMExecute("updt") == "true") {
   // whatever you wanna do! Resurrect dinosaurs, make robots feel...
   MMExecute("updt = false;");
   }
}

Note, that MMExecute returns a string so, though it be boolean in javascript, it’s converted to “true” and “false” in actionscript. When dealing with arrays and such, this becomes particularly frustrating, though you must question the design of your program any time you are passing complicated objects around… think about it.

Oh, one final note. It seems the capabilities I wish existed in Flash do exist in Fireworks (?) as detailed here. I looked and looked but could not find any equivalent to IsFwCallbackInstalled for Flash. Given how many things I’ve had to discover that were not anywhere to be found on Adobe’s site and how many undocumented features there are, I can’t help but wondering if a more elegant solution is lurking below.. Do tell me if you find it, mmkay?

Type runes on your Mac

I finally got around to making a Mac OS X keyboard to let you type Futhorc. I don’t know why I waited until just now (probably because it’s not important?), but it was really easy since they even have a program to automatically generate Mac OS X keyboard layouts, rather than typing the needed xml by hand. This is directly equivalent to the one I made for Linux, and by extension to the only Windows one I could find (see page).

Here’s my page on typing runes on your computer. It’s good whether you’re a Windows baby, a Mac fag or a Linux ass. It’s also avail under my code > type runes on your computer.