|
Tobin Fricke's Lab Notebook
|
|
|
| rocket science |
[Jun. 28th, 2009|03:01 am] |

This year's ICFP programming contest involves planning an optimal sequence of rocket burns to cause an orbiting spacecraft to visit a collection of other orbiting spacecraft. It's a cool problem—orbital mechanics is quite unfamiliar!
Fortunately, the contest contains three warm-up problems. The simplest is to just move from one circular orbit to another, which can be accomplished via the Hofmann transfer orbit (as suggested by the contest specification). The next requires that you meet up with another orbiting spacecraft in circular orbit. I've solved those two. The final warm-up problem is to leave one elliptical orbit to rendezvous with a spacecraft in another elliptical orbit.
The final problem that these warm-up problems lead to is to find an optimal procedure for visiting a collection of other spacecraft in various orbits—here's where the clever searching and optimization will come in.
As an added twist, the individual problems come packaged as binaries for a virtual machine that you have to implement. Unlike prior years, this virtual machine is quite simple. In fact, it has no branching instructions whatsoever, so it's hard to even call it a virtual machine. You could translate it directly into C, for example.
I think my approach is quite slick: I implemented the virtual machine in C, but then wrote a Matlab (.mex) interface to it, so I can implement the rest of my solutions in Matlab, employing all of Matlab's mathematics and visualization and interactiveness while still coupled to this physics engine implemented in the virtual machine.
However, I think it's time for one-man team "tensor" to get some sleep. (-:
EDIT: 24 hours into the contest, they added a moon! |
|
|
| ICFP call graph |
[Oct. 27th, 2007|11:50 pm] |
Remember the ICFP programming contest? I finally had some time to look at it again. The "RNA" contains seven-letter codes which produce an image. However, lots of the codes present don't code for image operations; we're instructed to ignore them. However, page 2181889 of the instruction manual implies that these codes can be used to produce a call-graph:
"When a Fuun has suffered a severe crash abnormal RNA may be produced. This 'hiccup' RNA is nothing to worry about and doesn't serve any purpose for morphing. It's not entirely clear what the real purpose of the RNA is, but it does seem to be related to the morphing process, because peculiar patterns have been observed. For example, the RNA code CFPICFP occurs very often and seems to indicate a small part of the morphing process is done. There are also other RNA codes, all starting with a C, that most likely indicate the start of a morphing process. Their exact meaning hasn't been figured out, though." My first check was to cause the RNA interpreter to increment a counter every time it sees an unknown RNA code other than CFPICFP, and to decrement that counter every time CFPICFP is seen. This counter doesn't run away, so it seems that the entry-points are identified by single seven-letter RNA codes and not multiple consecutive codes.
Six characters are too few to represent even the number of items listed in the gene (symbol) table in the usual number representation (binary, LSB first, I=0, C=1). Besides, three symbols appear in the "junk RNA": I, C, and P. Perhaps the representation is trinary? That would let us represent 3^7-1=2186 unique quantities, plenty enough to cover the approximately 400 items listed in the symbol table. Assuming that these numbers code for indexes into the symbol table, looking at the distribution of codes tells me that the numbers are coded MSB last and P=2, since "P" never appears in the last position. This leaves two possibilities: (I=0, C=1) and (I=1, C=0). If we choose the latter, then all of the coded numbers fall into the range [0, 256]. This seems auspicious, but my interpretation must still be not quite right, since with this interpretation the most commonly called function is number 111, cow-body. Seems unlikely. |
|
|
| Cult of the Bound Variable -- improved codex and dev kit |
[Jul. 23rd, 2007|11:31 pm] |
In case you're not all tuckered out from this year's ICFP Programming Contest, the creators of last year's contest have just released a new version of the Codex "with bug fixes, harder problems, and easter eggs." They've also released the tools they used to create the Codex, including "the entire source code for the Codex, and most of the tools... used to build the contest, including an ML to UM compiler, a UM assembler, puzzle generators for some of the problems, a graphical Antomaton simulator, etc." They've published a technical report (complete spoiler!) and the slides and video of a talk. |
|
|
| ICFP contest |
[Jul. 21st, 2007|02:00 pm] |
The ICFP Programming Contest is well under way. Recall that last year we were given an alien codex that turned out to be executable code. After we wrote a virtual machine for the alien codex, we were plopped into a sort of unix hacking text-adventure, filled with various puzzles. This year we're given a huge strand of alien DNA, and instructions on how to interpret the DNA!
The DNA turns out to be a strange pattern-matching language that ultimately spits out another code--RNA!--which in turn gets translated into an image. The goal is to come up with new strands of DNA that we can prepend to the alien DNA to transform the image in various ways. evan, four, and I have been working on it since about 3am PDT on Friday. The Task hints at one DNA prefix that will "do something interesting;" it turns out to invoke a self-check:

Well, we apparently still have some bugs in our virtual machine, somewhere--hence the corruption in the self-check... And we have only barely scratched the surface of figuring out how the DNA codex actually works.
[originally posted at nibot] |
|
|
| icfp: 2d language |
[Aug. 13th, 2006|08:01 pm] |
We log into ohmega's account and we find a specification, an interpreter, and a couple of problem statements for a perverse programming language called 2d, in which programs are drawn out as "ASCII art" flowcharts. Hilariously the specification explains, "This
language frees the programmer from the shackles of linear programming
by allowing programs to occupy two dimensions. However, unlike 3- and
4- dimensional languages like CUBOL and Hypercard, it does not
distract the programmer's attention with needless dimensional abandon."
The flowchart describes not just the data flow, but also the control flow of a program, because boxes aren't evaluated until all of their inputs have values.
The specification for 2d is available on Wikipedia.
I found it useful to first write my programs in Scheme, and then translate them into 2d. For example, here's a function that concatenates two lists, written first in Scheme and then in 2d:
(define (append listA listB)
(if (empty? listA)
listB
(cons (car listA)
(append (cdr listA) listB))))
The same program, implemented in 2d:
,..........................|........................................,
:append | :
: v :
: *==================* :
: !send [(N,S),(N,E)]!-----+ :
: *==================* | :
: | v :
: *=============* | *============* :
--->!case W of S,E!--------#----------->!send [(N,E)]!---------------
: *=============* | *============* :
: | | :
: v v :
: *=======* *==========* :
: !split N!-------->!use append!------------+ :
: *=======* *==========* | :
: | v :
: | *====================* :
: +------------------------------->!send [(Inl (W,N),E)]!-------
: *====================* :
,..................................................................., |
|
|
| ICFP: Optimizing the UM VM |
[Aug. 7th, 2006|05:15 pm] |
When describing my implementation of the Universal Machine virtual machine for the ICFP contest, I noted that it was disappointingly slow in running the benchmark. It turned out to be perfectly zippy enough to run the Codex with no noticable lag. However, it required a couple of times as much time to run the benchmark as some reported implementations, and a few optimizations were easy and obvious, so I implemented them. I also tried compiling my program with various flavors of compiler optimizations. The gcc compiler supports four levels of optimization, ranging from "-O0" (no optimization) to "-O3" (maximum strength). Moreover, the three versions of my program were:
A naïve implementation that did everything in the safest, easiest-to-debug, easiest-to-read, easiest-to-write way (or what seemed so at the time of writing). In particular, this involved calling a function every time the virtual machine wanted to allocate an array, and my program did bounds checking and all that. In the next version, I took out all my array-handling functions. Instead of numbering arrays created in the virtual machine sequentially, I just handed back pointers to the virtual machine—conveniently the virtual machine operates on 32-bit values and pointers are 32 bits on my machine. In this version, it's possible for the program running in the VM to cause a segfault, but as long as the program running in the VM is well-behaved, it should run faster, since all function calls are eliminated. For a third and further optimized version, I eliminated the switch statement in favor of a jump table with lots of duplicated code and gotos, which minimizes the number of jumps taking place. This was totally inspired by a thread in evan_tech's journal, since I didn't know about gcc's support for computed gotos.
The resulting code is about as optimized as I can imagine writing in C. (Though there's still a lot of bit-shifting that could be reduced.) There's really not too much in this program in the beginning to take out! ( To see the relative merit of these manual optimizations in conjunction with various levels of compiler optimization, I wrote a tiny shell script to compile and test each of the three versions of my program with each of the four levels of compiler optimization. The results are summarized in the table below. The numbers are the numbers of seconds required to execute the SANDmark benchmark, so lower numbers are better:
The results are an impressive victory for compiler optimizations. With -O3 there's virtually no difference between the "naïve implementation" and the most hand-optimized version. |
|
|
| ICFP2006: Decrypting the Codex |
[Aug. 4th, 2006|08:19 pm] |
From the sound of evan_tech's descriptions, this year's ICFP programming contest was downright surreal. The premise: You're given an archaeological find from an ancient yet computer-using civilization. You have a description of a virtual machine called the "Universal Machine" and you have the Codex. The rest is up to you. This leads to a series of puzzles, an elaborate programmer's Zork game, a console-mode Myst if you will. The contest is over, but the problem sounds fun, so I thought I'd give it a try.
( a few details )
The code, with no optimizations: http://web1.pas.rochester.edu/~tobin/contest/icfp/2006/um-0.c (Clearly some optimizations are necessary, since it takes seven and a half minutes to run the SandMark benchmark/test, while others on the icfp-discuss list are reporting times of about a minute.)
[tobin@eagle icfp]$ ./um codex.umz self-check succeeded! enter decryption key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx decrypting... ok LOADING: 9876543210
== CBV ARCHIVE == VOLUME ID 8
Choose a command:
p) dump UM data x) exit
? ?
Aha! Executing the codex, I'm given the option of dumping some UM data. I assume that's another program to execute with the UM? |
|
|
| navigation |
| [ |
viewing |
| |
most recent entries |
] |
| |
|
|