johnmee / nigel Goto Github PK
View Code? Open in Web Editor NEWAn adventure into "Genetic Programming" for Nigel O'Neill. Building a program that randomly 'evolves' code to solve a problem.
An adventure into "Genetic Programming" for Nigel O'Neill. Building a program that randomly 'evolves' code to solve a problem.
Suitable for using the normalised probabilistic selection routine created in #2 create a crossover (mate) routine which, given two candidates (contributing and receiving parents)
if there are no common node-types then it raises an error so the calling algorithm can decide what to do.
Via GP. Should be able to just copy/paste from deap example and build a notebook around it. Execute.
https://deap.readthedocs.org/en/master/examples/gp_parity.html
Firstly, let's define what we mean by program 'architecture'.
According to Koza (GP2 pp525) the architecture of an individual program in the population is defined by:
a) the number of function-defining branches,
b) the number of arguments possessed by each function-defining branch, and
c) if there is more than one function-defining branch, the nature of the hierarchical references (if any) allowed between the function-defining branches
Secondly, we need to step through the following process each time we create an individual:
then push changes to https://johnmee.com:8889/notebooks/DynamicADFFiveParity.ipynb
IndexError Traceback (most recent call last)
<ipython-input-6-a45f87ec14a5> in <module>()
7 types2 = set([node.ret for node in contributor[1:]])
8 common_types = types1.intersection(types2)
----> 9 graft_type = random.choice(list(common_types))
10
11 print("Receiver Types: ", types1)
/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/random.py in choice(self, seq)
253 i = self._randbelow(len(seq))
254 except ValueError:
--> 255 raise IndexError('Cannot choose from an empty sequence')
256 return seq[i]
257
IndexError: Cannot choose from an empty sequence
Apply to solving the Pythagoras problem
I'm not sure how many or what, but keep it simple and implement an ADF and see it get used in a solution.
Firstly, Koza states that point typing is used when the architecture of the individuals is evolutionarily selected (GP2, pp532).
For the Crossover routine/method to be compatible with various program architectures it will work best if each reproductive operation between two parents results in only 1 offspring being generated. Unlike the double-crossover which is possible when the architectures of each program in a population is homogenous and each crossover operation can produce 2 offspring, it works best if we only produce 1 offspring each time 2 parents mate due to the non-homogenous architecture of the population. This is because there are a number of compatibility checks which need to be done (aside from the type matching which always is required) making a successful swap very rare. This is because for both crossover fragments to be mutually compatible with their respective receivers both syntactically and and semantically is unlikely. This would result in a great deal of failed attempts and wasted computer resources. Hence, when programs contain ADF's with automatically defined architectures, we define parents as either a contributing parent, or a receiving parent, and the crossover is only done in one direction, from contributor to receiver.
Naturally, the contributing parent will contribute a randomly chosen program fragment for insertion into a randomly chosen point in the receiving parent, if (and only if) the below list of checks do not identify any incompatibility.
Before detailing the checks explicitly, they can broadly be described as falling into 3 areas.
• Firstly, every terminal and function contained in the crossover fragment must be in the terminal set or function set of the branch of the receiving parent. (This includes actual variables, dummy variables (e.g. ARG0, ARG1...), random constants, primitive functions, automatically defined functions)
• Secondly, The number of arguments of every function contained in the crossover fragment must equal the number of arguments for that function in the branch of the receiving parent to which it is being inserted.
• Thirdly, all other syntactic rules of construction must be satisfied, (including the type of the crossover fragment and the insertion point being a match)
Koza (GP2, pp533) explicitly states these 7 conditions of point-typing as:
(1) All the actual variables of the problem, if any; actually appearing in the
crossover fragment from the contributing parent must be in the terminal set of the branch of the receiving parent containing the point of insertion.
(2) All the dummy variables (e.g. ARG0, ARG1, etc.) if any actually appearing in the crossover fragment from the contributing parent must be in the terminal set of the branch of the receiving parent containing the point of insertion.
(3) All the automatically defined functions, if any actually appearing in the crossover fragment from the contributing parent must be in the function set of the branch of the receiving parent containing the point of insertion.
(4) All the automatically defined functions, if any actually appearing in the crossover fragment from the contributing parent must have exactly the number of arguments specified for that automatically defined function for the branch of the receiving parent containing the point of insertion.
(5) All functions (other than automatically defined functions) must also satisfy conditions (3) and (4).
(6) All terminals (other than dummy variables and actual variables of the problem already mentioned in conditions (1) and (2), if any actually appearing in the crossover fragment from the contributing parent must be in the terminal set of the branch of the receiving parent containing the point of insertion.
(7) All other syntactic rules of construction of the problem must be satisfied (including the type of the crossover fragment and the insertion point being a match).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.