473,569 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 18 '05 #1
34 2164
[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
Jul 18 '05 #2
(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
KD*****@GMUVAX2 .GMU.EDU <mailto:KD***** @GMUVAX2.GMU.ED U>

William M. Spears
Navy Center for Applied Research in AI
Navy Center for Applied Research in AI
SP****@AIC.NRL. NAVY.MIL <mailto:SP****@ 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 <pe*******@btin ternet.com> wrote in message
news:c4******** **@hercules.bti nternet.com...
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.

Jul 18 '05 #3
"Peter MacKenzie" <pe*******@btin ternet.com> writes:
(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."


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
Jul 18 '05 #4
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.
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.

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?


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
Jul 18 '05 #5
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.
Jul 18 '05 #6
> 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.

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
Jul 18 '05 #7
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.
Jul 18 '05 #8
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.
Jul 18 '05 #9
Peter MacKenzie wrote:
import sys
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...
file = 'myfile.txt'
Here the name "file" is bound to a string.
open(file,'r+b' )
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 = ..."
file.write("som e string of what you want to write")
file.close()


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
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2340
by: A Waterfall That Barks | last post by:
http://www.c-sharpcorner.com//Code/2003/March/SwarmSim.asp I just found this port of the swarm groups famous 'complexity from simple interacting agents' type software. Very easy to load and run in Studio. I'm going to try a mono build when I get home...don't know about how to translate the GDI though.
2
2847
by: Scott Robert Ladd | last post by:
I've just posted my analysis of GNU C and C++ optimizations, using a genetic algorithm to discover the most effective optimization flags for different algorithms. ACOVEA (Analysis of Compiler Options via Evolutionary Algorithm) implements a genetic algorithm to find the "best" options for compiling programs with the GNU Compiler Collection...
0
1161
by: louis | last post by:
For those in the DFW area, there's an IT open house at Perot Systems. (In my group, we're looking to hire one senior sql server DBA. Go to the perot systems web site to apply). ------------------------------------------------------------ You're Invited to Perot Systems IT Career Open House - July 14, 2005 To meet our growth needs,...
0
1416
by: avinash | last post by:
EIGHTEENTH INTERNATIONAL CONFERENCE ON SYSTEMS ENGINEERING (ICSEng05) LAS VEGAS, USA, AUGUST 16-18, 2005 (http://www.icseng.info) This series of International Conferences is jointly organized on a rotational basis among three institutions, University of Nevada, Las Vegas, USA, Technical University of Wroclaw, Poland, and Coventry...
0
1783
by: Emine Ekin | last post by:
/*Apologize for multiple posts*/ FIRST CALL FOR PAPERS ADVIS 2006 Fourth Biennial International Conference on Advances in Information Systems 18-20 October, 2006 Izmir, Turkey
0
2473
by: Bill Law | last post by:
Great Company on the Maryland Eastern Shore needs a DB2 Systems Programmer and DBA (DB2) to join their IT team. The selected candidate MUST have a BS degree and both DB2 DBA And DB2 Systems Programming experience. The salary range for this position is 80-85K range..tops.
3
2468
by: user | last post by:
Hi all, At the outset, I regret having to post this slightly OT post here. However, I strongly feel that people in this group would be the best to advise me on my predicament. I am working as a QA in an MNC in India, since I graduated in September 2003. I am working in a QA role which requires me to do some Winrunner automation, and...
54
5767
by: Matt | last post by:
How do we define systems programs? when we say systems programming, does it necessary mean that the programs we write need to interact with hardware directly? For example, OS, compiler, kernel, drivers, network protocols, etc...? Couple years ago, yes, I understand this is definitely true. However, as the software applications become more and...
3
6669
by: Ty Oft | last post by:
Hello Bytes! Maybe my question seems a bit silly (as one could simply answer it "Well, what are you more passionate about?" or stuff like that - please don't answer like this), but I am in a bit of a dilemma and time is short at the moment and I need to make a decision before it's too late. I have just begun my second year in a UK uni for a...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.