emergent/swarm/evolutionary systems etc

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter MacKenzie

    emergent/swarm/evolutionary systems etc

    Hello, I'm Peter, and I'm very much a newbie.

    New in the sense of being a novice at everything to do with programming,
    rather than just new to Python, so please be very explicit in your replies
    (should you deem me worth of such attention). I've long had a passing
    interest in programming from a macro-conceptual level, but only very
    recently have I tried to learn the details of how to impliment my ideas in
    code. Since I'm so inexperienced and learning soley from on-line
    documentation in my sparse spare time, I'm finding the learning curve rather
    steep, and would appreciate it if you didn't assume that I 'know' anything
    (especially with formating issues).

    What instigated my uptake of programming was a recently sparked, and rapidly
    growing interest in emergent processes, and particularly of computer
    applications for them. I've not covered more than 20 hours of good study on
    the subject (accounting for liberal procrastination ), but I like to jump in
    the deep end with things, and the logic of emergence really 'clicks' with my
    brain. I have, however covered biological evolution in considerably more
    depth, so I'm already quite familiar with the concepts involved.

    What I've been trying to do with Python is to set up something resembling
    John Von Neumann's conception of an imperfectly self-replicating program:

    (3.2.1 Self-Reproduction
    Nearly all of the practical implementations of arti cial worlds to be
    described are related
    in some way to the seminal work of John von Neumann. In the late 1940s and
    early
    1950s, he devoted considerable time to the question of how complicated
    machines could
    evolve from simple machines.9 Speci cally, he wished to develop a formal
    description of
    a system that could support self-reproducing machines which were robust in
    the sense
    that they could withstand some types of mutation and pass these mutations on
    to their
    o spring. Such machines could therefore participate in a process of
    evolution.
    Inspired by Alan Turing's earlier work on universal computing machines
    [Turing 36],
    von Neumann devised an architecture which could ful l these requirements.
    The ma-
    chine he envisaged was composed of three subcomponents [von Neumann 66]:
    1. A general constructive machine, A, which could read a description (X) of
    an-
    other machine, X, and build a copy of X from this description:
    A + (X) ; X (3.1)
    (where + indicates a single machine composed of the components to the left
    and
    right suitably arranged, and ; indicates a process of construction.)
    2. A general copying machine, B, which could copy the instruction tape:
    B + (X) ; (X) (3.2)
    9 Von Neumann had diculties in de ning precisely what the term
    `complicated' meant. He said \I
    am not thinking about how involved the object is, but how involved its
    purposive operations are.
    In this sense, an object is of the highest degree of complexity if it can do
    very dicult and involved
    things." [von Neumann 66].
    3.2. PREVIOUS WORK 47
    3. A control machine, C, which, when combined with A and B, would rst
    activate
    B, then A, then link X to (X) and cut them loose from (A + B + C):
    A + B + C + (X) ; X + (X) (3.3)
    Now, if we choose X to be (A + B + C), then the end result is:
    A + B + C + (A + B + C) ; A + B + C + (A + B + C) (3.4)
    This complete machine plus tape, [A + B + C + (A + B + C)], is therefore
    self-
    reproducing. From the point of view of the evolvability of this
    architecture, the crucial
    feature is that we can add the description of an arbitrary additional
    automaton D to
    the input tape. This gives us:
    A + B + C + (A + B + C + D) ; A + B + C +D + (A + B + C + D) (3.5)
    Furthermore, notice that if the input tape (A + B + C +D) is mutated in
    such a
    way that the description of automaton D is changed, but that of A, B and C
    are
    una ected|that is, the mutated tape is (A + B + C +D0)|then the result of
    the
    construction will be:
    A + B + C+ D + (A + B + C + D) mutation
    ; A + B + C + D0 + (A + B + C+ D0)
    (3.6)
    The reproductive capability of the architecture is therefore robust to some
    mutations
    (speci cally, those mutations which only a ect the description of D), so the
    machines
    are able to evolve. Von Neumann pointed out that it was the action of the
    general copy-
    ing automaton, B, which gave his architecture the capacity for evolving
    machines of
    increased complexity, because B is able to copy the description of any
    machine, no mat-
    ter how complicated [von Neumann 66] (p.121). This ability is clearly
    demonstrated in
    Equation 3.5 above.

    From Artificial Evolution to Artificial Life
    Timothy John Taylor
    Ph.D
    University of Edinburgh
    1999)

    -The formatting on the equations is a bit messed up, but I hope you get the
    idea.

    Although the concept is quite straight forward, and I have my own ideas
    about what specific features I'd like to include, I'm usure as to how to
    implement it at the level of coding. Basically, I wish to create:
    1. An entirely human-designed evolutionary engine.
    2. A file that it '1' will acess, modify, test against a goal to retrive a
    score, then save with the modifications intact and ready for the next run or
    loop-cycle.
    3. A buffer that will store a population of these files.
    4. A death engine that will remove low scoring files (probably as a part of
    '1')

    These concepts aren't new, and are already well publicised. Variants of
    them are used for determining coefficient values for engeneering, medical
    etc research, but I wish to create a program that's more open ended than a
    number-finder. The Neumann model is incomplete, since it not only fails to
    specify a method for mutation beyond the vague decription given, but also
    fails to account for the vanishingly small chance that completely random
    mutation of a program would produce any intelligible results relative to the
    processor's capacity for run cycles (overlooked, perhaps, because of an
    over-riding focus on making the evolutionary engine robust to mutation). To
    solve this, I propose an 'incubator' approach, where the engine would, as
    part of its evolutionary toolkit, and particularly at the beginnng of the
    process before the code becomes complex enough to allow the likelyhood of
    non-fatal mutations, scavange code from external sources.

    Regardless of any issues of copyright etc, this has the advantage of basing
    the now-less random mutations on code that is known to be operable, rather
    than the infinite monkies approach of random alphanumeric generation. To
    incorporate this and other revisions and refinements that I've just spotted,
    the program structure would look like so:

    An entirely human-designed evolutionary engine, which:
    1. Allows the user to set a goal.
    2. Takes random sections of code from a library.
    3. Places them in a text file.
    4. Applies a 'scatter shot' of random alphanumeric changes (with either a
    random or a user specified % of alpahnumerals changed)
    5. Runs the file.
    6. Scores the file on how many valid lines it has, if it fufilled the goal,
    how long it took, etc.
    7. Saves the score to the file (in the title?).
    8. Repeats for a user specified number of times.
    9. Selects the best programs, deletes the rest
    10. Returns to '3' and repeats until stopped.

    At the moment, I'm not even sure if python can create, chop and change
    files, so that the effects of a program being run can persist after it's
    closed down. The library modules are still largely incomprehensibl e to me,
    both in their function and their implementation. I'm a very long way from
    understanding how to apply the randomised aspects of the file changes, or
    much else for that matter, and I can already see a bunch of things that
    would need a lot of tweaking, even if the structure is sound (this is the
    first proper program I've planned, which I'm sure means that the structure
    is almost certaintly gibberish).

    Other things that would be handy:

    A bit to make sensible sections of code less vunerable to mutation, and
    concentrate changes in 'junk' areas.

    Something to decrease or prevent the addition of scavanged code when the
    proportion of scavanged code to random alphanumeric changes and working
    code, or vice versa (with working code forming the fulcrum of the dynamic).

    A 'skills' counter/protector, that would allow files to retain redundant
    code if their goal was changed, rather than necessarily losing it to the
    pressure of clock cycles and the equivalent of genetic drift. (For this,
    the 'bastion' module looks like it might be useful, though I'm not terribly
    sure about how it works, or 'exactly' what it does)

    An random goal changer, to provide an impetus for constant evolution without
    the need for user input. (There's only so good you can be at any one thing)

    An option to give the files an internal copy of the evolution engine, which
    could then be modified by itself as it alters the entire file. (This may
    prove difficult, as although this would allow the files to develop more
    efficient strategies for the process of evolution itself, it would make them
    more vunerable to fatal mutations. A possible solution would be to have a
    'nuclear membrane' - a guard to prevent mutations that are particularly
    likely to be fatal eg. mutations that alter significant chunks of the
    engine. It would also be possible to have multiple engines in each cell,
    which could self-assess and compare scores, replacing engines that
    underperform through damage or 'under-evolution' (radiation resistant
    bacteria use a similar technique)


    =============== ===
    All of this seems like a rather tall order, especially as I'm still
    struggling with some of the things from the beginners guide. Although I
    should probably buy a book and work my way through lots of examples of
    increasing complexity, I like to tackle things head-on and learn as I go.
    Even just writing this message has helped me to clarify to myself what it is
    I want to do.

    If anybody has even bothered to read this far, I'd ask you please to give
    some thought to these ideas (of myself and others), and perhaps to give me
    some pointers in the right direction. Thankyou.


  • Josiah Carlson

    #2
    Re: emergent/swarm/evolutionary systems etc

    [snip long and involved post]

    What you have posted is currently generally known as a "Genetic
    Algorithm". Searching for that term on Google should net you many links.

    In terms of applicability, genetic algorithms are decent at
    approximating solutions to a class of problems known as NP. You can
    search through various resources for more information on NP.

    Now, I say approximate, because if you look at the *space of possible
    solutions*, genetic algorithms will tend to find local optimums. That
    is, the space is huge, and genetic algorithms will find you a set of
    decent solutions. These solutions are rarely, if ever, the true
    optimal, but can, with the right crossover and mutation functions, be
    pretty damn good.

    In terms of using genetic algorithms to write programs, I haven't read
    any papers in the last few years with any positive results in that
    specific field. It is possible (in fact, quite likely) that I am
    missing some sort of paper on the topic, but I wouldn't hold my breath.

    So yeah, search for genetic algorithms and NP for their description, and
    you'll probably find something you like.

    Additionally, you may want to read Stephen Wolfram's "A New Kind of
    Science". It is available on the internet for free.

    - Josiah

    Comment

    • Peter MacKenzie

      #3
      Re: emergent/swarm/evolutionary systems etc

      (Hmm, this might appear as a double posting, but I don't think my last one
      made it through.)

      Thanks, but.

      ("One approach to discussing and comparing AI
      problem solving strategies is to categorize them using the
      terms ''strong'' and ''weak'' methods. Generally, a weak
      method is one which has the property of wide applicability
      but, because it makes few assumptions about the problem
      domain, can suffer from combinatorially explosive
      solution costs when scaling up to larger problems. State
      space search algorithms and random search are familiar
      examples of weak methods."

      Using Genetic Algorithms to Solve NP-Complete Problems
      Kenneth A. De Jong
      George Mason University
      KDEJONG@GMUVAX2 .GMU.EDU <mailto:KDEJONG @GMUVAX2.GMU.ED U>

      William M. Spears
      Navy Center for Applied Research in AI
      Navy Center for Applied Research in AI
      SPEARS@AIC.NRL. NAVY.MIL <mailto:SPEARS@ AIC.NRL.NAVY.MI L>
      <http://hive.cs.uwyo.ed u/~wspears/papers/icga89.pdf>)

      From this, and other reading on genetic algorithms, I've found that nearly
      all of the applications being developed and used are far 'stronger' than
      what I have in mind. Most critically, the great preponderance of uses
      involve a program that simply modulates a set of given variables in search
      for an answer, rather than modifying the source code itself. Understandably,
      this is because, as stated above, such 'weak' methods are of limited use for
      most problems (I wouldn't want to fly in a plane that had been designed by
      one).

      Since, at the moment, I'm more interested in a 'pet cyber slime' than a tool
      for designing efficient circuit layouts, such 'strong' applications are of
      limited use. Even the 'state space' and 'random search' examples above are
      considerably 'stronger' than I would desire to use.
      For me, the goal is not only to create a program that can find an optimal
      solution to a problem, but which can also find better ways of learning -
      something disallowed by a fixed-algorithm engine.

      Your pointer did lead me to consider a couple of aditional factors in my
      design - the incoporation of a 'breeding' mechanism to allow files in a
      population to share information, and a formalised chromosome stucture, to
      increase the probability that mutations will produce sensible effect, and to
      facilitate breeding:

      (The process of species changing over time to become better at survival
      within the environment is called evolution. One advance that it produced was
      a new method of reproduction. Cells began to carry some of their genes in
      rings called plasmids. During meetings between individual they could
      exchange bundles, passing the environmental knowledge embedded within the
      plasmid from individual to individual. Successful plasmids spread amongst
      the population but unsuccessful plasmids encumbered their carrier who would
      die sooner and have less chance to spread the bad genes. Greater benefits
      came when certain genes came together that worked better in combination than
      in isolation. The likelihood of random mutation equipping one cell with both
      genes is low but with the crossover of genes between individuals these
      traits can arise separately and, once they become common in the population,
      join together within one individual.

      Genetic Algorithms
      Nature's Genetics
      Matthew Caryl
      <http://www.permutation city.co.uk/projects/mutants/geneticalgorith ms.html>)

      There's a lot of other interesting stuff on this site, but it'll take a
      while to examine it all, and it'll be quite a while more before I have the
      time to start on Stephen Wolfram's "A New Kind of Science". One question
      though - can I, indeed, create, modify, run and save files using just a
      python script?

      Peter MacKenzie <peter9547@btin ternet.com> wrote in message
      news:c4aeq8$92a $1@hercules.bti nternet.com...[color=blue]
      > Hello, I'm Peter, and I'm very much a newbie.
      >
      > New in the sense of being a novice at everything to do with programming,
      > rather than just new to Python, so please be very explicit in your replies
      > (should you deem me worth of such attention). I've long had a passing
      > interest in programming from a macro-conceptual level, but only very
      > recently have I tried to learn the details of how to impliment my ideas in
      > code. Since I'm so inexperienced and learning soley from on-line
      > documentation in my sparse spare time, I'm finding the learning curve[/color]
      rather[color=blue]
      > steep, and would appreciate it if you didn't assume that I 'know' anything
      > (especially with formating issues).
      >
      > What instigated my uptake of programming was a recently sparked, and[/color]
      rapidly[color=blue]
      > growing interest in emergent processes, and particularly of computer
      > applications for them. I've not covered more than 20 hours of good study[/color]
      on[color=blue]
      > the subject (accounting for liberal procrastination ), but I like to jump[/color]
      in[color=blue]
      > the deep end with things, and the logic of emergence really 'clicks' with[/color]
      my[color=blue]
      > brain. I have, however covered biological evolution in considerably more
      > depth, so I'm already quite familiar with the concepts involved.
      >
      > What I've been trying to do with Python is to set up something resembling
      > John Von Neumann's conception of an imperfectly self-replicating program:
      >
      > (3.2.1 Self-Reproduction
      > Nearly all of the practical implementations of arti cial worlds to be
      > described are related
      > in some way to the seminal work of John von Neumann. In the late 1940s and
      > early
      > 1950s, he devoted considerable time to the question of how complicated
      > machines could
      > evolve from simple machines.9 Speci cally, he wished to develop a formal
      > description of
      > a system that could support self-reproducing machines which were robust in
      > the sense
      > that they could withstand some types of mutation and pass these mutations[/color]
      on[color=blue]
      > to their
      > o spring. Such machines could therefore participate in a process of
      > evolution.
      > Inspired by Alan Turing's earlier work on universal computing machines
      > [Turing 36],
      > von Neumann devised an architecture which could ful l these requirements.
      > The ma-
      > chine he envisaged was composed of three subcomponents [von Neumann 66]:
      > 1. A general constructive machine, A, which could read a description (X)[/color]
      of[color=blue]
      > an-
      > other machine, X, and build a copy of X from this description:
      > A + (X) ; X (3.1)
      > (where + indicates a single machine composed of the components to the left
      > and
      > right suitably arranged, and ; indicates a process of construction.)
      > 2. A general copying machine, B, which could copy the instruction tape:
      > B + (X) ; (X) (3.2)
      > 9 Von Neumann had diculties in de ning precisely what the term
      > `complicated' meant. He said \I
      > am not thinking about how involved the object is, but how involved its
      > purposive operations are.
      > In this sense, an object is of the highest degree of complexity if it can[/color]
      do[color=blue]
      > very dicult and involved
      > things." [von Neumann 66].
      > 3.2. PREVIOUS WORK 47
      > 3. A control machine, C, which, when combined with A and B, would rst
      > activate
      > B, then A, then link X to (X) and cut them loose from (A + B + C):
      > A + B + C + (X) ; X + (X) (3.3)
      > Now, if we choose X to be (A + B + C), then the end result is:
      > A + B + C + (A + B + C) ; A + B + C + (A + B + C) (3.4)
      > This complete machine plus tape, [A + B + C + (A + B + C)], is therefore
      > self-
      > reproducing. From the point of view of the evolvability of this
      > architecture, the crucial
      > feature is that we can add the description of an arbitrary additional
      > automaton D to
      > the input tape. This gives us:
      > A + B + C + (A + B + C + D) ; A + B + C +D + (A + B + C + D) (3.5)
      > Furthermore, notice that if the input tape (A + B + C +D) is mutated in
      > such a
      > way that the description of automaton D is changed, but that of A, B and C
      > are
      > una ected|that is, the mutated tape is (A + B + C +D0)|then the result of
      > the
      > construction will be:
      > A + B + C+ D + (A + B + C + D) mutation
      > ; A + B + C + D0 + (A + B + C+ D0)
      > (3.6)
      > The reproductive capability of the architecture is therefore robust to[/color]
      some[color=blue]
      > mutations
      > (speci cally, those mutations which only a ect the description of D), so[/color]
      the[color=blue]
      > machines
      > are able to evolve. Von Neumann pointed out that it was the action of the
      > general copy-
      > ing automaton, B, which gave his architecture the capacity for evolving
      > machines of
      > increased complexity, because B is able to copy the description of any
      > machine, no mat-
      > ter how complicated [von Neumann 66] (p.121). This ability is clearly
      > demonstrated in
      > Equation 3.5 above.
      >
      > From Artificial Evolution to Artificial Life
      > Timothy John Taylor
      > Ph.D
      > University of Edinburgh
      > 1999)
      >
      > -The formatting on the equations is a bit messed up, but I hope you get[/color]
      the[color=blue]
      > idea.
      >
      > Although the concept is quite straight forward, and I have my own ideas
      > about what specific features I'd like to include, I'm usure as to how to
      > implement it at the level of coding. Basically, I wish to create:
      > 1. An entirely human-designed evolutionary engine.
      > 2. A file that it '1' will acess, modify, test against a goal to retrive[/color]
      a[color=blue]
      > score, then save with the modifications intact and ready for the next run[/color]
      or[color=blue]
      > loop-cycle.
      > 3. A buffer that will store a population of these files.
      > 4. A death engine that will remove low scoring files (probably as a part[/color]
      of[color=blue]
      > '1')
      >
      > These concepts aren't new, and are already well publicised. Variants of
      > them are used for determining coefficient values for engeneering, medical
      > etc research, but I wish to create a program that's more open ended than a
      > number-finder. The Neumann model is incomplete, since it not only fails[/color]
      to[color=blue]
      > specify a method for mutation beyond the vague decription given, but also
      > fails to account for the vanishingly small chance that completely random
      > mutation of a program would produce any intelligible results relative to[/color]
      the[color=blue]
      > processor's capacity for run cycles (overlooked, perhaps, because of an
      > over-riding focus on making the evolutionary engine robust to mutation).[/color]
      To[color=blue]
      > solve this, I propose an 'incubator' approach, where the engine would, as
      > part of its evolutionary toolkit, and particularly at the beginnng of the
      > process before the code becomes complex enough to allow the likelyhood of
      > non-fatal mutations, scavange code from external sources.
      >
      > Regardless of any issues of copyright etc, this has the advantage of[/color]
      basing[color=blue]
      > the now-less random mutations on code that is known to be operable, rather
      > than the infinite monkies approach of random alphanumeric generation. To
      > incorporate this and other revisions and refinements that I've just[/color]
      spotted,[color=blue]
      > the program structure would look like so:
      >
      > An entirely human-designed evolutionary engine, which:
      > 1. Allows the user to set a goal.
      > 2. Takes random sections of code from a library.
      > 3. Places them in a text file.
      > 4. Applies a 'scatter shot' of random alphanumeric changes (with either a
      > random or a user specified % of alpahnumerals changed)
      > 5. Runs the file.
      > 6. Scores the file on how many valid lines it has, if it fufilled the[/color]
      goal,[color=blue]
      > how long it took, etc.
      > 7. Saves the score to the file (in the title?).
      > 8. Repeats for a user specified number of times.
      > 9. Selects the best programs, deletes the rest
      > 10. Returns to '3' and repeats until stopped.
      >
      > At the moment, I'm not even sure if python can create, chop and change
      > files, so that the effects of a program being run can persist after it's
      > closed down. The library modules are still largely incomprehensibl e to[/color]
      me,[color=blue]
      > both in their function and their implementation. I'm a very long way from
      > understanding how to apply the randomised aspects of the file changes, or
      > much else for that matter, and I can already see a bunch of things that
      > would need a lot of tweaking, even if the structure is sound (this is the
      > first proper program I've planned, which I'm sure means that the structure
      > is almost certaintly gibberish).
      >
      > Other things that would be handy:
      >
      > A bit to make sensible sections of code less vunerable to mutation, and
      > concentrate changes in 'junk' areas.
      >
      > Something to decrease or prevent the addition of scavanged code when the
      > proportion of scavanged code to random alphanumeric changes and working
      > code, or vice versa (with working code forming the fulcrum of the[/color]
      dynamic).[color=blue]
      >
      > A 'skills' counter/protector, that would allow files to retain redundant
      > code if their goal was changed, rather than necessarily losing it to the
      > pressure of clock cycles and the equivalent of genetic drift. (For this,
      > the 'bastion' module looks like it might be useful, though I'm not[/color]
      terribly[color=blue]
      > sure about how it works, or 'exactly' what it does)
      >
      > An random goal changer, to provide an impetus for constant evolution[/color]
      without[color=blue]
      > the need for user input. (There's only so good you can be at any one[/color]
      thing)[color=blue]
      >
      > An option to give the files an internal copy of the evolution engine,[/color]
      which[color=blue]
      > could then be modified by itself as it alters the entire file. (This may
      > prove difficult, as although this would allow the files to develop more
      > efficient strategies for the process of evolution itself, it would make[/color]
      them[color=blue]
      > more vunerable to fatal mutations. A possible solution would be to have a
      > 'nuclear membrane' - a guard to prevent mutations that are particularly
      > likely to be fatal eg. mutations that alter significant chunks of the
      > engine. It would also be possible to have multiple engines in each cell,
      > which could self-assess and compare scores, replacing engines that
      > underperform through damage or 'under-evolution' (radiation resistant
      > bacteria use a similar technique)
      >
      >
      > =============== ===
      > All of this seems like a rather tall order, especially as I'm still
      > struggling with some of the things from the beginners guide. Although I
      > should probably buy a book and work my way through lots of examples of
      > increasing complexity, I like to tackle things head-on and learn as I go.
      > Even just writing this message has helped me to clarify to myself what it[/color]
      is[color=blue]
      > I want to do.
      >
      > If anybody has even bothered to read this far, I'd ask you please to give
      > some thought to these ideas (of myself and others), and perhaps to give me
      > some pointers in the right direction. Thankyou.
      >
      >[/color]


      Comment

      • Eddie Corns

        #4
        Re: emergent/swarm/evolutionary systems etc

        "Peter MacKenzie" <peter9547@btin ternet.com> writes:
        [color=blue]
        >(Hmm, this might appear as a double posting, but I don't think my last one
        >made it through.)[/color]
        [color=blue]
        >Thanks, but.[/color]
        [color=blue]
        >("One approach to discussing and comparing AI
        >problem solving strategies is to categorize them using the
        >terms ''strong'' and ''weak'' methods. Generally, a weak
        >method is one which has the property of wide applicability
        >but, because it makes few assumptions about the problem
        >domain, can suffer from combinatorially explosive
        >solution costs when scaling up to larger problems. State
        >space search algorithms and random search are familiar
        >examples of weak methods."[/color]

        I think 'genetic programming' as opposed to GA may be more in your line. GP
        manipulates code directly with the usual crossovers, mutation etc. It's
        usually done in Lisp/Scheme since just about any mutation is always, at least,
        syntactically valid. The term 'evolutionary computing' is something of a
        blanket term for these types of systems. I don't have any good references,
        it's something I want to pursue myself at some point.

        Eddie

        Comment

        • Josiah Carlson

          #5
          Re: emergent/swarm/evolutionary systems etc

          [color=blue]
          > From this, and other reading on genetic algorithms, I've found that nearly
          > all of the applications being developed and used are far 'stronger' than
          > what I have in mind. Most critically, the great preponderance of uses
          > involve a program that simply modulates a set of given variables in search
          > for an answer, rather than modifying the source code itself. Understandably,
          > this is because, as stated above, such 'weak' methods are of limited use for
          > most problems (I wouldn't want to fly in a plane that had been designed by
          > one).[/color]
          [color=blue]
          > Since, at the moment, I'm more interested in a 'pet cyber slime' than a tool
          > for designing efficient circuit layouts, such 'strong' applications are of
          > limited use. Even the 'state space' and 'random search' examples above are
          > considerably 'stronger' than I would desire to use.
          > For me, the goal is not only to create a program that can find an optimal
          > solution to a problem, but which can also find better ways of learning -
          > something disallowed by a fixed-algorithm engine.[/color]

          Take this with a grain of salt, but generally, expecting computers to
          learn is a high expectation. From neural networks (aka connectionist
          networks), genetic algorithms, naive bayesian statistics, etc., the
          desire in all of these cases is for a system that responds to a certain
          environment, produces some reasonable solutions in this environment, and
          works reasonably well in other environments.

          The one limitation of all these approaches is that the algorithms and
          methods for doing this have limited knowledge (usually a few hundred
          bytes of state), no higher-order insight, etc. The algorithms, when
          given proper input and design, can solve certain problems. You may get
          lucky and your algorithm/data is applicable to another problem, but
          those situations are the rare exception, rather than the rule.

          These 'learning' methods do the best when applied to what you have shown
          is called 'strong' problems. The 'weak' problems I've seen worked on,
          generally had weak (read poor) results. The stronger your problem, the
          better results you will likely have.

          [color=blue]
          > There's a lot of other interesting stuff on this site, but it'll take a
          > while to examine it all, and it'll be quite a while more before I have the
          > time to start on Stephen Wolfram's "A New Kind of Science". One question
          > though - can I, indeed, create, modify, run and save files using just a
          > python script?[/color]

          Don't think of Python as a scripting language. It can be used that way,
          but Python has better built-in data structures and language features
          than the most used languages out there (C, C++ and Java).

          Can you create a file? Certainly, open a file for writing that didn't
          previously exist...
          file_for_writin g = open('filename' , 'wb')

          Can you modify a file? Certainly, open a file for reading and updating
          that exists...
          file_for_updati ng_in_place = open('filename' , 'r+b')

          Want to run a file? (be careful though, executing the contents of a
          file can be dangerous)...
          fil = open('filename' , 'rb')
          contents = fil.read()
          fil.close()
          exec(contents)

          Want to save a file?
          fil = open('filename' , 'wb')
          fil.write("some string of what you want to write")
          fil.close()


          - Josiah

          Comment

          • Peter MacKenzie

            #6
            Re: emergent/swarm/evolutionary systems etc

            Sorry for the long response time. I've been busy, and my brain has been
            clogged up with a cold and hayfever.

            Although I'm sure your instructions on creating files etc are perfectly
            valid, I lack the basic grammatical knowledge to make use of them (I really
            am very new to programing). I'll have to wait for my skills to catch up
            with my ideas before I can move on, but that must wait until July, as I have
            impending exams that demand much of my focus.

            In addition to exams, I also must start a dissertation in July for my
            geography hon B.Sc. Although I should ideally have found a subject two
            months ago, I've so far lacked any truly appealing project ideas (much to
            the consternation of my advisor). Since reading 'Emergence', by Steven
            Johnson, and conducting prelimenary research on the matter, I've settled on
            the dissertation title: "Emergence theory as an approach to city design".

            To this goal, I'd like to use computer modeling to simulate ways in which
            the spatial distribution of indicator phenomena in cities (land price/use,
            crime, demographic composition etc) is affected by bottom-up, local area
            rules. Given that I have only a basic foothold on the language, does
            anybody foresee difficulties for me learning enough to impliment simple and
            experimentally flexible sim-city style simulations (minus fancy graphics and
            llamas) in no more than 2 months (to allow for time to conduct actual
            experiments + field observations etc)? I would be able to engender aid from
            various staff, and the university library should carry titles on the
            subject. Failing that, I could do it the old fashioned way and buy a how-to
            book, but I'd like some opinions on the difficulty of the goal from people
            who've already trancended the non-programmer/programmer barrier.


            Comment

            • Josiah Carlson

              #7
              Re: emergent/swarm/evolutionary systems etc

              > rules. Given that I have only a basic foothold on the language, does[color=blue]
              > anybody foresee difficulties for me learning enough to impliment simple and
              > experimentally flexible sim-city style simulations (minus fancy graphics and
              > llamas) in no more than 2 months (to allow for time to conduct actual
              > experiments + field observations etc)? I would be able to engender aid from
              > various staff, and the university library should carry titles on the
              > subject. Failing that, I could do it the old fashioned way and buy a how-to
              > book, but I'd like some opinions on the difficulty of the goal from people
              > who've already trancended the non-programmer/programmer barrier.[/color]


              Two months is a pretty tight schedule. If you're on your toes, I would
              bet you could learn enough of the langauge to support your ideas in 2
              months. Actually programming the thing in 2 months; I wouldn't be able
              to make that kind of judgement about your abilities.

              I wish you luck.
              - Josiah

              Comment

              • Peter MacKenzie

                #8
                Re: emergent/swarm/evolutionary systems etc

                I'll take that to mean that my chances are slim. Although this probability
                is mediated my lack of a social life, I've conceived of a contingency
                wherein a standard spreadsheet application could be used to facilitate at
                least some limited degree of modelling. Given your recommendation, I'll
                ensure the feasibility of this option before I commit to the primary
                methodology, thereby ensuring that a disappointing rate of progress doesn't
                prove fatal for my dissertation.

                Fortunately, I've found an online textbook at
                http://www.ibiblio.org/obp/thinkCSpy/index.htm, which appears better suited
                to my needs than the standard python documentation, and may alleviate some
                of the conceptual and syntactical difficulties I've been experiencing.

                I expect I may be back here for additional aid in the near-future.


                Comment

                • Peter MacKenzie

                  #9
                  Re: emergent/swarm/evolutionary systems etc

                  And how near that future was! I've been going over the open/read/edit file
                  stuff again, trying to make it work, but I'm still having no success. I'm
                  not sure if I'm missing something fundamental (like a frontal lobe), or if
                  there's some less worrying problem afoot, but this is what I've been trying.
                  I've put it through many iterations, dropping and adding brackets and
                  full-stops, playing around with the structure and grammar etc, but nothing
                  seems to work.

                  import sys

                  file = 'myfile.txt'
                  open(file,'r+b' )
                  file.write("som e string of what you want to write")
                  file.close()

                  When I run this, it returns the message:

                  Traceback (most recent call last):
                  File "C:\Python23\op enfile.py", line 5, in ?
                  file.write()("s ome string of what you want to write")
                  AttributeError: 'str' object has no attribute 'write'

                  It must be something really simple that I've overlooked or failed to grasp,
                  but I've exhausted my willingness to continue experimenting and attempting
                  to reverse engineer code from the library modules. Please help. My brain
                  hurts.


                  Comment

                  • Peter Hansen

                    #10
                    Re: emergent/swarm/evolutionary systems etc

                    Peter MacKenzie wrote:
                    [color=blue]
                    > import sys[/color]

                    This part is useless for the four lines that follow, but
                    of course you'll need it if you ever want to access anything
                    that really is in the sys module...
                    [color=blue]
                    > file = 'myfile.txt'[/color]

                    Here the name "file" is bound to a string.
                    [color=blue]
                    > open(file,'r+b' )[/color]

                    Here you call a builtin and pass it two strings. Functions
                    can "never" modify what the arguments are bound to, so this
                    cannot modify the name "file" to something else. Clearly not
                    what you intended. Note that open() really *returns* the newly
                    created file object, so you should be assigning the result as:

                    file = open(filename, 'r+b')

                    Of course, now you need a "filename" name, which is what the
                    first line should be doing:

                    filename = 'myfile.txt' # instead of "file = ..."
                    [color=blue]
                    > file.write("som e string of what you want to write")
                    > file.close()[/color]

                    These two will now work.

                    Why don't you run through the Python tutorial first, since these
                    are pretty basic questions, some of which will be resolved if you
                    go the defined routes first.

                    There are also other good Python/newbie resources linked to from
                    the web site if you go there and poke around.

                    -Peter

                    Comment

                    • Mickel Grönroos

                      #11
                      Re: emergent/swarm/evolutionary systems etc

                      On Fri, 2 Apr 2004, Peter MacKenzie wrote:
                      [color=blue]
                      > import sys[/color]

                      You don't need the sys module for file I/O.
                      [color=blue]
                      > file = 'myfile.txt'
                      > open(file,'r+b' )
                      > file.write("som e string of what you want to write")
                      > file.close()[/color]

                      "file" is a str object containing the string "myfile.txt ". What you need
                      to do is catch the return value (a file object) of the open() function and
                      use that for writing:

                      file = "myfile.txt "
                      fh = open(file, "r+") ## Do you need "b" (binary) for a text file?
                      fh.write("somet hing")
                      fh.close()

                      Cheers,

                      /Mickel

                      --
                      Mickel Grönroos, application specialist, linguistics, Research support,CSC
                      PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
                      CSC is the Finnish IT center for science, www.csc.fi

                      Comment

                      • Dang Griffith

                        #12
                        Re: emergent/swarm/evolutionary systems etc

                        On Fri, 2 Apr 2004 10:16:19 +0000 (UTC), "Peter MacKenzie"
                        <peter9547@btin ternet.com> wrote:
                        [color=blue]
                        >I'll take that to mean that my chances are slim. Although this probability
                        >is mediated my lack of a social life, I've conceived of a contingency
                        >wherein a standard spreadsheet application could be used to facilitate at
                        >least some limited degree of modelling. Given your recommendation, I'll
                        >ensure the feasibility of this option before I commit to the primary
                        >methodology, thereby ensuring that a disappointing rate of progress doesn't
                        >prove fatal for my dissertation.
                        >
                        >Fortunately, I've found an online textbook at
                        >http://www.ibiblio.org/obp/thinkCSpy/index.htm, which appears better suited
                        >to my needs than the standard python documentation, and may alleviate some
                        >of the conceptual and syntactical difficulties I've been experiencing.
                        >
                        >I expect I may be back here for additional aid in the near-future.
                        >[/color]
                        The spreadsheet approach may be a suitable alternative, indeed.
                        In the past, I've taught some friends with an accounting background
                        a little about programming, using spreadsheet formulae as examples.

                        Actually, spreadsheets might even have an advantage in your case,
                        because the calculations are performed simultaneously, for all intents
                        and purposes. You don't need to control the "flow". This is a common
                        characteristic of "simulation languages", also. In them, you set up
                        your equations, relationships, dependencies, etc, provide initial
                        conditions, and let them run. There is very little of the linear
                        sequencing of steps that occurs in most popular languages (python,
                        C(etc), lisp/scheme, pascal).

                        To simulate "generation s", you will probably need to write a macro
                        that copies one generation to the next (column, or separate sheet).
                        This is ironic, given that the Von Neumann paper that started your
                        interest in the subject is about copying a machine/program.

                        Best of luck,
                        --dang

                        Comment

                        • Peter MacKenzie

                          #13
                          Re: emergent/swarm/evolutionary systems etc

                          Peter Hansen + Mickel Grönroos, (unsure of a more suitable intro protocol
                          for this environment + situation)

                          Oh the joy! It makes life worth living when things click into place and
                          make sense. My style of learning seems ill suited to the material available
                          on the subject, so although I had indeed read all that I could find on
                          making files, it was presented in a manner that I couldn't quite comprehend.
                          To elaborate, I process linguistic information in a holistic, intuitive
                          manner; a quality that requires for me to develop a 'feel' for the language
                          in question, rather than a literal understanding of the rules.

                          Because of this, I need full-yet-simple working examples to deconstruct and
                          process. Most of the examples I've come across have been fragmented and
                          incomplete, which leaves me grasping at loose ends and the countless
                          possibilities therein. It's as though somebody had handed me at birth a
                          dictionary and a set of grammatical rules, with the expectation that I would
                          be able to piece it all together and learn to communicate.

                          Conversely, my search for the working examples I craved only turned up
                          applications of the process that were too bound up in more complex matters
                          to be decipherable, the analogy this time being that of getting handed a
                          copy of 'Moby Dick' from which to start my education.

                          Being presented with an isolated, sterilised 'specimen' has helped me to
                          form a better understanding of the language, being of the right mix of
                          information bandwidth vs. complexity to allow me to capture the 'flavour' in
                          the code.

                          If there are any teachers reading this, I hope it might engender you to
                          consider the varying needs of students in your classes. By being an outlier
                          on the mental demographic, I've long suffered from problems arising from my
                          minority neurology. The cause, however, has generally been from
                          communicative frictions, rather than from the relative merits and demerits
                          of that mental architecture.

                          Thank you both for your help (spreadsheets in the next message).


                          Comment

                          • Leif B. Kristensen

                            #14
                            Re: emergent/swarm/evolutionary systems etc

                            Peter MacKenzie wrote:
                            [color=blue]
                            > Oh the joy! It makes life worth living when things click into place
                            > and make sense.[/color]

                            I know the feeling. For me too, the best way to learn a new language is
                            to wallow in working examples. I still remember the thrill of hacking
                            my way through Tom Swan's "Mastering Turbo Pascal" in the late
                            eighties, where he presented every wrinkle of the language, and every
                            single library function with both a working example program and a lucid
                            discussion. I've never learnt any other computer language so
                            thoroughly.

                            regards,
                            --
                            Leif Biberg Kristensen

                            Validare necesse est

                            Comment

                            • Peter Hansen

                              #15
                              Re: emergent/swarm/evolutionary systems etc

                              Peter MacKenzie wrote:
                              [color=blue]
                              > Peter Hansen + Mickel Grönroos, (unsure of a more suitable intro protocol
                              > for this environment + situation)
                              >
                              > Oh the joy! It makes life worth living when things click into place and
                              > make sense. My style of learning seems ill suited to the material available
                              > on the subject, so although I had indeed read all that I could find on
                              > making files, it was presented in a manner that I couldn't quite comprehend.
                              > To elaborate, I process linguistic information in a holistic, intuitive
                              > manner; a quality that requires for me to develop a 'feel' for the language
                              > in question, rather than a literal understanding of the rules.
                              >
                              > Because of this, I need full-yet-simple working examples to deconstruct and
                              > process. Most of the examples I've come across have been fragmented and
                              > incomplete, which leaves me grasping at loose ends and the countless
                              > possibilities therein. It's as though somebody had handed me at birth a
                              > dictionary and a set of grammatical rules, with the expectation that I would
                              > be able to piece it all together and learn to communicate.[/color]

                              Sounds like you should check out www.diveintopython.org, which as I
                              recall has quite full examples. If you haven't read it already do so.

                              The only other thing I can suggest is spend less time defending your
                              way of learning things :-) and more time just *doing* it. Write code,
                              and when it doesn't work at first, experiment. Python should be
                              learned with the interactive interpreter prompt right in front of
                              you, typing and watching and learning...

                              Anyway, keep at it. Python is certainly one of the easiest if not
                              the easiest modern language to learn (IMHO) so you should find yourself
                              making relatively good progress, whatever your difficulties.

                              -Peter

                              Comment

                              Working...