francescomecca.eu/output/categories/programming.xml
Francesco Mecca 6acba75cd5 wine article
2024-02-28 14:38:55 +01:00

545 lines
76 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Caught in the Net (Posts about programming)</title><link>francescomecca.eu</link><description></description><atom:link href="francescomecca.eu/categories/programming.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:francescomecca.eu"&gt;Francesco Mecca&lt;/a&gt; </copyright><lastBuildDate>Wed, 28 Feb 2024 09:29:27 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Un articolo per r/italyinformatica</title><link>francescomecca.eu/blog/2018/07/27/addio-reddit/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;p&gt;Questo articolo è stato originalmente scritto per il &lt;a href="https://tldr.italyinformatica.org"&gt;blog&lt;/a&gt; di &lt;a href="https://reddit.com/r/italyinformatica"&gt;r/italyinformatica&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Negli ultimi anni abbiamo assistito all'ascesa di un gran numero di linguaggi di programmazione, in particolare &lt;a href="https://golang.rg"&gt;Go&lt;/a&gt; (2009), &lt;a href="https://www.rust-lang.org/en-US/"&gt;Rust&lt;/a&gt; (2010), &lt;a href="https://kotlinlang.org/"&gt;Kotlin&lt;/a&gt; (2011), &lt;a href="https://elixir-lang.org/"&gt;Elixir&lt;/a&gt; (2011), &lt;a href="https://crystal-lang.org/"&gt;Crystal&lt;/a&gt; (2014), &lt;a href="https://www.ponylang.or"&gt;Pony&lt;/a&gt; (2014).&lt;/p&gt;
&lt;p&gt;Questa esplosione di nuovi linguaggi è dovuta, fra le molte motivazioni, alla necessità di adottare paradigmi di programmazione non immediatamente recenti come cittadini di primo tipo.&lt;/p&gt;
&lt;p&gt;Rispetto ai più maturi C, C++ o Java, Python o Ruby questi linguaggi offrono "out of the box" supporto per:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;una visione moderna delle concorrenze (le goroutines di Go o il modello ad attori di Pony ed Elixir)&lt;/li&gt;
&lt;li&gt;Memory safeness, in particolare:&lt;ul&gt;
&lt;li&gt;assenza di NULL (Pony, Rust, Kotlin)&lt;/li&gt;
&lt;li&gt;gestione automatica della memoria, il cosiddetto [Garbage Collector](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science) (o &lt;a href="https://en.wikipedia.org/wiki/Reference_counting"&gt;Reference Counting&lt;/a&gt; per Rust)&lt;/li&gt;
&lt;li&gt;assenza di puntatori&lt;/li&gt;
&lt;li&gt;assenza di deadlocks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Supporto ad HTTP nella standard library&lt;/li&gt;
&lt;li&gt;Management delle dipendenze (ad eccezione di Kotlin)&lt;/li&gt;
&lt;li&gt;Namespaces&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chiaramente nessuno di questi linguaggi è oggettivamente superiore agli altri, sono tutti &lt;a href="https://en.wikipedia.org/wiki/Turing_completeness"&gt;turing completi&lt;/a&gt; e la scelta del programmatore ricade su motivazioni del tutto personali (stile, programmazione ad oggetti, familiarità con altri linguaggi).&lt;/p&gt;
&lt;h3&gt;Un pò di contesto&lt;/h3&gt;
&lt;p&gt;Ho scritto la mie prime due righe di codice nel 2013 per il corso di Computer Science del Politecnico di Torino.&lt;/p&gt;
&lt;p&gt;Per mia fortuna, al Politecnico le cose si muovono ancora lentamente e ci hanno fatto usare C per tutta la durata della triennale. Si è aggiunto un corso di principi della programmazione ad oggetti al terzo anno, in Java.&lt;/p&gt;
&lt;p&gt;Personalmente ho imparato durante l'estate di quel primo anno le basi di C++ e Python poco dopo.&lt;/p&gt;
&lt;p&gt;Sono stati con i miei primi &lt;a href="https://github.com/framecca"&gt;progetti&lt;/a&gt; che ho capito che non si può avere un buon linguaggio senza un buon tooling ed una community vivace e soprattutto tanta, tanta documentazione. Per questo, per molto tempo C è stata la mia prima scelta, dato che il mio target è sempre Linux.&lt;/p&gt;
&lt;h3&gt;Gli obbiettivi prima del linguaggio&lt;/h3&gt;
&lt;p&gt;Questo post vuole essere una raccolta più o meno organizzata delle motivazioni per cui mi sono dovuto muovere oltre la frontiera di C nel mio ultimo progetto, ovvero un backend per la raccolta e presentazione di pubblicazione di ricerca e materiale didattico per più di 80 centri di ricerca.&lt;/p&gt;
&lt;p&gt;Per il Centro &lt;a href="http://nexa.polito.it/"&gt;Nexa&lt;/a&gt; del Politecnico di Torino mi sono ritrovato per la prima volta responsabile del codice che dovevo scrivere e dell'uso che se ne sarebbe fatto.&lt;/p&gt;
&lt;p&gt;Ho dovuto tenere in considerazione, oltre chiaramente alla funzionalità della piattaforma, in ordine di priorità:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Sicurezza&lt;/li&gt;
&lt;li&gt;Performance e scalabilità&lt;/li&gt;
&lt;li&gt;Separazione dal frontend&lt;/li&gt;
&lt;li&gt;Facilità di deploy in un server che non controllo&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Fortunatamente non mi è stata imposta nessuna limitazione sulla scelta del linguaggio, altrimenti Python sarebbe stato la scelta più adeguata se avessi dovuto tener conto anche di altri programmatori.&lt;/p&gt;
&lt;h3&gt;Benvenuto D&lt;/h3&gt;
&lt;p&gt;La mia scelta è caduta su &lt;a href="https://dlang.org"&gt;D&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Voglio provare ad affrontare ad uno ad uno i motivi di questa scelta magari inusuale.&lt;/p&gt;
&lt;h5&gt;Sicurezza&lt;/h5&gt;
&lt;p&gt;Nessuno vuole davvero vantarsi di usare un backend scritto in C/C++. Il &lt;a href="https://en.wikipedia.org/wiki/Buffer_overflow"&gt;buffer overflow&lt;/a&gt; può essere considerato il bug più comune e ci sono &lt;a href="https://techaeris.com/2017/09/27/buzz-fuzzing-find-uncommon-vulnerability/"&gt;situazioni&lt;/a&gt; in cui non appaiono affatto in maniera ovvia.&lt;/p&gt;
&lt;p&gt;Inoltre per un applicativo distribuito il Garbage Collector è la scelta più performante, &lt;a href="https://www.usenix.org/node/189882"&gt;specialmente se coordinato fra le varie istanze&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;D offre questo di design, e benchè il suo GC sia frutto di numerose &lt;a href="https://www.quora.com/Which-language-has-the-brightest-future-in-replacement-of-C-between-D-Go-and-Rust-And-Why/answer/Andrei-Alexandrescu"&gt;discussioni&lt;/a&gt;, offre in maniera del tutto innovativa, robustezza e &lt;a href="http://www.walterbright.com/gonewild.pdf"&gt;sicurezza&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In particolare, D presenta:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Array che sono slices (o ranges) ma non puntatori (e neanche oggetti)&lt;/li&gt;
&lt;li&gt;Bound checking durante la fase di compilazione.&lt;/li&gt;
&lt;li&gt;Inizializzazione automatica delle variabili.&lt;/li&gt;
&lt;li&gt;Safe Casting (chiaramente come eredità di C++).&lt;/li&gt;
&lt;li&gt;Restricted pointers: si può passare una funzione per referenza dichiarandola &lt;code&gt;ref&lt;/code&gt;, ma solo quando passata come parametro o di ritorno. Inoltre non c'è nessuna pointer arithmetic.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization"&gt;RAII&lt;/a&gt;, ovvero l'acquisizione delle risorse equivale alla loro assegnazione e Scopes: le variabili hanno una lifetime limitata allo scope di dichiarazione. Nessun dangling pointer come in C.&lt;/li&gt;
&lt;li&gt;Strutture immutabili: come nelle specifiche di molti linguaggi funzionali, si può dichiarare una variabile come &lt;code&gt;immutable&lt;/code&gt; e quindi può essere facilmente condivisa fra threads.&lt;/li&gt;
&lt;li&gt;@safe, @trusted: le specifiche del linguaggio permettono di annotare delle funzioni come sicure o affidabili affinchè il compilatore controlli che non gestiscano puntatori (ad esempio interfacciandosi con C) ed utilizzino il subset "sicuro" del linguaggio (maggiori dettagli in seguito).&lt;/li&gt;
&lt;li&gt;funzioni pure: le funzioni inoltre possono essere dichiarate pure, prive di effetti collaterali e sempre &lt;a href="https://en.wikipedia.org/wiki/Reentrancy_(computing)"&gt;rientranti&lt;/a&gt;. Questo permette di evitare &lt;a href="https://en.wikipedia.org/wiki/Deadlock"&gt;deadlocks&lt;/a&gt; e un controllo totale sul risultato delle funzioni.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Performance&lt;/h5&gt;
&lt;p&gt;Ci sono moltissime soluzioni per scrivere un applicativo che si interfaccia con il web, ma hanno tutte la loro origine nel famoso &lt;a href="http://www.kegel.com/c10k.html"&gt;C10K problem&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nel mio caso ho deciso di utilizzare un approccio &lt;a href="https://stackoverflow.com/questions/10960998/how-different-async-programming-is-from-threads"&gt;asincrono&lt;/a&gt; con coroutines (anche detti &lt;a href="https://en.wikipedia.org/wiki/Green_threads"&gt;threads leggeri&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Benchè D abbia &lt;a href="https://dlang.org/library/core/thread/fiber.html"&gt;supporto nativo&lt;/a&gt; alle coroutines, ho deciso di appoggiarmi al framework più comune per web dev in D: &lt;a href="francescomecca.eu/blog/2018/07/27/addio-reddit/vibed.org"&gt;vibe.d&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Ogni volta che Vibe accetta una richiesta dall'esterno ed esegue una funzione bloccante (che interrompe l'esecuzione del programma fino al ritorno della funzione), questa viene messa in una pool di azioni da eseguire e Vibe controlla periodicamente che almeno una di queste sia pronta a ritornare un risultato e continuare con l'esecuzione di questa.&lt;/p&gt;
&lt;p&gt;Inoltre, benchè questo meccanismo funzioni interamente su un solo thread, è elementare coordinare una &lt;a href="https://en.wikipedia.org/wiki/Thread_pool"&gt;thread pool&lt;/a&gt; che distribuisa il carico fra i vari core che eseguono migliaia di threads leggeri concorrentemente.&lt;/p&gt;
&lt;h5&gt;Contratti e Tests&lt;/h5&gt;
&lt;p&gt;Non amo scrivere commenti sui programmi. Penso sia assolutamente necessario commentare il codice di librerie ma al di fuori di queste il codice (buon codice) dovrebbe essere autoesplicativo.&lt;/p&gt;
&lt;p&gt;Inoltre, nelle mie recenti esperienze, il comportamento del programma era chiaro a partire dai tests.&lt;/p&gt;
&lt;p&gt;In D questo concetto viene portato agli estremi applicando il &lt;a href="https://en.wikipedia.org/wiki/Design_by_contract"&gt;"Design by Contract programming&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Un contratto è la divisione di una funzione in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Precondizione, ovvero le condizioni che devono essersi verificate prima della chiamata della funzione;&lt;/li&gt;
&lt;li&gt;Postcondizione, ovvero le condizioni che devono essere rispettate all'uscita della funzione (solitamente applicate al risultato);&lt;/li&gt;
&lt;li&gt;Invarianti, ovvero le specifiche di una struttura dati che devono rimanere verificate in ogni funzione;&lt;/li&gt;
&lt;li&gt;Corpo della funzione&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Un esempio:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;struct&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Clock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;short&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;invariant&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;assert&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;short&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;addReturnTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Clock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;short&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;unittest&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;auto&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Clock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;assert&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;addReturnTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Come si nota dall'esempio il supporto ai tests è built-in nel linguaggio e distanti solo una flag in fase di compilazione.&lt;/p&gt;
&lt;h5&gt;Un approccio moderno alle concorrenze&lt;/h5&gt;
&lt;p&gt;Il modello primitivo delle concorrenze in Posix è discutibilmente datato e prono ad errori per il programmatore.&lt;/p&gt;
&lt;p&gt;D di default evita la condivisione di dati fra Threads.
Fra le varie motivazioni c'è il fatto che questo rifletta più realisticamente l'hardware, ma sicuramente l'obbiettivo finale è la riduzione di bug.&lt;/p&gt;
&lt;p&gt;Non voglio dilungarmi nei dettagli di ogni singolo approccio, ma per completezza D offre out of the box i seguenti modelli:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Message passing e &lt;a href="http://dist-prog-book.com/chapter/3/message-passing.html"&gt;attori&lt;/a&gt;, ovvero tutti i dati che vogliono essere condivisi fra thread sono incapsulati in &lt;a href="https://en.wikipedia.org/wiki/Remote_procedure_call"&gt;RPC&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;Green threads, come nel mio caso;&lt;/li&gt;
&lt;li&gt;Multi processing, ovvero &lt;code&gt;man 3 fork&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;TaskPools, ovvero future e promises di Python e Javascript;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://moss.csc.ncsu.edu/~mueller/cluster/ps3/SDK3.0/docs/accessibility/sdkpt/cbet_1simdvector.html"&gt;SIMD vectorization&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Andrei Alexandrescu, uno dei due creatori del linguaggio, dedica un intero capitolo alle concorrenze che potete leggere liberamente &lt;a href="http://www.informit.com/articles/article.aspx?p=1609144"&gt;qui&lt;/a&gt;.&lt;/p&gt;
&lt;h5&gt;Assenza di dogmatismi&lt;/h5&gt;
&lt;p&gt;Non potrei mai pensare di scrivere un linguaggio di programmazione senza mettere al secondo posto la semplicità.&lt;/p&gt;
&lt;p&gt;Ma chiaramente ancora prima di discutere di semplicità la dobbiamo definire.&lt;/p&gt;
&lt;p&gt;Go e Python sono due linguaggi semplici. Lo sono per la ridotta sintassi (Go in particolare) e perchè attraverso il loro dogmatismo costringono il programmatore ad adottare dei paradigmi di programmazione scelti dai designer di quel linguaggio. E` il motivo per cui in python non abbiamo delle vere lambda e per cui Go non ha le eccezioni.&lt;/p&gt;
&lt;p&gt;In D il programmatore ha libertà piena di scelta. Oltre ad un paradigma di programmazione si può ridefinire la sintassi e evitare il Garbage Collector. Si può in ultimo disattivare tutte le feature del linguaggio che sono @safe e adottare uno stile molto più vicino al C/C++, con tanto di inline asm.&lt;/p&gt;
&lt;h3&gt;Dove iniziare&lt;/h3&gt;
&lt;p&gt;Non posso non concludere un post propagandistico senza indirizzare i più interessati alle prime risorse per imparare D.&lt;/p&gt;
&lt;p&gt;Personalmente consiglio il &lt;a href="http://www.informit.com/store/d-programming-language-9780321635365?w_ptgrevartcl=Concurrency+in+the+D+Programming+Language_1609144"&gt;libro&lt;/a&gt; di Andrei che offre in particolare moltissimi dettagli sulle motivazioni del design di D. Non ho ancora letto un libro che affrontasse così chiaramente il design di linguaggi di programmazione e i vari compromessi fra performance, semplicità e complessità del compilatore.&lt;/p&gt;
&lt;p&gt;Inoltre il sito della community offre due intro per chi proviene da &lt;a href="https://dlang.org/ctod.html"&gt;C&lt;/a&gt; e &lt;a href="https://dlang.org/cpptod.html"&gt;C++&lt;/a&gt;, oltre al classi &lt;a href="https://tour.dlang.org/"&gt;tour&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Inoltre la libreria standard, &lt;a href="https://github.com/dlang/phobos"&gt;Phobos&lt;/a&gt;, è talmente chiara che solitamente mi trovo a mio agio a consultare direttamente il codice piuttosto che la documentazione online.&lt;/p&gt;</description><category>dlang</category><category>programming</category><category>reddit</category><guid>francescomecca.eu/blog/2018/07/27/addio-reddit/</guid><pubDate>Fri, 27 Jul 2018 00:00:00 GMT</pubDate></item><item><title>Capire il Machine Learning (parte 3)</title><link>francescomecca.eu/blog/2016/11/15/machine-learning-parte3/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;h3&gt;Riconoscimento delle immagini&lt;/h3&gt;
&lt;p&gt;Il machine learning viene utilizzato anche per il riconoscimento delle immagini.
La tipologia di rete neurale utilizzata per questa applicazione è chiamata rete neural a convoluzione ( &lt;strong&gt;convolutional neural networks&lt;/strong&gt;), abbreviata CNN.&lt;/p&gt;
&lt;p&gt;Innanzitutto consideriamo che ogni immagine può essere codificata come una matrice di valori&lt;/p&gt;
&lt;p&gt;&lt;img alt="pixel" src="francescomecca.eu/wp-content/uploads/2016/8.jpg"&gt;&lt;/p&gt;
&lt;p&gt;Vediamo ora quali sono le operazioni compiute da una &lt;strong&gt;CNN&lt;/strong&gt; per riconoscere delle immagini.&lt;/p&gt;
&lt;h5&gt;Convoluzione&lt;/h5&gt;
&lt;p&gt;Durante la fase di apprendimento, la rete neurale analizza moltissime immagini (categorizzate) utilizzando dei "filtri", ovvero delle funzioni che mescolate all'input originale permettono di evidenziare dei pattern nell'immagine.
Questi pattern corrispondono alle caratteristiche proprie di un oggetto (quali possono essere ad esempio per un uccello il becco, le piume, le ali) e nel caso queste sono presenti, possiamo riconoscere l'immagine.&lt;/p&gt;
&lt;p&gt;In questo esempio l'immagine di Wally é mescolata (l'operazione si chiama &lt;strong&gt;convoluzione&lt;/strong&gt;) con un filtro "a cerchio" che risponde molto bene a caratteristiche come quella di possedere degli occhi.&lt;/p&gt;
&lt;p&gt;&lt;img alt="waldoblue" src="francescomecca.eu/wp-content/uploads/2016/bluefilter.png"&gt;&lt;/p&gt;
&lt;p&gt;La &lt;strong&gt;convoluzione&lt;/strong&gt; é un'operazione che ha la proprietà di essere indipendente dalla posizione. Non importa la posizione degli occhi, quando applichiamo la &lt;strong&gt;convoluzione&lt;/strong&gt; su un'immagine con un filtro "a cerchio" notiamo che gli occhi sono presenti.&lt;/p&gt;
&lt;h5&gt;Subsampling&lt;/h5&gt;
&lt;p&gt;Ogni segnale contiene del "rumore", ovvero degli elementi che la allontanano dal comportamento ideale. &lt;/p&gt;
&lt;p&gt;&lt;img alt="ideal" src="francescomecca.eu/wp-content/uploads/2016/ideal.jpg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="real" src="francescomecca.eu/wp-content/uploads/2016/real.jpg"&gt;&lt;/p&gt;
&lt;p&gt;Attraverso il subsampling possiamo ridurre il rumore e rendere il nostro algoritmo meno suscettibile a queste piccole variazioni; benché l'immagine abbia una risoluzione minore, i pattern rimangono.&lt;/p&gt;
&lt;p&gt;&lt;img alt="waldosub" src="francescomecca.eu/wp-content/uploads/2016/sub.png"&gt;&lt;/p&gt;
&lt;h5&gt;Connessione completa&lt;/h5&gt;
&lt;p&gt;Alla fine dell'analisi tutte le caratteristiche estrapolate vengono considerate nell'insieme e in questo modo possiamo capire a quale categoria appartiene l'immagine.&lt;/p&gt;
&lt;p&gt;Questo procedimento a livello algoritmo si esplicita con una connessione completa fra tutti i nodi della rete neurale che possono poi restituire l'output (probabilità che l'immagine appartenga ad una determinata categoria).&lt;/p&gt;
&lt;h5&gt;Fase di rinforzo&lt;/h5&gt;
&lt;p&gt;Durante il training é presente un'ultima fase (o strato), chiamato più propriamente &lt;strong&gt;loss layer&lt;/strong&gt;. Questo strato provvede a dare un &lt;strong&gt;feedback&lt;/strong&gt; alla rete neurale analizzando l'output in relazione ai dati di partenza (ovvero le immagini già categorizzate).&lt;/p&gt;</description><category>AI</category><category>algoritmi genetici</category><category>Genetic algorithm</category><category>Neural networks</category><category>PesceWanda</category><category>programming</category><category>reti neurali</category><guid>francescomecca.eu/blog/2016/11/15/machine-learning-parte3/</guid><pubDate>Tue, 15 Nov 2016 00:00:00 GMT</pubDate></item><item><title>Capire il Machine Learning (parte 2)</title><link>francescomecca.eu/blog/2016/11/11/machine-learning-parte2/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;p&gt;Nel precedente &lt;a href="francescomecca.eu/pescewanda/2016/11/10/machine-learning-intro/"&gt;post&lt;/a&gt; abbiamo preso in considerazione una rete neurale molto basica.
Proviamo ora ad approfondire il concetto aggiungendo una proprietà fondamentale, la memoria.&lt;/p&gt;
&lt;h3&gt;Memoria e Stati&lt;/h3&gt;
&lt;p&gt;La rete neurale che abbiamo modellato non ha alcun tipo di memoria. con gli stessi dati di input, l'output è (quasi certamente) lo stesso.
Possiamo ampliare il nostro modello introducendo il concetto di &lt;em&gt;stato&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Poniamo il problema della vendita delle auto in questo modo:
immaginiamo di avere un algoritmo di machine learning che valuti le auto e faccia delle offerte di vendita che conseguentemente vengono valutate da delle persone e accettate oppure rifiutate.
Ogni volta che una proposta viene accettata la teniamo in memoria e nell'aggiustare i pesi per la seguente offerta, teniamo in considerazione la validità dei pesi usati in precedenza.
In altre parloe, in ogni operazione di valutazione dell'auto salviamo lo stato dell'offerta precedente (rifiutata o accettata) e la consideriamo quando vogliamo proporre l'offerta successiva.
Abbiamo in questo modo una &lt;em&gt;recurrent neural network&lt;/em&gt; (RNN) dove ogni stato precedente viene utilizzato per modificare l'output dell'algoritmo.&lt;/p&gt;
&lt;h5&gt;Generazione di testo attraverso le RNN&lt;/h5&gt;
&lt;p&gt;Immaginiamo di voler creare un algoritmo che utilizzando una RNN possa generare del testo o prevedere quale sarà il prossimo carattere inserito (come nel caso del T9).&lt;/p&gt;
&lt;p&gt;Inizialmente dobbiamo permettere alla RNN di analizzare almeno qualche sample del nostro testo.
La RNN analizza carattere dopo carattere e costruisce un grande grafo dove collega ogni carattere al suo successivo.
Inizialmente l'output della nostra RNN non ha alcun valore:
in questo esempio, abbiamo l'output di una RNN allenata attraverso Guerra e Pace:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;tyntd&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;iafhatawiaoihrdemot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;lytdws&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;tfti&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;astai&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ogoh&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;eoase&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rrranbyne&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;'&lt;/span&gt;&lt;span class="n"&gt;nhthnee&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;
&lt;span class="n"&gt;plia&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tklrgd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;o&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;idoe&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ns&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;smtt&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ne&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;etie&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;hregtrs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;nigtike&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;aoaenns&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;lngty&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;L'output prodotto dalla RNN, benchè non abbia nessun valore per un umano, viene analizzato dalla RNN per arricchire il grafo costituito inizialmente dai caratteri (e le loro relazioni) di Guerra e Pace.
Questo procedimento continua all'infinito.
Ogni volta che la RNN produce dell'output lo salva e lo riutilizza come input in maniera ricorsiva per generare nuovo output.&lt;/p&gt;
&lt;p&gt;Dopo 300 iterazioni abbiamo un output di questo tipo:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;"Tmont thithey" fomesscerliund
Keushey. Thom here
sheulke, anmerenith ol sivh I lalterthend Bleipile shuwy fil on aseterlome
coaniogennc Phe lism thond hon at. MeiDimorotion in ther thize."
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Dopo quasi mille:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;Aftair&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;fall&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;unsuch&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;that&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;hall&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Prince&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Velzonski&lt;/span&gt;&lt;span class="err"&gt;'s that me of&lt;/span&gt;
&lt;span class="err"&gt;her hearly, and behs to so arwage fiving were to it beloge, pavu say falling misfort &lt;/span&gt;
&lt;span class="err"&gt;how, and Gogition is so overelical and ofter.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Duemila:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="s2"&gt;"Why do what that day,"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;replied&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Natasha&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;wishing&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;himself&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;fact&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;the&lt;/span&gt;
&lt;span class="nv"&gt;princess&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Princess&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;Mary&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;was&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;easier&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;fed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;had&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;oftened&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;him&lt;/span&gt;.
&lt;span class="nv"&gt;Pierre&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;aking&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;his&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;soul&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;came&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;packs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;drove&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;up&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;his&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;father&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;in&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;law&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;women&lt;/span&gt;.
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Possiamo notare come l'output migliori visibilmente.&lt;/p&gt;
&lt;p&gt;Nel prossimo post tratterò una variante di rete neurale utilizzata per classificare e riconoscere immagini.&lt;/p&gt;</description><category>AI</category><category>algoritmi genetici</category><category>Genetic algorithm</category><category>Neural networks</category><category>PesceWanda</category><category>programming</category><category>reti neurali</category><guid>francescomecca.eu/blog/2016/11/11/machine-learning-parte2/</guid><pubDate>Fri, 11 Nov 2016 00:00:00 GMT</pubDate></item><item><title>Capire il Machine Learning (parte 1)</title><link>francescomecca.eu/blog/2016/11/10/machine-learning-intro/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;p&gt;Questo è il primo di una serie di post che hanno l'obbiettivo di fornire una breve e generale introduzione al mondo del machine learning e delle intelligenze artificiali più in generale.
Mi auguro che questa breve introduzione al mondo dell'apprendimento automatico sia una sorta di vaccino contro il sensazionalismo mediatico e la disinformazione che negli ultimi anni fanno da contorno al progresso in questo settore.&lt;/p&gt;
&lt;h3&gt;Non c'è risultato senza algoritmo&lt;/h3&gt;
&lt;p&gt;Nelle scienze informatiche un algoritmo è un insieme di istruzioni che partendo da uno stato iniziale (input) permette di arrivare ad uno stato finale (output) attraverso una serie di step logici.
Ogni algoritmo utilizza una logica propria e specifica per il problema di cui si occupa.
Nel caso del machine learning l'algoritmo non viene progettato in base al tipo di problema bensì vengono utilizzati algoritmi generici adattabili attraverso dei parametri.
L'algoritmo di machine learning analizza i vari parametri e i dati che riceve "in pasto" al fine di raggiungere lo stato di output ottimale.
L'output ottimale è la migliore approssimazione di un risultato teorico che si raggiunge nella fase di "training".&lt;/p&gt;
&lt;h3&gt;La macchina impara&lt;/h3&gt;
&lt;p&gt;Nella fase di allenamento o di apprendimento, il "training", si possono adottare due tecniche differenti: apprendimento con supervisione ( &lt;strong&gt;supervised learning&lt;/strong&gt; ) e apprendimento senza supervisione ( &lt;strong&gt;unsupervised learning&lt;/strong&gt; ).&lt;/p&gt;
&lt;h5&gt;Supervised Learning&lt;/h5&gt;
&lt;p&gt;Immaginiamo di dover valutare il prezzo di un'automobile usata senza essere esperti in materia.
Noi abbiamo questi dati:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;PREZZO ORIGINALE&lt;/th&gt;
&lt;th style="text-align: center;"&gt;Km percorsi&lt;/th&gt;
&lt;th style="text-align: center;"&gt;stato di usura&lt;/th&gt;
&lt;th style="text-align: right;"&gt;PREZZO FINALE&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;50 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;120 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;lieve&lt;/td&gt;
&lt;td style="text-align: right;"&gt;40 000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;150 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;notevole&lt;/td&gt;
&lt;td style="text-align: right;"&gt;8 000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;80 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;lieve&lt;/td&gt;
&lt;td style="text-align: right;"&gt;15 000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;120 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;notevole&lt;/td&gt;
&lt;td style="text-align: right;"&gt;...&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Dalla tabella possiamo dedurre la caratteristica fondamentale del &lt;strong&gt;supervised learning&lt;/strong&gt;: abbiamo due vettori (serie di dati) di input (prezzo originale) e di output (prezzo finale) che hanno una correlazione certa e valida.&lt;/p&gt;
&lt;p&gt;Possiamo dedurre intuitivamente quale sarà il prezzo dell'ultima auto se analizziamo i dati precedenti.
Questo è quello che succede nel caso del &lt;strong&gt;supervised learning&lt;/strong&gt;.
Un algoritmo di machine learning che utilizza il &lt;strong&gt;supervised learning&lt;/strong&gt; estrapolerà la relazione fra i vari dati e in questo modo potrà ottenere un determinato output partendo dai dati di input.
Possiamo capire già da ora che nel caso ci fossero dati che "inquinano" il nostro data set, come ad esempio il colore dell'auto, l'algoritmo non sarà capace di fare un'analisi corretta.&lt;/p&gt;
&lt;p&gt;La precisione della soluzione dipende dalla quantità di dati e dall'influenza che questi hanno nella situazione reale.&lt;/p&gt;
&lt;h2&gt;Unsupervised Learning&lt;/h2&gt;
&lt;p&gt;Nel caso di unsupervised learning ci troviamo di fronte agli stessi dati ma senza la possibilità di conoscere il prezzo finale.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;PREZZO ORIGINALE&lt;/th&gt;
&lt;th style="text-align: center;"&gt;Km percorsi&lt;/th&gt;
&lt;th style="text-align: right;"&gt;stato di usura&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;50 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;120 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;lieve&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;150 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;notevole&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;80 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;lieve&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;120 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;notevole&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Non siamo capaci di stabilire il prezzo finale attraverso l'unsupervised learning, ma possiamo stabilire dei pattern fra i vari dati.
Non c'è nessun tipo di feedback (il prezzo finale) che possa aiutarci a capire se il risultato sia giusto ma possiamo analizzare le notevoli relazioni fra i dati.&lt;/p&gt;
&lt;h2&gt;Machine Learning e intelligenza&lt;/h2&gt;
&lt;p&gt;Concentriamoci sul &lt;strong&gt;supervised learning&lt;/strong&gt;.
Nel caso della vendita dell'automobile, abbiamo un semplice problema con una soluzione lineare di questo tipo:
&lt;em&gt;prezzo finale&lt;/em&gt; = &lt;em&gt;prezzo originale&lt;/em&gt; + &lt;em&gt;km percorsi&lt;/em&gt; + stato di usura&lt;/p&gt;
&lt;p&gt;Ovviamente ogni incognita nella nostra equazione influisce diversamente sul prezzo finale e quindi possiamo riscriverla come:
&lt;em&gt;prezzo finale&lt;/em&gt; = A &lt;em&gt;&lt;em&gt;prezzo originale&lt;/em&gt; + B &lt;/em&gt;&lt;em&gt;km percorsi&lt;/em&gt; + C * stato di usura&lt;/p&gt;
&lt;p&gt;Se pensiamo ad un algoritmo possiamo ragionare in questo modo:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;funzione&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;calcola_prezzo_auto&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;parametri&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo_originale&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;km_percorsi&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;stato_usura&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variabili&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo_finale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;finale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo_originale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.804246&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;finale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo_finale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;km_percorsi&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.000125&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;finale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prezzo_finale&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;stato_usura&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2500&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I valori di quelle costanti, stabilite casualmente nell'esempio, sono chiamate &lt;em&gt;pesi&lt;/em&gt; e servono a stimare il prezzo finale.
Una volta stabiliti i pesi, il nostro algoritmo di supervised learning applica questi pesi ai dati originali e ne valuta l'errore:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;PREZZO ORIGINALE&lt;/th&gt;
&lt;th style="text-align: center;"&gt;Km percorsi&lt;/th&gt;
&lt;th style="text-align: center;"&gt;stato di usura&lt;/th&gt;
&lt;th style="text-align: center;"&gt;PREZZO FINALE&lt;/th&gt;
&lt;th style="text-align: right;"&gt;PREZZO STIMATO&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;50 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;120 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;lieve&lt;/td&gt;
&lt;td style="text-align: center;"&gt;40 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;374888&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;150 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;notevole&lt;/td&gt;
&lt;td style="text-align: center;"&gt;8 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;16000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;80 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;lieve&lt;/td&gt;
&lt;td style="text-align: center;"&gt;15 000&lt;/td&gt;
&lt;td style="text-align: right;"&gt;13492&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;120 000&lt;/td&gt;
&lt;td style="text-align: center;"&gt;notevole&lt;/td&gt;
&lt;td style="text-align: center;"&gt;...&lt;/td&gt;
&lt;td style="text-align: right;"&gt;10988&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Una volta valutato l'errore e la distanza dal prezzo finale, l'algoritmo di machine learning modifica i pesi di conseguenza e ripete la procedura fino ad arrivare al risultato che più si avvicina ai dati iniziali.
&lt;img alt="rete1" src="francescomecca.eu/wp-content/uploads/2016/reteneurale1.jpg"&gt;
Ci sono varie funzioni che stimano l'errore e permettono di correggere i pesi o metodi che restringono lo spazio di ricerca fino a convergere alla soluzione, ovvero i pesi cercati.&lt;/p&gt;
&lt;h3&gt;Reti Neurali&lt;/h3&gt;
&lt;p&gt;Ora, come possiamo immaginare, il prezzo di un'auto ha molti fattori che si aggiungono a quelli elencati nell'esempio.
Non solo, ma molti problemi non hanno una soluzione lineare, ovvero una soluzione che si può semplicemente esprimere attraverso una funzione che aggiunge e moltiplica i valori una sola volta.&lt;/p&gt;
&lt;p&gt;Possiamo arricchire l'esempio dell'automobile immaginando di avere più set di pesi e di ripetere il procedimento più volte:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;---------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO_ORIG * peso A1 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| KM_PERCORSI * peso B1 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| STATO_USURA * peso C1 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO FINALE STIMATO 1|&lt;/span&gt;
&lt;span class="c"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;---------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;span class="c"&gt;| &lt;/span&gt;&lt;span class="nb"&gt;--------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO_ORIG * peso A2 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| KM_PERCORSI * peso B2 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| STATO_USURA * peso C2 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO FINALE STIMATO 2|&lt;/span&gt;
&lt;span class="c"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;---------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;span class="c"&gt;| &lt;/span&gt;&lt;span class="nb"&gt;--------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO_ORIG * peso A3 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| KM_PERCORSI * peso B3 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| STATO_USURA * peso C3 &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO FINALE STIMATO 3|&lt;/span&gt;
&lt;span class="c"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;---------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;E ora immaginiamo di combinare ogni PREZZO FINALE STIMATO in un'ultimo risultato:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c"&gt;| &lt;/span&gt;&lt;span class="nb"&gt;--------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO_1 * peso X &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO_2 * peso Y &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO_3 * peso Z &lt;/span&gt;&lt;span class="nb"&gt;-----&lt;/span&gt;&lt;span class="nv"&gt;&amp;gt;&lt;/span&gt;&lt;span class="c"&gt; |&lt;/span&gt;
&lt;span class="c"&gt;| PREZZO FINALE DEF |&lt;/span&gt;
&lt;span class="c"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;---------------------------------------------------&lt;/span&gt;&lt;span class="c"&gt;|&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Questa é, seppur molto basica, una rete neurale.
Proviamo a visualizzarla in un'immagine dove i box arancioni sono i nodi di input e i rossi sono i nodi "nascosti" e temporanei.&lt;/p&gt;
&lt;p&gt;&lt;img alt="rete2" src="francescomecca.eu/wp-content/uploads/2016/reteneurale2.jpg"&gt;&lt;/p&gt;
&lt;p&gt;In una rete neurale (&lt;em&gt;neural networks&lt;/em&gt;) abbiamo:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;i neuroni: la funzione di stima e i set di pesi;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;le catene: i collegamenti fra neuroni che permettono di valutare il prezzo più volte.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nel prossimo &lt;a href="francescomecca.eu/pescewanda/2016/11/11/machine-learning-PARTE2"&gt;post&lt;/a&gt; cercherò di approfondire il concetto di rete neurale con degli esempi di applicazioni concrete.&lt;/p&gt;</description><category>AI</category><category>algoritmi genetici</category><category>Genetic algorithm</category><category>Neural networks</category><category>PesceWanda</category><category>programming</category><category>reti neurali</category><guid>francescomecca.eu/blog/2016/11/10/machine-learning-intro/</guid><pubDate>Thu, 10 Nov 2016 00:00:00 GMT</pubDate></item><item><title>Arduino Uno as HID keyboard</title><link>francescomecca.eu/blog/2016/7/5/arduino_keyboard/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;p&gt;Turin is the hometown of Arduino. I have been at the &lt;a href="http://fablabtorino.org/"&gt;fablab&lt;/a&gt; multiple times but I had to come all the way to America to get my hands on a simple Arduino Uno.&lt;/p&gt;
&lt;p&gt;For 60$ I bought a cheap (but still good!) mechanical keyboard by Qisan, a clone of the Arduino Uno and a USB host shield.&lt;/p&gt;
&lt;p&gt;Given that is 3 years since I have been using a dvorak layout and it's a pain to change layout on every machine that you have to use.
You can imagine that given this three pieces of hardware together I put together an hardware key mapper for the keyboard.&lt;/p&gt;
&lt;p&gt;I have never had experience with Arduino before but it was not that difficult to make it do simple things like blinking the led or send signal through to a serial monitor.&lt;/p&gt;
&lt;p&gt;It took me half an hour to wear down all my excitement: the USB Host Shield library broke all the compatibility with the similar project I found wandering online.&lt;/p&gt;
&lt;p&gt;In particular &lt;a href="http://hunt.net.nz/users/darran/"&gt;this blog&lt;/a&gt; has the most precious information and the guy wrote a HID driver that allows the Uno to be seen as a HID device.&lt;/p&gt;
&lt;p&gt;It was a noob error but I didn't checked the various arduino alternatives and I discovered late that just a few have the HID capabilities that would make this work easier. I should have bought and Arduino Due or Leonardo maybe.&lt;/p&gt;
&lt;p&gt;Also, the various guides about flashing with a dfu tool are specific to older models of the Uno and it took me some time to figure the name of the new components so that I could flash a new firmware.&lt;/p&gt;
&lt;h3&gt;A small journey in the Arduino world&lt;/h3&gt;
&lt;p&gt;It feels pretentious to write a little guide for this kind of work, given also the fact that I have roughly 10 hours of experience with the Arduino. But the other resources are really outdated so I hope this piece can be useful to someone out there.&lt;/p&gt;
&lt;p&gt;All the files I have used today are on &lt;a href="http://francescomecca.eu:3000/pesceWanda/arduino_HID_keyboard"&gt;my repos&lt;/a&gt; and I included also an outdated version of the USB Host Shield library that I used.&lt;/p&gt;
&lt;p&gt;The original code from this &lt;a href="http://hunt.net.nz/users/darran/weblog/c6f35/Arduino_USB_Keyboard_Passthrough.html"&gt;blog post&lt;/a&gt; works like a charm but just as a simple passthrough.&lt;/p&gt;
&lt;p&gt;It was not difficult at all to examine the code:
during each loop of the iteration a char array gets read from the shield and if it is contains information Arduino with the Serial.Write method send the data to the host.&lt;/p&gt;
&lt;p&gt;The buffer array is a simple array of length 8 and the first two positions are reserved. In particular the first one represent the various modifier keys.&lt;/p&gt;
&lt;p&gt;The dvorak layout has the same pairs as the US layout but eventually I got used to having the '@' where at the same place of 'Q' (qwerty) and '"' over the '2'.
Also, I am an avid vim user (I should thank Simone Basso for that) and I swapped some keys on the new 65 keys keyboard.
The modifier bit at the beginning of the array came in handy for my code.&lt;/p&gt;
&lt;p&gt;An hardware key remapper is a simple but long switch C statement but I decided to consider also the modifier bit: in this way certain keys like the Window (UGH!) key is mapped to a different layer of keys.
I got all the codes for the HID events &lt;a href="http://www.freebsddiary.org/APC/usb_hid_usages.php"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The process of flashing the code on the Uno goes like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;write the looping code;&lt;/li&gt;
&lt;li&gt;push it to the Arduino using the IDE;&lt;/li&gt;
&lt;li&gt;shortcircuit the board so that it goes in DFU mode;&lt;/li&gt;
&lt;li&gt;flash the .hex HID firmware;&lt;/li&gt;
&lt;li&gt;try your code;&lt;/li&gt;
&lt;li&gt;repeat until it's right.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="Everything fits in one picture" src="francescomecca.eu/wp-content/uploads/2016/IMG_20160706_011304.jpg"&gt;&lt;/p&gt;
&lt;h3&gt;Flashing the firmware&lt;/h3&gt;
&lt;p&gt;The firmware is in my repo but I got it from (here)[http://hunt.net.nz/users/darran/weblog/a6d52/Arduino_UNO_Keyboard_HID_version_02.html].
The tool I used to flash it is dfu-programmer (version 0.62).
Every time you want to flash a new firmware the Arduino must be put in DFU mode (you can see the difference with lsusb).
To do that simply create a shortcircuit using a small metal wire on the two pins near the reset button and a led will blink.
This &lt;a href="https://www.youtube.com/watch?v=E8XyRwXQr8Q"&gt;video&lt;/a&gt; shows the method briefly (no real need for a jumper).
The commands are the following and there is no risk to brick the Uno:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;dfu-programmer atmega16u2 erase
dfu-programmer atmega16u2 flash Arduino-keyboard-0.2.hex
dfu-programmer atmega16u2 reset
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After each flashing the device needs to be disconnected once. Of course you can flash the original firmware back. It is included in my repo or on the official ones.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Arduino and the shield" src="francescomecca.eu/wp-content/uploads/2016/IMG_20160706_011143.jpg"&gt;&lt;/p&gt;
&lt;p&gt;That's it, as you can see is not difficult at all. The worst part is gathering the various info that are left dormant in blogs or forums.&lt;/p&gt;</description><category>Arduino</category><category>arduino uno</category><category>HID arduino</category><category>mechanical keyboard</category><category>PesceWanda</category><category>programming</category><guid>francescomecca.eu/blog/2016/7/5/arduino_keyboard/</guid><pubDate>Tue, 05 Jul 2016 00:00:00 GMT</pubDate></item><item><title>Interpolation using a genetic algorithm</title><link>francescomecca.eu/blog/2016/5/15/genetic-alg/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;p&gt;This weekend I was in Milan to get a visa and I had the opportunity to work with a friend, Michele, on genetic algorithms.
It was the first time I dig up in such field and it was very exciting.
In this post I want to explain some bits of our work.&lt;/p&gt;
&lt;h3&gt;A brief introduction to GA&lt;/h3&gt;
&lt;p&gt;A genetic algorithm is a search/optimization algorithm that uses an heuristic approach to reduce the search space and evolve gradually to a solution.&lt;/p&gt;
&lt;h5&gt;Population&lt;/h5&gt;
&lt;p&gt;It is an algorithm that has its root in the theory of natural selectioni by Charles Darwin.
The main components of a GA are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the population, that concentrate all the available solutions at a given time;&lt;/li&gt;
&lt;li&gt;the fitness function, that gives an approximation of the quality of the solution codified by a given member of the population.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In a GA the first thing to do is to generate a population.&lt;/p&gt;
&lt;p&gt;A population is a group of objects with given attributes, usually a string, and they contains in some form the solution (usually inside a string); the first population is randomly generated and contains a big number of solutions, but not every solution (this is not a bruteforce approach).&lt;/p&gt;
&lt;p&gt;After this step the fitness functions evaluates the quality of every solution that a given member carries: the evaluation should be considered from a bottom up point of view.&lt;/p&gt;
&lt;h5&gt;Reproduction&lt;/h5&gt;
&lt;p&gt;Now, as in Darwin's theory of evolution, the member of the population are going to "reproduce": two members are going to be coupled to generate a new member of the second generation and every child member will contain a solution that is the product of the original genes of their parent members.&lt;/p&gt;
&lt;p&gt;This time the reproduction of the population into a second one is not entirely random. The fitness function gives us an approximation of the quality of every gene that a member carries and by the rule of the "survival by the fittest" the probability that a member is going to reproduce with another one is proportional to the quality of its genes.&lt;/p&gt;
&lt;p&gt;When we have a second generation of members we can recur on our GA and generate a third generation. From this point we can recur until we converge to a solution that is common to every member, or at least that is suited to our needs.&lt;/p&gt;
&lt;h5&gt;Mutation&lt;/h5&gt;
&lt;p&gt;Actually, in some cases, a mutation function can be added, so that, like in real world, some times the genes are "scrambled" indipendently from the fitness function.&lt;/p&gt;
&lt;p&gt;There is more to a GA, for example we could talk about possible ways of storing the genes inside a member or when to use mutation, anyway I want to stop here and continue with an analysis of my problem.&lt;/p&gt;
&lt;h3&gt;Interpolating a function using a GA&lt;/h3&gt;
&lt;p&gt;Me and Michele decided to spend some time developing a little python script to explore GA capabilities and we decided to interpolate some points on a cartesian plane.&lt;/p&gt;
&lt;p&gt;Our program, that is available &lt;a href="http://francescomecca.eu:3000/pesceWanda/interpol_genetica"&gt;here&lt;/a&gt; uses a class to define the various members of the population and a string for the genes, a class as well for the points on the plane.&lt;/p&gt;
&lt;p&gt;The fitness function is not as precise as it should be because this is only a proof of concept:&lt;/p&gt;
&lt;p&gt;.. code:: python&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="n"&gt;mutationProbability&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;
&lt;span class="n"&gt;rangeLimit&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;
&lt;span class="n"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;fitness&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pointList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;pointList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gene&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rangeLimit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;result&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;item is just a member of the population, poinList is the list of points and n is the number of points (n - 1 is the grade of the function).&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gene&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;this piece of code gives us the value of the function encoded in the genes in the points of pointList;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="nb"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;abs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;p&lt;/span&gt;.&lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;y&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;rangeLimit&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;:
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;result&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;while here the script stores 1 - the previous result because if the GA has yield a good result there should be distance = 0 from the function evaluated and the points; If this is the case, the fitness function should attribute the highest possible reproduction probability for that member.
At the end the fitness function returns the total value over the number of points evaluated.&lt;/p&gt;
&lt;p&gt;As you can see this fitness function is by no means an optimal one. The reproduction probability is higher for functions that crosses some points and are really distant from others rather than for functions that are closer to every point but crosses none.
Anyway for simple cases the GA yields good results, as an example for points (0 0), (1 4), (2 9) one of the member with the highest reproduction probability has this function in its genes:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;-0.0487839869993989 &lt;span class="gs"&gt;* x^0 + 4.600339125358671 *&lt;/span&gt; x^1 + -0.2780958075230644 * x^2
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that crosses this points: (0 -0.0488), (1 4.2735), (2 8.0395) given 80 iterations, initial population of 600 members and a two digit approximation.&lt;/p&gt;
&lt;p&gt;For a more precise computation a higher population size and a really high number of iterations should be used.&lt;/p&gt;</description><category>AI</category><category>Genetic algorithm</category><category>PesceWanda</category><category>programming</category><category>python</category><guid>francescomecca.eu/blog/2016/5/15/genetic-alg/</guid><pubDate>Sun, 15 May 2016 00:00:00 GMT</pubDate></item><item><title>Kyuss Music Player</title><link>francescomecca.eu/blog/2016/4/17/kpd-player/</link><dc:creator>Francesco Mecca</dc:creator><description>&lt;p&gt;For a long time I have been using Clementine music player on my workstation. Recently I reinstalled Gentoo on my desktop and I wanted to avoid installing QT libraries of any sort.
So I switched to &lt;a href="https://www.musicpd.org/"&gt;mpd&lt;/a&gt; and I have fallen in love with it. It is very flexible, fast and enriched by a lot of community software.
For some weeks I used mpc client as my primary client for mpd but I was not satisfied with it. Even though it is pretty minimal but packed with every feature mpd permits, the search feels uncomfortable because is case sensitive and need artist, album, etc. flags before any entry.
This is why I have written kpd together with Francesco Gallà&lt;/p&gt;
&lt;h3&gt;Kyuss Player Client&lt;/h3&gt;
&lt;p&gt;kpd is an acronym for Kyuss Player Client because we have been listening only to &lt;a href="https://en.wikipedia.org/wiki/Kyuss"&gt;Kyuss&lt;/a&gt; while programming this client.
We have reimplemented the search functions to suit our habits. No more case sensitive, optional 'artist, album, title' flags.
kpd accepts only one string as the search argument and implements optional filter arguments to narrow the search in a grep like way.
I welcome you to read the &lt;a href="http://francescomecca.eu:3000/pesceWanda/kpd"&gt;readme&lt;/a&gt; in my git to understand how the search works.
Anyway in this post I want to explain bits of the code.&lt;/p&gt;
&lt;h4&gt;Main&lt;/h4&gt;
&lt;p&gt;The main kpd file invoked when the command is run in the console is kpd.py
The most interesting part in this file IMHO is these lines:&lt;/p&gt;
&lt;p&gt;.. code:: python&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;argsOrder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dictArgs&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;False&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;update_status&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;methodToCall&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;getattr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;util&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;retUtil&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;methodToCall&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dictArgs&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;el&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;searchRes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;argsOrder is a list of the arguments on the command line in the order the user wrote them.
kpd uses a dictionary to store for every argument the corrispective string for the function that will be invoked using getattr.
In this way any argument can be added to the main file without writing any other line of code. WE used this method to avoid using switch alike solutions.&lt;/p&gt;
&lt;h4&gt;Util&lt;/h4&gt;
&lt;p&gt;The util.py source file is a pretty easy source file to read. It contains every function that can be invoked by command line arguments. Every function has the same 'prototypes' so that they can be called using the method explained above.
To implement &lt;code&gt;no-output&lt;/code&gt; and &lt;code&gt;output&lt;/code&gt; function I have used a class:
to suppress the output on the console the program assign to &lt;em&gt;sys.stdout&lt;/em&gt; a dummy class that save the original stdout on a variable and replaces write and flush functions so that they are just pass. and no output is written.
To permit output after suppression the program just reassing the original value to sys.stdout.&lt;/p&gt;
&lt;h4&gt;Database Search&lt;/h4&gt;
&lt;p&gt;In MPDdatabase.py we have written the search functions.
Originally we intended to just read and import in a dictionary the whole mpd database that is stored compressed in the home directory.
This list of dictionaries stores every entry related to the song and if any of them matches the search string or the filter string (considering also flags if any) the related song is printed on the output and saved in a list so it can be added by the add function.
This approach result very efficent in term of precision but it lacked speed. For a database of about 77 thousand songs (about 550k lines) a search query could last almost 2 seconds.
To improve the speed of the search we used the pickle module. The pickle module allows kpd to dump the data structure used to store the database in memory on a file that can be read easily by using the &lt;code&gt;pickle.load&lt;/code&gt; function.
In this way the search lasts about 40 milliseconds on the same database that wastes about 16MiB of memory on disk.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;This was really fun. It was our first hand on python project and the first real program we have written since we started learning programming at our university.
I discovered that programming allows me to relax and that is really cool to have custom software for activities you do every day.
The source for our program is stored in my git &lt;a href="http://francescomecca.eu:3000/pesceWanda/kpd"&gt;here&lt;/a&gt; and you are free to modify it.&lt;/p&gt;</description><category>mpd</category><category>music player</category><category>PesceWanda</category><category>programming</category><category>python</category><guid>francescomecca.eu/blog/2016/4/17/kpd-player/</guid><pubDate>Sun, 17 Apr 2016 00:00:00 GMT</pubDate></item></channel></rss>