Using CNTK and C# to train Mario to drive Kart


Introduction

In this blog post I am going to explain one of possible way how to implement Deep Learning ML to play video game. For this purpose I used the following:

  1.  N64 Nintendo emulator which can be found here,
  2. Mario Kart 64 ROM, which can be found on internet as well,
  3. CNTK – Microsoft Cognitive Toolkit
  4. .NET Framework and C#

The idea behind this machine learning project is to capture images together with action, while you play Mario Kart game. Then captured images are transformed into features of training data set, and action keys into label hot vectors respectively.  Since we need to capture images, the emulator should be positioned at fixed location and size during playing the game, as well as during testing algorithm to play game. The flowing image shows N64 emulator graphics configuration settings.

2018-02-15_16-34-03

Also the N64 emulator is positioned to Top-Left corned of screen, so it is easier to capture the images.

Data collection for training data set

During image captures game is played as you would play normally. Also no special agent, not platform is required.

In .NET and C# it is implemented image capture from the specific position of screen, as well as it is recorded which keys are pressed during game play. In order to record keys press, the code found here is modified and used.

The flowing image shows the position of N64 emulator with playing Mario Kart game (1), the windows which is capture and transform the image (2), and the application which collect images, and key press action and generated training data set into file(3).

2018-02-15_16-31-42

The data is generated on the following way:

  • each image is captured, resized to 100×74 pixels and gray scaled prior to be transformed and persisted to data set training file.
  • before image is persisted the hotkey of action key press is recorded and connected to image.

So the training data is persisted into CNTK format which consist of:

  1. |label – which represent 5 component hot vector, indicate: Forward, Break, Forward-Left, Forward-Right and None (1 0 0 0 0)
  2. |features consist of 100×74 numbers which represent pixels of the images.

The following data sample shows how training data set are persisted in the txt file:

|label 1 0 0 0 0 |features 202 202 202 202 202 202 204 189 234 209 199...
|label 0 1 0 0 0 |features 201 201 201 201 201 201 201 201 203 18...
|label 0 0 1 0 0 |features 199 199 199 199 199 199 199 199 199 19...
|label 0 0 0 1 1 |features 199 199 199 199 199 199 199 199 199 19...

Since my training data is more than 300 000 MB of size, I provided just few BM sized file, but you can generate file as big as you wish with just playing the game, and running the flowing code from Program.cs file:

await GenerateData.Start();

Training Model to play the game

Once we generate the data, we can move to the next step: training RCNN model to play the game. For training model the CNTK is used. Also since we play a game and previous sequence will determined the next sequence in the game, LSTM RNN is used. More information about CNTK and LSTM can be found in previous posts. In my case I have collected nearly 15000 images during several round of playing the same level and route. Also for more accurate model much more images should be collected, nearly 100 000. The model is trained in one hour, with 500000 iterations. The source code about whole project can be found on GitHub page. (http://github.com/bhrnjica/LSTMBotGame )

By running the following code, the training process is started with provided training data:

CNTKDeepNN.Train(DeviceDescriptor.GPUDevice(0));

Playing the game with CNTK model

Once we trained the model, we move to the next step: playing a game. The emulator should be positioned on the same position and with the same size in order to play the game.ONce the model is trained and created in th training folder, the playing game can be achive by running:

var dev = DeviceDescriptor.CPUDevice;
MarioKartPlay.LoadModel(“../../../../training/mario_kart_modelv1”, dev);
MarioKartPlay.PlayGame(dev);

How it looks like on my case, you can see on this youtube video:

Advertisements

Using CNTK with Visual Studio 2017 and Python


In the next few steps will show how to install CNTK and python environment in Visual Studio 2017.

  1. First download the latest CNTK version from the official GitHub page, or just click on the following link: https://github.com/Microsoft/CNTK/releases

The release page will show the latest bits. Click on the CPU only package, accept the license and download the zip file.

  1. Once that you have zip file on your PC, create the folder C:/local on disk and unzip the package in to it.
  2. The next step performs the installation of the library as well as installation of the Python related distribution anaconda 4.1.1.
  3. Open C:\local\cntk\Scripts\install\windows path and run install.bat file. You will need administrative rights in order to successfully install all required components.
  4. The following image shows the installation process:

  1. As can be seen first you have to run batch file (step 2), then press 1 and ENTER in order to continue with the installation process and press ‘y‘, to perform downloading required components.
  2. The installation process takes several minutes to complete. The first component to be installed is Anaconda 4.1.1 which is needed in order to setup  CNTK.

  1. Once the anaconda is installed, the process of CNTK installation starts and passes very quickly since we already download all CNTK bits.

  1. Now that we have CNTK installed, the last installation step is installation of the Visual Studio Tool for Python.
  2. Run the Visual Studio 2017 Installer and after the installed is show, just select the python components similar picture shows below:

  1. Once the installation is completed run Visual Studio 2017.
  2. From the Visual Studio 2017 Tool menu select Python and then select Python Environment:

  1. From the Python Environment window select Anaconda 4.1.1 and update symbols DB, by pressing the button pointed on the image below:

  1. Once we have environment updated, Press “Make this the default environment for the new projects” option in order to apply the environment for the future Python CNTK based projects.
  2. Also the path for Python and Python scripts should be registered in Global Environment OS.

  1. Once the previous steps are performed successfully, we can start writing CNTK aware python code in Visual Studio 2017.
  2. OPen VS 2017 and Anaconda 4.1.1 environment and type.

   import cntk

print(“CNTK verion:”, cntk__version__)

  1. Similar output should be appear
  2. print(“CNTK version:”, cntk.__version__)

 

GPdotNET v4.0 has been released


After almost two years of implementation, I am proud to announce the forth version of the Open source project called GPdotNET v4.0. The latest version completely implements Genetic Programming and Artificial Neural Network for supervised learning tasks in three kind of problems: regression, binary and multiclass classification. Beside supervised learning tasks, with GPdotNET you can solve several Linear Programming problems: Traveling Salesman, Assignment and Transportation problems. The source code and binaries can be download from Github page: https://github.com/bhrnjica/gpdotnet/releases/tag/v4.0

Figure 1. Main Window in GPdotNET v4.0

Introduction

In 2006 the GPdotNET started as post-graduate semester project, where I was trying to implement simple C# program based on genetic programming. After successfully implemented console application, started to implement .NET Windows application to be easy to use for anyone who wants to build mathematical model from the data based on genetic programming method. In November 2009 GPdotNET became an open source project, by providing the source code and installer. Since then I have received hundreds of emails, feedbacks, questions and comments. The project was hosted on http://gpdotnet.codeplex.com. In 2016 I decided to move the project to GitHub for better collaboration and compatibility, and can be found at http://github.com/bhrnjica/gpdotnet. However, for backward compatibility, the old hosting site will be live as long as the codeplex.com would be live. Since the beginning of the development, my intention was that the GPdotNET would be cross-OS application which can be run on Windows, Linux and Mac. Since version 2, GPdotNET can be compiled against .NET and Mono, and can be run on any OS which has Mono Framework installed. Beside this fact, vast majority of users are using GPdotNET on Windows OS.

GPdotNET is primarily used on Academia by helping engineers and researchers in modelling and prediction various problems, from the air pollution, water treatment, rainfall prediction, to the various modelling of machining processes, electrical engineering, vibration, automotive industry etc. GPdotNET is used in more than ten doctoral dissertations (known to me) and master thesis, nearly hundreds paper used GPdotNET in some kind of calculation.

Modeling with GPdotNET (New in GPdotNET v4.0)

Working with GPdotNET requires the data. By providing the learning algorithms GPdotNET uses a data of the research or experimental measures to learn about the problem. The results of learning algorithms are analytical models which can describe or predict the state of the problem, or can recognize the pattern. GPdotNET is very easy to use, even if you have no deep knowledge of GA, GP or ANN. Appling those methods in finding solutions can be achieved very quickly. The project can be used in modeling any kind of engineering process, which can be described with discrete data, as well as in education during teaching students about evolutionary methods, mainly GP and GA, as well as Artificial Neural Networks.

Working in GPdotNET follows the same procedures regardless of the problem type. That means you have the same set of steps when modelling with Genetic Programming or Neural Networks. In fact, GPdotNET contains the same set of input dialogs when you try to solve Traveling Salesman Problem with Genetic Algorithm or if you try to solve handwriting recognition by using Backpropagation Neural Networks. All learning algorithms within GPdotNET share the same UI.

The picture below shows the flowchart of the modelling in GPdotNET. The five steps are depicted in the graphical forms surrounded with Start and Stop item.

Figure 2. Modelling layout in GPdotNET 4.0

After GPdotNET is started main window is show, and the modelling process can be started.

Choosing the Solver Type

The first step is choosing the type of the solver. Which solver you will use it depends on your intention what you want to do. Choosing solver type begins when you press “New” button, the “GPdotNET Model creation wizard” appear. Soler types are grouped in two categories. The first group (on the left side) contains models implemented prior to v4.0 version. It contains solvers which apply GP in modelling regression problems, and GP in optimization of the GP models. In addition, you can perform optimization of any analytically defined function by using “Optimization of the Analytic function”. Also, there are three linear programming problems which GPdotNET can solve using GA.

On the right side, there are two kind of solvers: GP or ANN, which are not limited to solve only regression. Both GP or ANN can build model for regression, binary or multi-class problems. Which type of problem GPdotNET will use, depends of the type of the output column data (label column).

Figure 3. Available model types

Loading Experimental Data (new in GPdotNET 4.0)

GPdotNET uses powerful tool for importing your experimental data regardless of the type. You can import numerical, binary or classification data by using Importing Data Wizard. With GPdotNET importing tools you can import any kind of textual data, with any kind of separation character.

Figure 4. Importing dataset dialog

After the data is imported in forms of columns and rows, GPdotNET implemented set of very simple controls which can perform very powerful feature engineering. For each loaded column, you can set several types of metadata: column name, column type (input, output, ignore), normalization type (minmax, gauss), and missing value (min, max, avg). With those options, you can achieve most of the modelling scenarios. Before “Start Modelling” minimum conditions must be achieved.

  • At least one column must be of “input” parameter type.
  • At least one column must be of “output” parameter type.

Which type of problem (regression, binary or multi class) will be used depends of the type of the output column. The following cases are considered:

  1. in case of regression problems ouput column must be of numeric type.
  2. in case of binary classinfication output column must be of binary type.
  3. in case of multi class classinfication output column must be of categorical type.

Figure 5. Defining metadata for training data set

When the column should not be part of the feature list, it can be easily ignored when the Column Type is set to “ignore“, or Param type is set to “string“.

Figure 6. Changing column type to binary

Change value of metadata by double click on the current value, select new values from available popup list. When you done with Feature Engineering press “Start Modelling” button and the process of modelling can be start.

Note: After you press Start Modelling button you can still change values of metadta, but after every change of the metadata values, Start Modelling button must be pressed.

Setting Learning Parameters

Figure 7. Setting parameters Dialog

After data is loaded and prepared successfully, you have to set parameters for the selected method. GPdotNET provides various parameters for each method, so you can set parameters which can provides and generates best output model. Every parameter is self-explanatory.

Searching for the solution

GPdotNET provides visualization of the searching solution so you can visually monitor how GPdotNET finds better solution as the iteration number is increasing. Beside searching simulation, GPdotNET provides instant result representation (only GP models), so any time the user can see what is the best solution, and how currently best solution is good against validate or predicted set of data. (Result and Prediction tabs).

Figure 8. Searching simulation in GPdotNET

Saving and exporting the results:

GPdotNET provides several options you can choose while exporting your solution. You can export your solution in Excel or text file, as well as in Wolfram Mathematica or R programming languages (GP Models only). In case of ANN model the result can se exported only to Excel.


Figure 9. Searching simulation in GPdotNET

Besides parameters specific to learning algorithm, GPdotNET provides set of parameters which control the way of how iteration process should terminates as well as how iteration process should be processed by means of parallelization to use the multicore processors. During the problem searching GPdotNET records the history, so you can see when the best solution is found, how much time pass since the last iteration process start, or how much time is remaining to finish currently running iteration process.

Due to the fact that GP is the method which requires lot of processing time, GPdotNET provides parallelization, which speed up the process of searching. Enabling or disabling the parallelization processing is just a click of the button.

GPdotNET Start Page

In case you have no data or just want to test the application, GPdotNET providers 15 data samples for demo purposes. All samples are grouped in problems specific groups: Approximation and Regressions, Binary Classification, Multi-class classification, Time series modelling and Linear Programming.

Figure 10. Modelling layout in GPdotNET

By click on appropriate link sample can be opened to see current result and parameter values. You can easily change parameter, press Run button and search for another solution. This is very handy to introduce with GPdotNET. In any time, you can stop searching and export current model or save current state of the program.

Final note: The project is licensed under GNU Library General Public License (LGPL). For information about license and other kind of copyright e.g. using the application in commercial purpose please see http://github.com/bhrnjica/gpdotnet/blob/master/license.md.

In case you need to cite it in scientific paper or book please refer to  https://wordpress.com/post/bhrnjica.net/5995

GPdotNET v4.0 Beta 2 released


Download GPdotNET v4 beta2

The last few days I am preparing the new build for publishing of GPdotNET v4.0 which will include lot of new features. In the last post I have announced ANN modul and compleately new modul for preparing tha data for modelling. Here is a quick overview of the new features comming in this build:

  1. Since this build the GP modul is also integrated with the new way of data preparation. Now with the latest version of GPdotNET the user will have the same user  experience in modelling with GP and ANN.
  2. The big news for this build is ability for modelling classification problems (two-class as well ) with Genetic programming. Multy -classs GP solver will be released soon.
  3. Separation of the previous and new version. Both are included in the latest build.
  4. Disable protected operations.

 

As picture shows below you can choose models from prevous version on the left side. On the right side of the new model dialog, you can select modeling and prediction with ANN or GP.

GPdotNET v4.0 Beta 2

After you select the solver GPdotNET is ready to accept the data.

GPdotNET v4.0 Beta 2 02

From the previous blog post you can see more info about loading and handling data.  The same user experimence you can see regadles of the solver type (ANN or GP).

Beside this GP integration there are several bug fix which were reported from the users.

In GP solver the new feature has been added: Ability to disable protected operations. In the previuous version of GPdotNET protected operations (eg. /, log, ln, etc) are enabled in the model. Whenever operation was undefined for the current value. GPdotNET returned default value (0 or 1). So with protected operation the model is always defined. With protected operations we collect much good genetic material dufirng evolution. In case the option is disable any upprotected operation can discar the model. This option is available in new and previous GP solver.

GPdotNET v4.0 Beta 2 03

Features not implemented in this beta

1. Exporting GP/ANN model

2. Open/Save gpa file for new Solvers.

GPdotNET v4.0- Introduction


This is the first post in series of posts that describe upcomming version of GPdotNET v4.0. Besides lot of improvements of the current version, the main part isimplementation of neural networks and set of other optimization methods of machine learning.

1. Modelling with GPdotNET v4.0

GPdotNET Logo

GPdotNET Logo

GPdotNET is C#, open source artificial intelligence tool for applying Genetic Algorithm and Artificial Neural Networks in modeling, prediction, optimization and pattern recognitions. With GPdotNET you can solve various engineering problems from classic regression and approximation to linear programming transportation and location problems and other machine learning based problems. By providing the learning algorithms GPdotNET uses a data of the research or experimental measures to learn about the problem. The results of learning algorithms are analytical models which can describe or predict the state of the problem, or can recognize the pattern. GPdotNET is very easy to use, even if you have no deep knowledge of GA, GP or ANN, you can apply those methods in finding solutions. The project can be used in modeling any kind of engineering process, which can be described with discrete data, as well as in education during teaching students about evolutionary methods, mainly GP and GA, as well as machine learning mainly Artificial Neural Networks.
The typical process of modelling with GPdotNET can be described in 5 steps.

  1. Choosing the type of the Solver: The first step is choosing the type of the solver. Which solver you will use depends on your intention what you want to do. For example if you want to make model for your experimental measurement you have several options which depend of your experimental data and the method you want to use. In GPdotNET you can use Genetic Programming or Neural Nets for modelling and prediction experimental data. But this is not strictly separate as may look on the flowchart below. That means that you can user Neural Networks for prediction, but training algorithm can be based on  Genetic Algorithm or Particle Swarm Optimization or Back Propagation algorithm.
  2. Loading your experimental data: GPdotNET uses powerful tool for importing your experimental data regardless of the type of data. You can import your numerical, binary or classification data. GPdotNET can automatically define classes, or format numerical data with floating or comma separated decimal values. More info can be find in Section 2.
  3. Setting Learning Parameters. After data is loaded and prepared successfully, you have to set parameters for the selected method. GPdotNET providers various parameters for each method, so you can set parameters which can provides and generates best output model.
  4. Searching for the solution: GPdotNET provides visualization of the searching solution so you can visually monitor how GPdotNET finds better solution as increasing the iteration number. If you provide data for testing calculated model, you can also see simulation of prediction.
  5. Saving and exporting the results: GPdotNET provides several options you can choose while exporting your solution. You can export your solution in Excel or text file, as well as in Wolfram Mathematica or R programming languages.

As would be seen, working in GPdotNET follows the same procedures regardless of the problem type. That means you have the same set of steps when modelling with Genetic Programming or Neural Networks. In fact GPdotNET contains the same set of input dialogs when you try to solve Traveling Salesman Problem with Genetic Algorithm or if you try to solve handwriting recognition by using Backpropagation Neural Networks. All learning algorithms within GPdotNET share the same UI.

The picture below shows the flowchart of the modelling in GPdotNET. The five steps described previously are depicted in the graphical forms surrounded with Start and Stop elements.

Modeling in GPdotNET v4.0

Modeling in GPdotNET v4.0

Besides parameters specific to learning algorithm, GPdotNET provides set of parameters which control the way of how iteration process should terminates as well as how iteration process should be processed by means of parallelization to use the multicore processors. During the problem searching GPdotNET records the history, so you can see when the best solution is found, how much time pass since last iteration process started, or how much time is remain to finish currently running iteration process.
Due to the fact that GP is the method which requires lot of processing time, GPdotNET provides parallelization, which speed up the process of searching. Enabling or disabling the parallelization processing is just a click of the button.

1.1 GPdotNET Open source project

From developer point of view GPdotNET is .NET (Mono) application written in C# programming language which can run both on Windows and Linux based OS, or any OS which supports Mono framework. Project started in 2006 within postgraduate study for modeling and optimization with evolutionary algorithms. As open source project, GPdotNET is first published on November 5 2009 on codeplex.com. The project is licensed under GNU Library General Public License (LGPL). For information about license and other kind of copyright please see http://gpdotnet.codeplex.com/license. The project is hosted at http://gpdotnet.codeplex.com. Main place for all news, documentation and code changes is my blog site at https://bhrnjica.wordpress.com/gpdotnet.

1.2 How to citate GPdotNET

GPdotNET is used from all around the world, in scientific papers, journals, books, for diploma works, master thesis or Dissertations. It is free to use GPdotNET with proper citation. So if you want to use the GPdotNET you need the right way to citate the tool.

Use this citation example in your paper, book etc.:

[1] B. I. Hrnjica, GPdotNET V4.0- artificial intelligence tool [Computer program], http://gpdotnet.codeplex.com, accessed {date}.

Or

[1] Bahrudin I. Hrnjica, GPdotNET V4.0 – artificial intelligence tool [Computer program], http://gpdotnet.codeplex.com, accessed {date}.

Announcing Neural Networks in GPdotNET


gpdotnet_ann1

Last few months I was playing with Artificial Neural Network (ANN) and how to implement it in to the GPdotNET. ANN is one of the most popular methods in Machine Learning, specially Back Propagation algorithm. First of all, the Artificial Neural Network is more complex than Genetic Algorithm, and you need to dive deeper in to math and other related fields in order to understand some of the core concept of the ANN. But likely there are tons of fantastic learning sources about ANN. Here is my recommendation of ANN learning sources:

First of all there are several MSDN Magazine articles about ANN and how to implement it in C#.

1. Dive into Neural Networks

2. Classification and Prediction Using Neural Networks

3. Neural Network Back-Propagation for Programmers

If you want to know what’s behind the scene of ANN, read this fantastic online book with great animations of how neuron and neural networks work.

1. Neural Networks and Deep Learning,  by Michael Nielsen.

There is a series you tube video about ANN.

1. Neural Networks Demystified [Part 1: Data and Architecture]

Open source libraries about ANN in C#:

1.  AForge.NET. – Computer Vision, Artificial Intelligence, Robotics.

2. numl – Common Machine Learning Algorithms by Seth Juarez

The first GPdotNET v4.0 beta will be out very soon.

Alati za analizu rezultata eksperimentalnog istraživanja


Bilo da pišete neki naučni rad, magistarsku ili doktorsku tezu, u prilici ste da baratate sa rezultatima vašeg istraživanja, koji su većinom u diskretnom obliku. Diskretni oblik rezultata istraživanja prvenstveno je dat u tabelarnom obliku pri kojem postoji nekoliko ulaznih parametara  te jedna ili više izlaznih varijabli.
Pretpostavimo da ste vršili određeno mjerenje, npr. silu rezanja, a da ste pri tom varirali dijametar alata i posmak. U tom slučaju rezultat vašeg mjerenja može biti tabela slična prikazanoj:

RB          s[mm/o]          d[mm]          F[ N]
---------------------------------------------------
 1           0,25              8            318,8
 2           0,35              8            437
 3           0,25             14            450
 4           0,35             14            530,3
 5           0,3              11            445,6
 6           0,3              11            467
 7           0,3              11            475,5
 8           0,3              11            456,8
 9           0,3              11            469
10           0,38             11            480,8
11           0,23             11            399
12           0,3              16            588,2
13           0,3               7            320
----------------------------------------------------

Po meni najbolji alat za modeliranje podataka datih u diskretnom obliku jeste Wolframova Mathematica. Da bi dobili regresijske modele pomoću Mathematica potrebno je eksperimentalne podatke pripremiti, odnosno definisati varijablu eksperiment sa vrijednostima iz tabele.Od eksperimentalnih rezultata prikazanih tabelom ptrebno je izvršiti regresijsku analizu i definisati matematički model, odnosno funkcionalnu zavisnos dijametra, posmaka od sile bušenja.

Izvorni kod prikazan na narednom listingu predstavlja jedan od načina kako prikazati podatke preko varijable, a koja predstavlja listu eksperimentalnih podataka.

</p>

<pre>eksperiment={{0.25,8,318.8},{0.35,8,437},{0.25,14,450},{0.35,14,530.3},{0.3,11,445.6},{0.3,11,467},{0.3,11,475.5},{0.3,11,456.8},{0.3,11,469},{0.38,11,480.8},{0.23,11,399},{0.3,16,588.2},{0.3,7,320}}

Sada kada imamo varijablu, vrlo je jednostavno dobiti matematičke modele. Varijabla predstvalja 2D polje koje se sastoji of vrsta i kolona naše polazne tabele.

Na primjer da bi dobili regresijski model drugog stepena sa linearnom međuzavisnosti među članovima potrebno je izvršiti komandu:

rModel2=Fit[eksperiment,{1,x,x^2, y,y^2,x*y},{x,y}]

Gornjom komandom Mathematika će metodom najmanjih kvadrata odrediti kvadratni model. Kako se može vidjeti Fit komanda, kao jedan od argumenata, uzima i šemu modela. Šema modela predstavlja članove polinoma koji će se naći u matematičkom modelu. Nakon izvršavanja ove dvije komande Mathematica je vratila matematički model naglašen crvenim pravougaonikom:

mepslika1

Naravno Fit komanda uzima bilo koju kombinaciju faktora i bilo koji stepen polinoma, tako da se čitaocu ostavlja da sam istraži i ostale modele. Npr. vrlo je interesantno da se odredi regresijski model 3-ćeg stepena, sa linearnom i kvadratnom međuzavisnošću ulaznih parametara.

Još zgodnije izgleda kada se dobijeni regresijski model može prikazati grafički izvršavajući slijedeću komandu:

mepslika2

Vidjeli smo kako na jednostavan način mogu dobiti regresijski modeli od diskretnog skupa podataka koji može predstavljati vaše eksperimentalno istraživanje. Naravno sve ovo se može uraditi i u Microsoft Excelu samo sa malo više muke.

Modeliranje podataka metodom genetskog programiranja

Modelirati se mogu podaci i preko evolucijske metode genetsko programiranje preko koje se mogu dobiti vrlo kvalitetni modeli koji mogu biti dosta precizniji od regresijskih modela. Prednost evolucijskih modela (modela koji se dobiju nekom od evolucijkih metoda) jeste ta da oni ne zavise od stepena polinoma, niti od zavisnosti među ulaznim parametrima. Na ovaj način prirodnim putem se generiraju modeli, kao i međuzavisnost između ulaznih parametara. Jedan od alata koji koristi metodu genetsko programiranje za modeliranje rezultata eksperimenta je GPdotNET, koji na vrlo jednostavan i intuitivan način koristi metodu genetskog programirnaja pri izgradnji matematičkih modela. Više informacije o GPdotNET mozete pronaći na https://bhrnjica.net/GPdotNET.

Da bi rezultate eksperimenta prezentiane na gornjoj tabeli učitali u GPdotNET potrebno je formirati csv datoteku kojom ćemo definisati skup podataka za treniranje.

– Otvorite Notepad i kopirajte slijedeći tekst te sačuvajte datoteku pod naslovom SkupZaTreniranje.csv.

!s[mm/o]         d[mm]         F[ N]
!---------------------------------------------------
0.25;8;318.8
0.35;8;437
0.25;14;450
0.35;14;530.3
0.3;11;445.6
0.3;11;467
0.3;11;475.5
0.3;11;456.8
0.3;11;469
0.38;11;480.8
0.23;11;399
0.3;16;588.2
0.3;7;320

Primjetite da su kolone odvojene sa ‘;’ (tačka zarez), a kolone novim redom. Također važno je imati na umu da su decimalne cifre odvojene tačkom umjesto zarezom, te da ispred vrste koja predstavlja neki tekst, naziv kolone ili dr. mora biti stavljan zna !, odnosno da se označi kao linija koja se ne procesuira.

Kada imamo ovakvu datoteku sada možemo učitati podatke u GPdotNET.

1. Pokrenimo GPdotNET i odaberimo New komandu. Pojavljuje nam se dijalog za odabir vrste modela koju želimo odrediti. Ostavite početne vrijednosti i pritisnite dugme OK.

mepslika3

2. Sada iz Load Data taba pritisnemo dugme “Training Data” izaberemo datoteku koju smo prethodno formirali i pritisnemo dugme OK.

mepslika4

3. U trećem koraku podešavamo parametre GP. Parametre je potrebno podesiti kako je prikazano na donjoj slici.

mepslika6

4. Sada nam samo ostaje da pokrenemo simulaciju traženja rješenja klikom na komandu RUN.

5. Kada smo dobili model koji nam odgovara preko “Result” taba možemo vidjeti oblik dobijenog modela, a preko Export komandi mozemo vršiti daljnju analizu rezultata.

mepslika7

Vidjeli smo kako vrlo jednostavno i efektivno možemo modeliati naše rezultate eksperimentalnih istraživanja bez suvišnog gubljenja vremena i podešavanja. Također, vidjeli smo kako sa GPdotNET možemo dobijati vrlo precizne matematičke modele dobijene metodom genetsko progamirnaje.