Angel \”Java\” Lopez on Blog

July 11, 2017

New Month’s Resolutions: July 2017

We are in the second part of the year, a long year with interesting projects. Time to write the new month’s resolutions and review the past ones:

– Continue RskSharp [pending]
– Continue SimpleBlockchain [pending]
– Continue BlockchainSharp [complete] see repo
– Continue ChineseP [complete] see repo
– Continue TensorSharp [pending]
– Continue RSharp [complete] see repo
– Experiments with RSKJ fork [complete] see repo
– Continue Vyu [pending]
– Continue Domie [complete] see repo
– Continue Wordie [pending]

Also, I was working on:

– Start WikiExpert [complete] see repo
– Start PerProm [complete] see repo
– Start RskApi [complete] see repo
– Improve SharpGo [complete] see repo
– Improve Neurum [complete] see repo
– Improve ClojJS [complete] see repo
– Improve SimpleScraper [complete] see repo
– New Sample in SimpleGA [complete] see repo
– Start GenPrj [complete] see repo
– Start RskUtils [complete] see repo
– Start SimpleJsonRpc [complete] see repo
– Start HuskyJS [complete] see repo
– Improve Husky [complete] see repo

My new month’s resolutions:

– Continue RskSharp
– Continue SimpleBlockchain
– Continue BlockchainSharp
– Continue ChineseP
– Continue TensorSharp
– Continue RSharp
– Continue WikiExpert
– Continue SimpleGA
– Continue Neurum
– Continue HuskyJS

Stay tuned!

Angel “Java” Lopez*





June 24, 2015

Genetic Algorithms: Links And Resources (4)

Filed under: Artificial Intelligence, Genetic Algorithm, Links — ajlopez @ 11:14 am

Previous Post

Genetic algoritms applied to machine learning

Announcing gerl: Genetic Programming in Erlang

Parallel genetic algorithm in Erlang

A genetic algorithm example in Erlang. | Dream Child

IEEE Xplore Abstract – Machine learning using a genetic algorithm to optimise a draughts program board evaluation function


Encog Machine Learning Framework | Heaton Research

AI Programming: Noob to Pro | Game Jolt

(1) Life as evolving software | Gregory Chaitin –

aforge – AForge.NET Framework – Google Project Hosting

IEEE Xplore – Using genetic algorithms to solve the South African school timetabling problem

Pragmatic Genetic Programming | Engineering Useful Surprises

My Links

Stay tuned!

Angel “Java” Lopez

June 18, 2015

Genetic Algorithms: Links And Resources (3)

Filed under: Genetic Algorithm, Links — ajlopez @ 10:13 am

Previous Post
Next Post

Machine Learning: Genetic Algorithms in Javascript Part 2

Machine Learning: Genetic Algorithms Part 1 (Javascript)

Exact and Asymptotically Exact Solutions for a Class of Assortment Problems

Genetic Algorithm for Dynamic Path Planning

A Mobile Robot Path Planning Using Genetic Algorithm in Static Environment

Evolutionary systems and artificial life

Evolution computations on C#

Sketch of an “artificial scientist” project

dolphin278 / genetic
Implementation of genetic algorithms for nodejs

Genetic and Evolutionary Computation: Medical Applications

The AI Revolution Is On

Genetic Algorithm For Hello World

Next generation of algorithms inspired by problem-solving ants

Introduction to Genetic Algorithms


Human-based computation

Curve fitting with Pyevolve

Pragmatic Genetic Programming

My Links

Stay tuned!

Angel “Java” Lopez

November 8, 2012

Genetic Algorithms: Links And Resources (2)

Filed under: Genetic Algorithm, Links — ajlopez @ 12:44 pm

Previous Post
Next Post

Past week, I presented my distributed genetic algorithm example (Browser, JavaScript, Node.js, Socket.IO, TCP+JSON) at @udadev (see page). Now, more links about this topic:

Gene Expression Programming: Mathematical Modeling by an Artificial Intelligence

New operator for the Traveling Salesman Problem

A Genetic Algorithm in T-SQL

Genetic Programming: Mona Lisa Source Code and Binaries

orienteering problem
how to use generic algorithm to solve Automatic Route Generation

yogthos / Clojure-Genetic-Algorithm-Example

lancecarlson / eugene
Evolve your programs! Eugenics applied to software

Breaking Transposition Cipher with Genetic Algorithm

Genetic Programming and a LLVM JIT for restricted Python AST expressions

A Simple C# Genetic Algorithm

Pyevolve was developed to be a complete genetic algorithm framework written in pure python.


Genetic Algorithms in Plain English

A 2D Packing Problem

Genetic Algorithms: Cool Name & Damn Simple

Genetic Programming: A Novel Failure

Genetic algorithms, Mona Lisa and JavaScript + Canvas

The Future of Game AI: Learning to Use Human Tactics

Gambit Game Lab

My Links

Keep tuned!

Angel “Java” Lopez

September 22, 2012

SimpleGA (1) Genetic Algorithms in Javascript/Node.js

Filed under: Algorithms, Genetic Algorithm, JavaScript, NodeJs, Open Source Projects — ajlopez @ 7:24 pm

Two week ago, I was writing:

a Simple Genetic Algorithm base framework, that supports population, evaluation and mutator operators (I should add crossover operators). The base algorithm is based on

A Genetic Algorithm Tutorial (pdf)

You can create a population of genotypes, each one with an evaluation function. The library evaluates each genotypes and prepares another population, based on the value of each genotype, copying the best ones, and mutating some of the initial specimen based on fitness. The fitness value is v = fi / fa, where fi is the individual fitness evaluation, and fa is the fitness average. The integer part of v determines the count of copies of an individual that survives to the next generation. The fraction part is the probability of having a mutated copy in the next generation set of genotypes:

var newpopulation = [];

for (var k = 0; k < l; k++) {
	if (values[k] < 0)
	var fitness = values[k] / total;
	if (fitness < 0)
	var ntimes = Math.floor(fitness);
	var fraction = fitness - ntimes;
	for (var j = 0; j < ntimes; j++)
	if (fraction > 0 && Math.random() <= fraction)

if (mutators && mutators.length > 0) {
	l = newpopulation.length;
	var lm = mutators.length;
	for (k = 0; k < l; k++) {
		var mutator = mutators[Math.floor(Math.random() * lm)];
		newpopulation[k] = mutator.mutate(newpopulation[k]);

(I should add crossover operator support). There is a sample implementing the Travelling Saleman Problem

running in console using

It can run from the console, or you can launch a local web page:

I wrote client/server version (web page at browser, Node.js server program) and a distributed version (the evaluation of many population running in many server nodes, coordinated by a Node.js server, showing results in a browser).

Next steps: add crossover operators, sample short descriptions, more samples.

Keep tuned!

Angel “Java” Lopez

September 21, 2012

Genetic Algorithms: Links and resources (1)

Filed under: Genetic Algorithm, Links — ajlopez @ 2:22 pm

These days, I wrote a simple genetic algorithm in Javascript, runing at browser, and at server (Node.js), even with distributed load (see I should write a post about that code (my previous posts with experiments in C#), but first, I want to share some of my genetic algorithm links:

In the computer science field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the process of natural evolution. This heuristic is routinely used to generate useful solutions to optimization and search problems. Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to optimization problems using techniques inspired by natural evolution, such as inheritance, mutation, selection, and crossover.

Robocode with JGAP

Andy’s Genetic Programming- GPQuick and Doodle Garde

Genetic Algorithms: Cool Name & Damn Simple

Local Optimization Software

E-Book "Global Optimization Algorithms — Theory and Application"
This book elaborates on many of the basic principles in global optimization, Evolutionary Algorithms, and Genetic Programming.

Evolvable Hardware

Genetic A/B Testing with JavaScript

Introduction to Genetic Algorithms
Genetic Programming: Evolution of Mona Lisa

Time for Genetic Programming?

Help! My Product Development is Going TOO FAST
Use evolution: We can build a machine that evolves the product by user-testing variations.

Discipulus 5 Genetic Programming Predictive Modelling
Genetic Algorithm Library


Genetic Algorithms

An Introduction to Genetic Algorithms In Java

Survival of the Fittest: Natural Selection with Windows Forms
What is Genetic Programming?

Genetic Algorithms

Global Optimization Toolbox

Travelling salesman problem
A C++ Library of Genetic Algorithm Components

My Links

Keep tuned!

Angel “Java” Lopez

February 7, 2010

Genetic Algorithms using GoRoutines and Channels in C#

Filed under: .NET, C Sharp, Genetic Algorithm — ajlopez @ 10:39 am

More than a year ago, I wrote:

Genetic Algorithms with AjAgents and Concurrency and Coordination Runtime (CCR)

exploring concurrency in the implementation of Travelling Salesman Problem using a genetic algorithm. At the end of past year, I wrote an example, using the ideas implemented in:

GoRoutines and Channels in C#

The code is in the AjConcurr.Tsp project at:

This is the result (not a great interface… ;-):

TSP is not a good problem to resolve using Genetic Algorithm: the result depends of the improvement of population after each iteration. My implementation uses a mutation algorithm that tries to generate better individuals (a fair algorithm should only mutate). The code is written in a big method, under the Run button click, only for demo purpose.

At the beginning, I define the channels:

            Channel genomas = new Channel();
            Channel evaluated = new Channel();
            Channel bestsofar = new Channel();
            Channel mutator = new Channel();

Remember: you can put a value (object) in a channel, and in another thread, you can get that value. If you put a value in a channel, and no thread is reading the channel, your thread is blocked. If you read a value from a channel, and no value is present, your thread is blocked. In this way, producers and consumers are synchronized.

Evaluated channel receives individuals (solutions to the problem) and collects it, forming a new population. The best individual is send to bestsofar channel, that keeps the best individual found in process. Genomas channel receives an individual, evaluate its fitness, and forward it to Evaluated channel. Mutator receives a genoma, mutates and evaluates it. The new genoma is forwarded to Evaluated channel.

Many populations are processed in parallel. More accurate: there is no population, there are N * M individuals that are processed, mutated, and collected. For each group of N collected individuals, the best are selected, and a new group of N individuals are injected again in the process.

This is the code. First, launch a goroutine to generate the initial populations:

// Generates the initial populations
GoRoutines.Go(() =>
    Genoma genoma = GenerateGenoma();
    for (int j = 0; j < PopulationSize * 10; j++)

Launch a goroutine to evaluate new genomas:

// Evaluate genomas
GoRoutines.Go(() =>
    while (true)
        Genoma genoma = (Genoma)genomas.Receive();
        genoma.value = this.CalculateValue(genoma);

A goroutine to collect genomas, select them, and generate a new group, population:

// Collect and select
GoRoutines.Go(() =>
  GenomaComparer comparer = new GenomaComparer();
    while (true)
    List<Genoma> genomalist = new List<Genoma>();
    for (int k = 0; k < PopulationSize; k++)
      Genoma genoma = (Genoma)evaluated.Receive();
    GoRoutines.Go(() => bestsofar.Send(genomalist[0]));
    for (int k = 0; k < PopulationSize / 5; k++)
      GoRoutines.Go(() => evaluated.Send(genomalist[k]));
    for (int k = 0; k < PopulationSize / 5; k++)
      GoRoutines.Go(() => mutator.Send(genomalist[k]));
      GoRoutines.Go(() => mutator.Send(genomalist[k]));
      GoRoutines.Go(() => mutator.Send(genomalist[k]));
      GoRoutines.Go(() => mutator.Send(genomalist[k]));

A goroutine for receives genomas, improve them, and forwards them to evaluated channel:

// Mutates
GoRoutines.Go(() =>
    Random rnd = new Random();
    while (true)
    Genoma genoma = (Genoma)mutator.Receive();
    Genoma newgenoma = this.Mutate(genoma);
        while (newgenoma.value >= genoma.value)
            if (rnd.Next(3) == 0)
        newgenoma = this.Mutate(genoma);

A goroutine to receives and process the best-so-far indivuals:

// Receives and draws the results
GoRoutines.Go(() =>
    Genoma best = null;
    while (true)
        Genoma genoma = (Genoma)bestsofar.Receive();
        if (best == null || best.value > genoma.value)
            best = genoma;

I didn’t write support for crossover, but it could be added. The problem and algorithm could be changed. The main idea of this spike is to show the parallel implementation of a genetic algorithm.

The main problem is in the evaluated channel reading and processing. In that step, the goroutine forwards values to many channels. I had to launch many goroutines to feed the channels, because if one of these is blocked, the full process were blocked.

Next step: implement and use Queue Channels as in:

Implements actor model, and put each step in an agent. And then, implement distributed agents.

Keep tuned!

Angel “Java” Lopez

Blog at