Tagged-code macros, bug-fixes for examples, and other minor Clojush updates

June 24, 2011
by Lee Spector (lspector)

There have been a couple of Clojush updates since my last post here, with the most significant being tagged-code macros for facilitating the manipulation of code within the tag space (taking arguments from the tag space and then tagging results). Details are in the update comment below.

Available as usual from: https://github.com/lspector/Clojush

20110618: - Switched to Kyle Harrington's version of overlap; it's more clear,
            possibly faster, and may fix a hard-to-trace bug that cropped up
            in a long evolutionary run (?).
20110624: - Replaced lawnmower and dsoar examples with bugfixed versions
            (thanks to Kyle Harrington).
          - Added namespace and made miscellaneous other changes to 
          - Added support for tagged-code macros. Tagged-code macro calls
            have the effect of code instructions, but they take their
            code arguments from the tag space and they tag their code return
            values. They are implemented as macros to leverage the existing
            code instruction set; note that this means that a single call
            will contribute more than one iteration step toward the 
            evalpush-limit. Tagged-code macros appear in programs as hash maps
            that map :tagged_code_macro to true, :instruction to a code
            instruction, :argument_tags to a sequence of tags to be used
            to acquire arguments, and :result_tags to a sequence of tags
            to be used for tagging results. Execution of a macro expands
            the needed code onto the exec stack to grab arguments from the tag 
            space and push them on the code stack, execute the code instruction, 
            and tag results. Note that results will also be left on the code
            stack if global-pop-when-tagging is false. Conceptually, tag values
            are "baked in" to these macros in much the same way that tag values
            are "baked in" to the instruction names for stackless tag
            instructions; we use hash maps simply because there is more
            information to bake in and this prevents us from having to parse
            the names (which would get messy and also waste time). Because
            the maps make it difficult to read programs, however, a utility
            function called abbreviate-tagged-code-macros is provided to
            produce copies of programs with more human-readable (but not 
            currently executable) representations of tagged-macro calls.
            A tagged-code-macro-erc is provided to generate random tagged-code
            macros in pushgp runs. A new example, codesize20, provides 
            a simple demonstration of the use of tagged-code macros.

One Response to “Tagged-code macros, bug-fixes for examples, and other minor Clojush updates”

  1.   lspector Says:

    Note that a couple of tagged-code macros will behave a little oddly if required non-code arguments aren’t present. The tagged-code macro handler will noop if the tag space doesn’t contain the needed code, but not if other needed arguments aren’t present. That means that the retrievals and tagging will still be executed, even though the embedded call to the code instruction will noop. This will be oddest for code_insert and code_if, I think, and a bit odd also for code_extract, code_nth, and code_nthcdr. All of these will work fine when sufficient arguments are present, and they won’t cause errors or anything else really problematic in any event, but if a required argument isn’t present then some tag retrieval and tagging will still take place (in a repeatable way).

Leave a Reply

You must be logged in to post a comment.