An agile mutator

The agile mutator is being developed at the artai repo: https://github.com/jhlq/artai.co

In the Hexago folder the file called mutator.jl contains code that learns from the mutations it performs where it is beneficial to mutate. Try the Hexago game here: https://hexago.herokuapp.com/ (soon at http://artai.co/hexago/ )

The other thing we said we would do in association with that treacherous company with which we previously collaborated has been completed and they will not be mentioned again.

Posted in Miscellaneous | Leave a comment

Congo

“The wars in that country have claimed nearly the same number of lives as having a 9/11 every single day for 360 days, the genocide that struck Rwanda in 1994, the ethnic cleansing that overwhelmed Bosnia in the mid-1990s, the genocide that took place in Darfur, the number of people killed in the great tsunami that struck Asia in 2004, and the number of people who died in Hiroshima and Nagasaki — all combined and then doubled.”
http://edition.cnn.com/2012/11/27/opinion/congo-war-ignored-vava-tampa/

Posted in Horror | Leave a comment

The mutator

This time we consider a mutator with memory, first obtain the code from:
https://github.com/jhlq/trademaker/blob/master/AI2.jl
Then load it into julia:
julia -L AI2

Create the mutator and its neural network:
mutator=init()

The mutator keeps track of the network, now we need some training samples.
example,target=rsample()

Examples consist of bars describing how dispersed the previous hundred trades were and a target value to assign to these bars depending on how fast two bids on the spread are bought.

The net is untrained so the result is random:
score(mutator.net,example,target)

Let’s poke it.
poke!(mutator,example,target)

The mutator pokes the net in various ways to make it conform to the target and also remembers the effect of poking a specific node, maximum score per example is 1.
score(mutator.net,example,target)

Ever had your brain poked continuously a thousand times?
for poke in 1:1000;println(poke!(mutator,example,target));end
score(mutator.net,example,target) #0.9999999

Let’s see what result we get on several samples
examples,targets=rsamples(10)

The score function is overloaded to handle sample arrays.
score(mutator.net,examples,targets)
poke!(mutator,examples,targets)
score(mutator.net,examples,targets)
sum(score(mutator.net,examples,targets))

The poke! function also, the exclamation point is a julia convention for functions that modify their arguments.
poke!(mutator,examples,targets)
sum(score(mutator.net,examples,targets))

The overloaded poker pokes once for each sample, because of this the end result is sometimes worse. So we use the pocket algorithm, it works like this: we take the best result so far, and put it in our pocket.

The pocket algorithm is part of the evolve function, let’s do ten iterations:
mutator=evolve(mutator,examples,targets,10);

Each time a better net is pocketed the new score is printed. Let’s evolve a lot.
mutator=evolve(mutator,examples,targets,10000);

After a while the rate of improvement decreases, this means we need to decrease the mutation factor which defaults to 0.1, a value that determines the strength of the poke!
mutator=evolve(mutator,examples,targets,1000,0.03);
mutator=evolve(mutator,examples,targets,1000,0.01);

Next up we will download the full trade history and make the mutator more agile.

Posted in Miscellaneous | Leave a comment

Neural networks in Ripple

We need data. We need a model to process the data. We need the model to evolve.

The full code can be found at https://github.com/jhlq/trademaker/blob/master/AI.jl

All trades in the Ripple network are stored, the first thousand BTC trades are here: https://ripple.com/chart/BTC/XRP/trades.json?since=1

To get a random set of a thousand trades in Julia we first define
start=1000*abs(rand(Int)%100)
Then do:
trades=JSON.parse(readall(`curl https://ripple.com/chart/BTC/XRP/trades.json?since=$start`))
Or, using the Requests package:
trades=JSON.parse(get("https://ripple.com/chart/BTC/XRP/trades.json?since=$start").data)

This will yield non overlapping sets which facilitates database storage (there is a SQLite package) however for training purposes overlapping sets are often better since this translates to more training examples.

Next we divide the trades, one part the model looks at to predict the other part.
np=100
peek=zeros(np,2)
for t in 1:np
  peek[t,1]=float(trades[t]["price"])
  peek[t,2]=float(trades[t]["amount"])*(0.5+0.5*t/100)
end

The amount is scaled so that a most recent trade contributes twice as much as one a hundred trades ago.

Now we make a histogram, for algorithmic reasons the number of intervals should be odd.
ma=maximum(peek[:,1])
mi=minimum(peek[:,1])
niv=33
bars=zeros(niv)
intervall=(ma-mi)/niv
for t in 1:np
  for iv in 1:niv
    if peek[t,1]<mi+intervall*iv
      bars[iv]+=peek[t,2]
      break
    end
  end
end

Here is where the model decides which bids to place, lets put one each in two of the most popular intervalls:
maxi=sortperm(bars,rev=true)
bidiv1=maxi[1]*intervall+mi
bidiv2=maxi[2]*intervall+mi

If they both get bought we make a profit so lets grade the bids based on how long it takes for one BTC to be traded in both intervalls.
bid1val=0
bid2val=0
barval=0
for testi in 101:1000
  test=[float(trades[testi]["price"]),float(trades[testi]["amount"])]
  for iv in 1:niv
    if test[1]bidiv1-intervall
      bid1val+=test[2]
      break
    elseif test[1]bidiv2-intervall
      bid2val+=test[2]
      break
    end
  end
  if bid1val>1 && bid2val>1
    println(testi)
    barval=1-(testi-101)/900
    break
  end
end

The bars and barval are what matters, they are the training sample and its prediction target. Lets make some functions for working with neural networks, the ones in AI.jl are called: makenet, mutate and feed. The bars are not quite ready to be fed to a network, first we need to make them spatially invariant since a vector of [1,0,1,0,0] contains essentially the same information as [0,0,1,0,1] but they will be treated entirely different, lets see them both as a vector containing a gap of length one.
function transpatinvari(d)
  dn=d/maximum(abs(d))
  nd=length(dn)
  if nd%2==0
    push!(dn,0) #for symmetry
    nd+=1
  end
  t=zeros(nd)
  for da in 1:nd
    for dat in 0:nd-da
      t[1+dat]+=dn[da]*simil(dn[da],dn[da+dat])
      #simil is a custom similarity measure
    end
  end
  return t
end

After feeding the network these transformed bars its prediction is scored based on the similarity to barval. Many algorithms can be based on such a score, below is one which randomly mutates the top performers in each generation.
function evolve(net=makenet(33,50,3),gens=3,its=9)
  #its is the number of iterations per generation
  nn=9
  m1=6
  nets=mutate(net,nn)
  tnets=nets
  scores=Array(Array,gens)
  for gen in 1:gens
    scores[gen]=score(nets,its)
    tops=sortperm(scores[gen],rev=true)
    tnets[1:m1]=mutate(nets[tops[1]],m1)
    tnets[m1+1:end]=mutate(nets[tops[2]],nn-m1)
    nets=tnets
  end
  return nets,scores
end

nets=evolve()

Evolution can be boosted by having the mutator evolve. Each time a neuron is perturbed the result is logged and the mutator remembers the effect of mutating that neuron.

Posted in Science | 56 Comments

Gravity and 3D laser pens

Anyone who has ever ran a simulation of the common space time diagram of gravity where planets appear on a elastic sheet knows that it is not an optimal representation of what is actually going on; the spheres on the sheet do not neatly revolve around eachother but rather quickly crash together.

What does the diagram really represent? In places of greater mass the sheet is lower, so the depth indicates gravitational force and gravity in turn warps space time. Volume around a dense object is pulled closer and becomes more compact, for a box to contain the same amount of volume while moving down the sheet it has to become relatively smaller.

Field

Each circle travels past an equal area on both sides, in other words each circle is a straight line. This effect also explains why no object traveling at finite speed can return from the horizon of a black hole: it’d have to travel an infinite distance.

By filling three perpendicular planes with diodes emitting light invisible until three beams cross one can draw in the enclosed space by selectively turning on lights with a penremote, pemote!

Posted in Science | Leave a comment

Progress

What if we could contribute to advancing science? What if we could get paid for this contribution? Well, we can. With the rise of internet huge amounts of computing power has become available “in the cloud” and the potential of this metacomputer has been utilized for a while by projects where individuals idle time is donated to for example folding proteins, marking cancer or searching for extraterrestrials. This cloud has also spawned a new form of currency, born from the desire of money not controlled by any government, the pioneering efforts of Bitcoin developers are sending ripples through the world in countless forms of which one is Ripple’s creation XRP. A currency aiding to initiate a trend of putting to good use the vast resources involved in creating virtual coins, in contrast to Bitcoin instead of solving rather meaningless puzzles for safety XRP is awarded to computers who contribute toward scientific progress.

So beyond the satisfaction of improving life on earth what is the monetary reward involved? Maybe it is mostly nominal and this whole cryptocurrency fad is soon to disappear? Such statements were numerous in their early days and an early landmark was achieved in 2010 when a forum member declared that two pizzas had been purchased for ten thousand Bitcoins, crypptocurrencies were achieving real value! That sum, 10 000 BTC, is today worth over five million euro.

Participating in this new project launched last month seems wise, if there is an idle computer at home connecting it to the world community grid benefits everyone involved. Start contributing: https://www.computingforgood.org/ Join the talk: https://ripple.com/forum/ (Qni)

Posted in Science | Tagged , , | Leave a comment

Profit != Progress

Portraying the situation so horrendous as this documentary does seems a little exaggerated, humanity may end, life goes on.

Posted in Miscellaneous | Leave a comment