Category Archives: C#

GPdotNET v4.0 Beta 3 has been released


This is the third beta version of the GPdotNET v4.0 which brings new features and continuation of the new set of solvers. Beta 3 introduce Genetic Programming Multi-class Solver (GPMCS).

The latest version of the project can be found at http://github.com/bhrnjica/gpdotnet.

As announced in Beta 1 and Beta 2 there are new set of solvers. Beta 3 finally brings GP Multi-class solver, and announced feature complete of the GPdotNET v4.0.

Here is a quick recap of all new features announced in the last three beta versions:

1. New Start Page will be extended with new examples of Neural Nets : – binary classification, – multi-class classification and – regressions examples.

2. Improved module for loading experimental data, which now supports non numeric data like categorical or binary data. New data module also support normalization of the experimental data, handling missing values.

3. Introduction of the ANN solver for all three kind of problems:

  • regression
  • binary
  • multi-class

4. Depending of the output column of loaded experimental data, different learning solver can be selected.

5. Introduction of the GP Binary class solver.

6. Introduction of the GP Multi-Class solver. In the flowing text you can see few screen shots:

Picture below shows loaded “iris flower data set” in to the GP multi-class solver.

gp_multyclass_sl0

The picture below shows GP Multi-class solver in action. As can be seen best solution is found at 242 iteration, with very high value of the fitness value.

gp_multyclass_sl2

Even better the prediction page shows how best chromosome predict iris value. As can be seen best solution predicts 13 rows correctly, and only 2 row are calculated wrong.

gp_multyclass_sl1

The last picture shows the Best Chromosome (solution) for the Iris Flows Data Set :

gp_multyclass_sl3

GPdotNET project has been moved to GitHub


Since now the GPdotNET project is located at http://github.com/bhrnjica/gpdotnet.

gp_multyclass_sl00

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.

Objektno Orjentisano Programiranje- treći dio


Polimorfizam (en. Polymorfism)

Polimorfizam predstavlja najsofisticiraniju osobinu OOP pri kojoj jedan objekat može ispoljavati različite osobine. Naime, pored standarnih funkcja koje se mogu definisati u klasi, OOP koncept dozvoljava da se definišu virtuelne metode. Virtuelne metode se implementiraju na potpuno isti način kao i regularne samo što u svojoj deklaraciji imaju prefiks virtual. Kada se metoda deklariše kao virtualna, polimorfizam dolazi do izražaja samo u slučaju kada se definišu klase koje su izvedene iz bazne klase.
U izvedenim klasama virtuelne metode se mogu “preklopiti” (en. override) tako da imaju potpuno drugačiju implementaciju od one koja se nalazi i baznoj klasi. Na taj način jedan objekat tipa bazne klase može imati dvije različite osobine pri pozivu jedne te iste metode u zavisnosti od toga na koji način je objekat instanciran. Polimorfizam predstavlja jedan od najvažnijih i najznačajnijih fenomena OOP i treba ga koristiti kad god za to postoji potreba.
Virtualne metode se u izvedenim klasama mogu ali i ne moraju deklarisati sa ključnom riječju virtual. Međutim, kod nekih programskih jezika poput C# potrebno je dodati ključnu riječ overide. Virtuelne metode osim u ključnoj riječi za programera nemaju posebnih implementacijskih zahtjeva. Osim što u slučaju kada programiramo sa C++, moramo voditi računa da polimorfizam radi samo u slučaju pointera na objekte. Dakle u koliko instanciramo objekat na stack memoriji ne pokreće se virtuelni mehanizam i nemamo polimorfizam. Razlog zašto polimorfizam radi samo ako su u pitanju pointeri i heap memorija je jednostavan u koliko se poznaje priroda nastanka C++ jezika. Kako je C++ jezik izrastao iz C jezika, koji ima statičnu veličinu za svaki formirani objekat na staku, otud dolazi razlog da se virtualne metode nemogu mijenjati na tako statički definisanom objektu. Međutim u koliko se objekat klase instancira na heap dinamičkoj memoriji, tabela sa virtuelnim metodama se povezuje se i vrši prepoznavanje metoda poziva u vrijeme izvršavanja.
Kako rade virtualne metode može se objasniti na slijedeći način: Prilikom kompajliranja formira se tabela u koju se smještaju virtulne metode iz bazne i svih izvedenih klasa. Prilikom poziva interpreter pretražuje virtualnu tabelu sa listom virtuelnih metoda te poziva onu virtuelnu metodu iz one klase iz koje je objekat instanciran.
Kada govorimo o instanciranju objekata u slučaju bazne i izvedene klase možemo imati sljedeće slučajeve:
1. Objekat tipa bazne klase instanciran sa baznom klasom.
2. Objekat tipa bazne klase instanciran da izvedenom klasom.
3. Objekat tipa izvedene klase instanciran sa izvedenom klasom.
Kada objekat pozove virtuelnu metodu možemo dobiti slijedeće slučajeve shodno gore instanciranim varijantama objekta:
1. Izvršava svirtualna metoda iz bazne klase.
2. Izvršava se metoda iz izvedene klase.
3. Izvrsava se metoda iz izvedene klase.
U drugom slučaju imamo pojavu polimorfizma, dok se u prvom i trećem slučaju radi o standardnom pozivu metode. Sljedeći listing prikazuje naš primjer poziva metode Status iz bazne klase Osoba i izvedene klase Student.

//glavna ulazna funkcija
int main()
{  

	Osoba* os1 = new Osoba();
	Osoba* os2 = new Student();
	Student* os4 = new Student();  

	cout << "Osoba.Status(Osoba) vraća: " << os1->Status().c_str() << endl;
	cout << "Osoba.Status(Student) vraća: " << os2->Status().c_str() << endl;
	cout << "Student.Status(Student) vraća: " << os4->Status().c_str() << endl;  

	system("Pause");
	return 0;
}

Vidimo da u drugom slučaju kada imamo bazni tip Osoba koja je instancirana preko izvedenog tipa Student, pojavu polimorfizma. Istu situaciju bi imali u koliko bi pokrenuli C# verziju napisanog programa. Izlaz ovog programa dat je na narednoj slici:

Osoba.Status(Osoba) vraća: Osoba
 Osoba.Status(Student) vraća: Student
 Osoba.Status(Student) vraća: Student
 -------------------------------------------
 Press any key to continue...