Collecting Robots

Collecting Robots is a little project I have made as a project for a university course of Operating System for Robotics. The goal is to plan a strategy for some “robots” to collect some “objects” and taking them to some “collect points”. The robots also have a maximum capacity, i.e. they can take a maximum number of objects at once, so to go on they will need to take the objects to a collect point.

The problem is quite hard (I believe it is NP-hard) so my first thought was to use an heuristic approach. I implemented a genetic solution using the JSGenetic library I wrote some time ago.

Actually there’s a little problem with my implementation: the crossover operation is quite weak. It does not combine the two parent individual in a complete way, thus the generated children is often very similar to the parents. This moves the evolution capability towards the mutation process, which is much more random, and this means the evolution will lead more likely to a local optima. This is especially evident with large problems (many objects) when object positions are not uniformely distributed in the map.

The app is publicly available here.

Browser compatibility:

  • [Google Chrome/Chromium] OK
  • [Firefox] Some problems, “go” and “animate” button works but label doesn’t refresh (isn’t .innerText standard?), simulation is slower
  • [IE] Not tested
  • [Safari] Not tested

Some notes on usage of the app:

Map generation

You may use the randomly generated map which is presented on startup, generate a new one with the “randomize” button, or generate your own map.

To generate your map, just press “clear” to clear current map, then select the proper point you want to place on the dropdown list, and place it clicking on the map.

If you want to change the number of points used by the randomize option, you can place the point manually on the map, in the number and type you want them to be, and then pressing “randomize” will make a new random map with the number and type of points you placed.

Evolution of the solution

When the map is ready, you can press “init Evolver” to initialize the Evolver object, which is responsible for managing the evolution process.

Then, pressing “go” will start the evolution, showing the best solution found in the left canvas.

When you’re happy with the shown solution, press “stop”.

Simulation

Beware that you need to stop the evolution to run the simulation. Doing otherwise will lead to unknown results 😛

When you have a solution (you need to at least have initialized the Evolver), you can see the robots in action in the right canvas by pressing “animate”, which will start the simulation with the current solution.

JSGeneticNeuralNetwork.js experiment

This new project is about feed forward neural network with genetic evolving weights. I’ve combined my two libraries, JSGenetic and JSNeuralNetwork, plus a little module I’ve developed about continuous genetic algorithms, and developed a little library which evolves neural networks with a genetic algorithm.

A little example I’ve made to test the library can be found here, it’s pacman learning to eat.

There are also other examples in the JSNeuralNetwork page.

QuiXXX down, quick and hopefully effective primitive load balancing system

QuiXXX, an app for android and windows phone me and a friend developed some time ago, was actually (and unbelievably) doing well. It has been receiving ~ 5 to 10 thousands visits per month, which was about 5-10k times more than we expected when we first developed it as a joke.

Anyway, recently there has been a peek in traffic (looks like mexican windows phone users liked the app) and we first noticed the problem: we are exceeding the maximum CPU load of our free hosting service (frogcp.com):

cpuexceededfrogcp

So I registered another free account on altervista.org and uploded the app there, then also mirrored the app on my domain www.nicassio.it, and wrote a very primitive load balancing redirect in php to be hosted on the original service frogcp, which redirects to one of the two mirrors with equal probability.

Let’s see if this will sort it out.

Ah, this broke the scoreboard, but this is temporary.

I’ll update this blog post when there’s further information.

[update]

We needed to do this without an actual update of the app, but this is not possibile, at least for android. Any page on a different domain will be opened in the browser, instead of within the app. That’s because we didn’t tell the app to handle redirection that way. Since we are not willing to release an updated version of the app right now, after being ublocked today I reuploaded the app to the original frogcp url making some changes to lower the cpu usage. I hope this will be enough for the near future.

Naive Bayes Classifier in JS, empowering telegram webapp

Today I made a simple implementation of a naive bayes classifier in Javascript. The implementation was largely inspired by this article.

After that, I spent some time to integrate it with this Telegram webapp, and now I have a telegram webapp in which you can mark messages as ‘spam’ or ‘important’, and every message is then classified giving some confidence about the possibility of it of being part of these categories.

It saves the results to the chrome local storage, so that you can train the classifier over time, preserving the results beetween sessions.

When I will train it enough, and if the results are good, I’m looking forward to implement the auto-hiding of messages based on this data. This is intended for large telegram group chats, in which often off-topic messages will just make painful extracting important messages from the enormous amount of things people texted. How many times you look at your preferred messaging app and you find ~50 unread messages? This is meant to resolve this, even if the bayes classifier is not perfect for this task, it was easy to implement and usually gets good results. I’ll update here if I have encouraging result from this test.

Meanwhile, here’s a screenshot:

telegrambayesscreenshot

Some music, please

I’d like to spend a few words about a project I’ve been doing with a friend for some years so far. My friend, nicknamed ‘Cassio’, enjoys singing some music (sort of dancehall/reggae/hip hop) and It’s been years since I started assisting him technically to record some of his songs.

We bought some stuff, like a decent microphone, a tiny external audio card, some cables and a dedicated PC, and we’ve been recording some tracks using Cubase 5, with me enjoying exploring new effects and possibilities offered by the software. I must say that has been very much fun, and I’m sharing it on this blog because I think it’s a pretty interesting experience, with (maybe) some technical value too.

If you’re interested in listening some of the songs we produced, you can find them on his official soundcloud page. The songs are in italian.

JSNeuralNetwork updates and some more experiments

I’ve updated the JSNeuralNetwork library implementing a small and still simple version of the Hopfield Network, along with some implementations.

Moreover, I implemented a new experiment based on the Kohonen networks, which is about vision, and needs a webcam to work.

 

As usual everything is here: http://www.nicassio.it/daniele/JSNeuralNetwork/.

Due parole e un’app sugli strani redirect sdc.tre.it sdcf.tre.it di Tre Italia

In questi giorni mi sono ritrovato a discutere con i centralinisti del servizio clienti di Tre Italia a proposito di strani redirect che mi succedevano navigando su rete 3 con il mio cellulare. In particolare, succedeva che il mio browser veniva a tutti gli effetti intercettato e rediretto ad un servizio che appartiene al dominio tre.it, el mio caso sdcf.tre.it, che redirigeva a siti pubblicitari.

Ricercando in rete l’indirizzo, ho trovato diverse persone che condividevano il mio stesso problema, così ho deciso di telefonare al servizio clienti per far chiarezza.

La prima telefonata è stata a dir poco futile, nella quale il (non troppo preparato) centralinista mi assicurava che l’indirizzo non aveva assolutamente a che fare con alcun servizio della Tre. La cosa è ovviamente e palesemente falsa, dal momento che è un indirizzo che appartiene al dominio tre.it, registrato dalla società in questione.

A questo punto ho deciso di scrivere sulla pagina facebook di assistenza clienti 3, ottenendo le prime informazioni:

screen_assistenza_tre_sdcf

 

Insistendo col servizio clienti, un’altra operatrice mi cerca di dare maggiori informazioni, ma nemmeno lei sa spiegare qualcosa a proposito di questi strani redirect. L’unica cosa che scopro è che sul mio conto sono stati addebitati 14 centesimi per visualizzazione di contenuti di “editoria mobile”, che sono riconducibili a testate giornalistiche che hanno stretto contratti con Tre Italia per addebitare automaticamente sul conto dei visitatori che accettassero di visualizzare le pagine con i loro articoli. L’operatrice mi assicura che quando queste pagine si presentano, da qualche parte deve essere specificato che il contenuto è a pagamento, e io di questo sono sicuro. Ma sono anche relativamente certo che non avrei mai accettato di pagare 7 o 9 centesimi per visualizzazione se ne fossi stato cosciente. Sento puzza di soldi facili per le testate giornalistiche e Tre.

Detto questo, chiedo che Tre non accetti mai in futuro addebiti sul mio conto che non siano relativi all’utenza telefonica, come ad esempio questi addebiti da siti quali corriere.it o repubblica.it. L’operatrice insiste che questo non è possibile, farfugliando qualcosa a proposito del fatto che Internet è libera. Devo dire che se anche Internet fosse libera, cosa di cui dubito sempre di più, Tre si sta impegnando in tutti i modi per evitare che sia così.

Finito questo piccolo sfogo, che racconta la mia esperienza con gli addebiti Tre, veniamo alla parte tecnica, che più si addice a questo blog. Ho provato a realizzare un’applicazione Android che, senza necessità dei permessi di root sul telefono, sia in grado di intercettare le chiamate ai servizi di tre.it riconducibili a pubblicità o addebiti indesiderati. Cercando in rete ho scoperto degli indirizzi sono usati da Tre per “servizi” che hanno (a mio avviso) come scopo principale quello di addebitare costi a utenti inconsci, e che si possono trovare preinseriti addirittura nei browser predefiniti dei telefoni brandizzati Tre. Tutto questo è un insulto alla clientela, se non si può già paralare di truffa.

L’applicazione che ho sviluppato serve ad intercettare eventuali redirect indesiderati del browser verso questi indirizzi:

sdc.tre.it

sdcf.tre.it

mobile.tre.it

portal.tre.it

L’applicazione è per ora in fase di test, potrebbe non funzionare bene e non in tutti gli scenari, ma è già qualcosa. L’ho già rilasciata sperando che possa funzionare almeno in parte per chi condivide questi problemi, soprattutto perchè anche cercando in rete, o chiamando il servizio clienti sembra che questi problemi non si possano risolvere altrimenti.

Ecco il link all’applicazione nel Google Play Store:

https://play.google.com/store/apps/details?id=it.nicassio.addebititreblocker

Update:

Aggiungo un link ad un relativo articolo di bastabollette.it che suggerisce anche un approccio legale al problema: https://bastabollette.it/telefonia/h3g/sdcf-tre-come-difendersi/

JSNeuralNetwork first implementation

As I started attending a class of introduction to neural network at the university, I’ve been looking to create something which would help me to understand the subject better with some practice. Therefore I decided to implement a sample Neural Network library in Javascript, which will implement at least some of the networks we saw during the class.

The first one I’ve implemented is a WTA (Winner Takes All) network, and an example can be found here. There might be space for improvement, I may refine this in the future, but my goal in this blog is to point out the intuition behind what I do, not to provide tools to be used in production.