<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Bahrudin Hrnjica Blog</title>
	<atom:link href="http://bhrnjica.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://bhrnjica.net</link>
	<description>C#, C++, Math, Evolutionary Algorithms, Engineering, ...</description>
	<lastBuildDate>Tue, 21 May 2013 19:38:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bhrnjica.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/f47afefa350870cfd31c7a7fab9c110e?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Bahrudin Hrnjica Blog</title>
		<link>http://bhrnjica.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bhrnjica.net/osd.xml" title="Bahrudin Hrnjica Blog" />
	<atom:link rel='hub' href='http://bhrnjica.net/?pushpress=hub'/>
		<item>
		<title>GPdotNET vNext: Assignment and Transportation problems</title>
		<link>http://bhrnjica.net/2013/05/10/gpdotnet-vnext-assignment-and-transportation-problems/</link>
		<comments>http://bhrnjica.net/2013/05/10/gpdotnet-vnext-assignment-and-transportation-problems/#comments</comments>
		<pubDate>Fri, 10 May 2013 06:17:03 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GPdotNET]]></category>
		<category><![CDATA[GA]]></category>
		<category><![CDATA[Genetic Algorithm]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5404</guid>
		<description><![CDATA[Recently I wrote blog post  about implementation of TSP problem in GPdotNET. I got positive feedback about implementation, but there were people saying if can I implement more problems based on linear programming and optimization. So I have decided to implement Assignment and Transportation problems in GPdotNET. With existing 4,  the next version of GPdotNET [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5404&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div id="attachment_5027" class="wp-caption alignnone" style="width: 310px"><a href="http://bhrnjica.files.wordpress.com/2009/11/gplogo_350x134pix.png"><img class="size-medium wp-image-5027" alt="GPdotNET Logo" src="http://bhrnjica.files.wordpress.com/2009/11/gplogo_350x134pix.png?w=300&#038;h=113" width="300" height="113" /></a><p class="wp-caption-text">GPdotNET vNext</p></div>
<p style="text-align:justify;">Recently I wrote blog post  about implementation of TSP problem in GPdotNET. I got positive feedback about implementation, but there were people saying if can I implement more problems based on linear programming and optimization. So I have decided to implement Assignment and Transportation problems in GPdotNET. With existing 4,  the next version of GPdotNET 2.5 will contains in total the following problem domains:</p>
<p style="text-align:justify;">1. Modelling discrete data set with GP,</p>
<p style="text-align:justify;">2. Modelling and optimization discrete data set with combination of GP and GA,</p>
<p style="text-align:justify;">3. Modelling Time series data set with GP,</p>
<p style="text-align:justify;">4. Optimization of Analytic function with GA,</p>
<p style="text-align:justify;">5. Traveling Salesman Problem with GA,</p>
<p style="text-align:justify;">6. Assignment Problem with GA,</p>
<p style="text-align:justify;">7. Transportation problem with GA.</p>
<p style="text-align:justify;">In order to implement those problems it has to be implemented two new chromosome types:</p>
<p style="text-align:justify;">1. Vector based GA chromosome for solving TSP and Assigment problem</p>
<p style="text-align:justify;">2. Matrix based GA chromosome for solving Transport problem.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/gpdotnetvnext.png"><img class="alignnone size-medium wp-image-5409" alt="gpdotnetvnext" src="http://bhrnjica.files.wordpress.com/2013/04/gpdotnetvnext.png?w=300&#038;h=189" width="300" height="189" /></a></p>
<p style="text-align:justify;">The first one (vector based chromosome type) is already implemented and needs to be modified for accepting different format data, in order to fully support TSP and Assignment problems at the same time. For second type there are several solutions for implementation for Matrix based chromosome, one of my favorite is published in the book <a href="http://books.google.ba/books?id=vlhLAobsK68C&amp;printsec=frontcover&amp;source=gbs_ge_summary_r&amp;cad=0">&#8220;Genetic Algorithms + Data Structures = Evolution Programs&#8221;</a>.</p>
<p style="text-align:justify;">I can say this would be an exciting summer. :)</p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/gpdotnet/'>GPdotNET</a> Tagged: <a href='http://bhrnjica.net/tag/net/'>.NET</a>, <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/ga/'>GA</a>, <a href='http://bhrnjica.net/tag/genetic-algorithm/'>Genetic Algorithm</a>, <a href='http://bhrnjica.net/tag/gpdotnet/'>GPdotNET</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5404/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5404/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5404&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/05/10/gpdotnet-vnext-assignment-and-transportation-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2009/11/gplogo_350x134pix.png?w=300" medium="image">
			<media:title type="html">GPdotNET Logo</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/gpdotnetvnext.png?w=300" medium="image">
			<media:title type="html">gpdotnetvnext</media:title>
		</media:content>
	</item>
		<item>
		<title>WinDays13 &#8211; kratki utisci, pptx datoteka i demo primjeri</title>
		<link>http://bhrnjica.net/2013/04/24/windays13-kratki-utisci-pptx-i-demo-primjeri/</link>
		<comments>http://bhrnjica.net/2013/04/24/windays13-kratki-utisci-pptx-i-demo-primjeri/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 08:19:37 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[WP8]]></category>
		<category><![CDATA[windays]]></category>
		<category><![CDATA[WInRT]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5382</guid>
		<description><![CDATA[Još uvijek traje jedna od najvecih Microsoft konferencija u regionu, i nakon dva dana konferencije mogu reći da su ovi WinDaysi do sada najbolje organizirana konferencija. Preko 1000 registrovanih polaznika i stotinjak predavača samo su neke od statističkih brojki ove konferencije. Da je ovo prava developerska konferencija između ostalog možemo se uvjeriti na dobroj posjećenosti dev [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5382&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Još uvijek traje jedna od najvecih Microsoft konferencija u regionu, i nakon dva dana konferencije mogu reći da su ovi <a href="http://windays.hr">WinDaysi </a>do sada najbolje organizirana konferencija. Preko 1000 registrovanih polaznika i stotinjak predavača samo su neke od statističkih brojki ove konferencije.</p>
<p>Da je ovo prava developerska konferencija između ostalog možemo se uvjeriti na dobroj posjećenosti dev predavanja. Prvog dana konferencije najzanimljiviji dijelovi možemo kazati da su bili ITPro i Dev keynote , a posebno je interesantnan bio keynote od <a href="http://developers.de/blogs/damir_dobric/default.aspx">Damir Dobrića</a> koji je zbog štrajka radnika avio-kompanije, javljanje održao preko Skypea sa ljubljnskog aerodroma. Drugog dana nastavilo se u dobrom raspoloženju, a sada već tradicionalna večera predavača desila se u restoranu nedalok od konferencije u pravom istarskom stilu.</p>
<p>Drugog dana konferencije održao sam predavanje na temu MVVM u razvoju WP8 i Windos store aplikacija, i sa zadovoljstvo mogu reći da je proteklo u dobroj atmosferi sa prepunom salom. Kao što sam najavio prethodno moje predavanje oko MVVM tehnike na WP8 i WinRT bilo je drugog dana konferencije. Ovim pute se zahvaljujem svim posjetiocima predavanja i kao što sa obećao demo primjere i prezentacijku datoteku objavljujem na kraju posta.<br />
<iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129078&#038;authkey=ADKpwTRa6kTa-fU&#038;em=2" width="402" height="327" frameborder="0" scrolling="no"></iframe></p>
<iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129077&#038;authkey=AKMG2kX8lvUCdow" width="98" height="120" frameborder="0" scrolling="no"></iframe>
<iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129076&#038;authkey=ADeDh5WRfLjZ8yA" width="98" height="120" frameborder="0" scrolling="no"></iframe>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130424_095628.jpg"><img class="alignnone size-medium wp-image-5393" alt="20130424_095628" src="http://bhrnjica.files.wordpress.com/2013/04/20130424_095628.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130424_100501.jpg"><img class="alignnone size-medium wp-image-5394" alt="20130424_100501" src="http://bhrnjica.files.wordpress.com/2013/04/20130424_100501.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130424_094223.jpg"><img class="alignnone size-medium wp-image-5392" alt="20130424_094223" src="http://bhrnjica.files.wordpress.com/2013/04/20130424_094223.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130423_192036.jpg"><img class="alignnone size-medium wp-image-5391" alt="20130423_192036" src="http://bhrnjica.files.wordpress.com/2013/04/20130423_192036.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130422_214523.jpg"><img class="alignnone size-medium wp-image-5390" alt="20130422_214523" src="http://bhrnjica.files.wordpress.com/2013/04/20130422_214523.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130422_191850.jpg"><img class="alignnone size-medium wp-image-5389" alt="20130422_191850" src="http://bhrnjica.files.wordpress.com/2013/04/20130422_191850.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130422_191736.jpg"><img class="alignnone size-medium wp-image-5388" alt="20130422_191736" src="http://bhrnjica.files.wordpress.com/2013/04/20130422_191736.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/04/20130422_165302.jpg"><img class="alignnone size-medium wp-image-5387" alt="20130422_165302" src="http://bhrnjica.files.wordpress.com/2013/04/20130422_165302.jpg?w=300&#038;h=225" width="300" height="225" /></a></p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/windows-8/'>Windows 8</a>, <a href='http://bhrnjica.net/category/wp8/'>WP8</a> Tagged: <a href='http://bhrnjica.net/tag/windays/'>windays</a>, <a href='http://bhrnjica.net/tag/windows-8/'>Windows 8</a>, <a href='http://bhrnjica.net/tag/winrt/'>WInRT</a>, <a href='http://bhrnjica.net/tag/wp8/'>WP8</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5382/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5382/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5382&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/04/24/windays13-kratki-utisci-pptx-i-demo-primjeri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130424_095628.jpg?w=300" medium="image">
			<media:title type="html">20130424_095628</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130424_100501.jpg?w=300" medium="image">
			<media:title type="html">20130424_100501</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130424_094223.jpg?w=300" medium="image">
			<media:title type="html">20130424_094223</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130423_192036.jpg?w=300" medium="image">
			<media:title type="html">20130423_192036</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130422_214523.jpg?w=300" medium="image">
			<media:title type="html">20130422_214523</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130422_191850.jpg?w=300" medium="image">
			<media:title type="html">20130422_191850</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130422_191736.jpg?w=300" medium="image">
			<media:title type="html">20130422_191736</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/20130422_165302.jpg?w=300" medium="image">
			<media:title type="html">20130422_165302</media:title>
		</media:content>
	</item>
		<item>
		<title>WinDays 13: Ćevap Explorer u MVVM sosu, prepečen na WP8 i Windows Store platformama</title>
		<link>http://bhrnjica.net/2013/04/08/windays-13-cevap-explorer-u-mvvm-sosu-prepecen-na-wp8-i-windows-store-platformama/</link>
		<comments>http://bhrnjica.net/2013/04/08/windays-13-cevap-explorer-u-mvvm-sosu-prepecen-na-wp8-i-windows-store-platformama/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 19:20:11 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[WInRT]]></category>
		<category><![CDATA[WP8]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5376</guid>
		<description><![CDATA[Ove godine održava se 13.-ta po redu Microsoft konferencija WinDays. Ovo je, slobodno možemo reći najznačajnija i najveća Microsoft konferencija na Balkanu, kao po broju posjetilaca tako i po sadržaju i organizaciji. Po drugi put u zadnje dvije godine  pripala mi je čast da učestvujem kao predavač, te da svojim predavanjem doprinesem realizaciji ove konferencije. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5376&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://bhrnjica.files.wordpress.com/2013/04/windays13logo.png"><img class="alignnone size-medium wp-image-5379" alt="windays13logo" src="http://bhrnjica.files.wordpress.com/2013/04/windays13logo.png?w=300&#038;h=72" width="300" height="72" /></a></p>
<p>Ove godine održava se 13.-ta po redu Microsoft konferencija WinDays. Ovo je, slobodno možemo reći najznačajnija i najveća Microsoft konferencija na Balkanu, kao po broju posjetilaca tako i po sadržaju i organizaciji. Po drugi put u zadnje dvije godine  pripala mi je čast da učestvujem kao predavač, te da svojim predavanjem doprinesem realizaciji ove konferencije. Ovaj put moje predavanje biće vezano za MVVM tehniku programiranja i kao se ona uklapa u nove platforme Windows RT i Windows Phone 8. Naravno, pored kraćih teorijskih dijelova predavanje će obilovati Demo primjerima. Sada već popularna Windows Store aplikacija <strong>Ćevap EXPLORER</strong> specijalno je refaktorisana i implementirana u MVVM tehnici za WinRT in Windows Phone 8. Slobodno možemo reći da će cijelo predavanje mirisati na ćevape i pečenu jenjetinu. U narednom tekstu možete pogledati opis i ostale informacije oko predavanja.</p>
<p>Naslov: <strong>MVVM u razvoju WP8 i Windows Store aplikacija</strong></p>
<p>Level: 300</p>
<p>Opis:</p>
<p><em>Pojavom XAML programskog jezika za razvoj korisničkih interfacea u Windows Presentation Foundation, a malo kasnije i u Silverlightu, nametalo je potrebu modifikacije MVC tehnike, koja se morala prilagoditi novim postavkama ovog programskog/markup jezika. Kao rezultat prilagođavanja MVC tehnike na XAML, dobijena je nova tehnika programiranja koja definiše jedan Model, jedan View, a kao interakciju između ova dva sloja: sloj jednostavno nazvan ViewModel. Po konceptu vrlo sličan MVC-u, MVVM tehnika se idealno uklapa u koncepciju razvoja klijentskih aplikacija kobinacijom XAML i C# programskog jezika. Ovo predavanje će kroz demo primjere prikazati na koji način se mogu razvijati WP8 odnosno Windows Store aplikacije koristeći MVVM tehniku. Pored prestavljanja osnovnih pojmova ove tehnike (Model, View i ViewModel) predavanje će i prikazati načine komunikacije izmedju View i ViewMode koristenjem Commands i Behaviours, odnosno povratne komunikacije preko Messages. Pored mnogih prednosti korištenja ove tehnike, dijeljenje izvornog koda između WP8 i WinRT predstavlja scenario mnogih današnjih aplikacijiskih rješenja. U ovom predavanju će se također pokazati, kroz demo primjere, na koji način zajedničke implementacije podijeliti između iste aplikacije razvijane za dvije platforme WP8 i WinRT. </em></p>
<p>Predavanje koje sam predstavio održaće se <span style="color:#ff0000;"><strong>utorak 23. aprila u vremenu od 14:00 &#8211; 14:45 u dvorani Coral 3.</strong></span></p>
<p>Vidimo se na Windaysima.</p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/windows-8/'>Windows 8</a> Tagged: <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/mvvm/'>MVVM</a>, <a href='http://bhrnjica.net/tag/winrt/'>WInRT</a>, <a href='http://bhrnjica.net/tag/wp8/'>WP8</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5376/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5376/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5376&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/04/08/windays-13-cevap-explorer-u-mvvm-sosu-prepecen-na-wp8-i-windows-store-platformama/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/04/windays13logo.png?w=300" medium="image">
			<media:title type="html">windays13logo</media:title>
		</media:content>
	</item>
		<item>
		<title>MSNetwork 3: Paralelno i asinhrono programirnje primjeri i prezentacijska datoteka</title>
		<link>http://bhrnjica.net/2013/04/04/msnetwork-3-paralelno-i-asinhrono-programirnje-primjeri-i-prezentacijska-datoteka/</link>
		<comments>http://bhrnjica.net/2013/04/04/msnetwork-3-paralelno-i-asinhrono-programirnje-primjeri-i-prezentacijska-datoteka/#comments</comments>
		<pubDate>Thu, 04 Apr 2013 09:45:28 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programiranje]]></category>
		<category><![CDATA[Windows 8]]></category>
		<category><![CDATA[.NET4.5]]></category>
		<category><![CDATA[async]]></category>
		<category><![CDATA[MSNetwork]]></category>
		<category><![CDATA[Parallelfx]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5344</guid>
		<description><![CDATA[U ovom postu pobrojani su svi demo primjeri  sa kratkim objašnjenjem koje sam na MSNetwrok 3 predavanju demonstrirao. Ovo ujedno i predstavlja moje aktivnosti zadnjih nekoliko godina vezanih oko ove teme. Tačno prije 5 godina odnosno u aprilu 2008 godine (22. aprila 2008.) napisao sam prvi članak oko paralelnog programiranja, dok je 5 mjeseci ranije [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5344&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://bhrnjica.files.wordpress.com/2013/03/msnetwork.png"><img class="alignnone size-full wp-image-5291" alt="msnetwork" src="http://bhrnjica.files.wordpress.com/2013/03/msnetwork.png?w=604"   /></a></p>
<p>U ovom postu pobrojani su svi demo primjeri  sa kratkim objašnjenjem koje sam na MSNetwrok 3 predavanju demonstrirao. Ovo ujedno i predstavlja moje aktivnosti zadnjih nekoliko godina vezanih oko ove teme.</p>
<p>Tačno prije 5 godina odnosno u aprilu 2008 godine (22. aprila 2008.) napisao sam prvi članak oko paralelnog programiranja, dok je 5 mjeseci ranije te godine izbačena prva CTP verzija ParallelFx biblioteke.</p>
<p>Ovim MSNetwork predavanjem želio sam ujedno i da sve to objedinim i da široj javnosti prenesem iskustva iz ovog područja programiranja. Ovaj blog post sadrži izvorni kod za sve demo primjere koji su planirani za ovo predavanje. Moguće je, (jer blog post pišem ranije) da neki od primjera nije demonstriran zbog vremena, pa ovom prilikom ih objavljujem sviju sa kratkim pojašnjenjem.</p>
<p>Ukupno za ovo predavanje planirano je 9 demo primjera i to:</p>
<p>1. Power point prezentacija predavanja.</p>
<iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129032&#038;authkey=AFMyE8vlcuvmd2U&#038;em=2" width="602" height="327" frameborder="0" scrolling="no"></iframe>
<p>2. Demo primjeri sa predavanja</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129024&#038;authkey=ALKsMnSt_wAhN94" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Primjer manipulacije sa objektom Thread, i kako manipulisati u višenitnom okruženju.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129023&#038;authkey=AAb7EdAKzMWlJnc" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Primjer manipulacije sa Task objektom, kao osnovnim konceptom pralelnog i asinhronog programiranja.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129027&#038;authkey=AMQW7AZv6eQv6sw" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Demo sadrzi 5 različitih primjera korištenja for, foeach, parallelLoopState i primjer koordinacije i razmjene podataka izmedju niti.</td>
</tr>
<tr>
<td><!-- Invalid office shortcode URL --></td>
<td>PLINQ primjer koristenja paraleliziranih LINQ upita.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129025&#038;authkey=ALtPTTh2Op0yklo" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Primjer korištenja Partisionera, kojim dijelimo poslove na više taskova.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129029&#038;authkey=ANYd-MzKlDen9Uc" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Primjer koji demonstrira Race Condition fenomen kada dvije niti u isto vrijeme pokusavaju da promjene vrijednost varijable.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129030&#038;authkey=AIeiT5ukoGZEmJ4" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Realni primjer primjene ParallelFx u rjesavanju sistema linearnih jednačina sa 1000 nepoznatih.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129028&#038;authkey=ADN1TJe3cinJBxg" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Primjer asinhronog programiranja na strani klijenta. Kako stari sekvencijalni kod pretvoriti u asinhroni.</td>
</tr>
<tr>
<td><iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2129031&#038;authkey=ABgyLfBCXLIvlT8" width="98" height="120" frameborder="0" scrolling="no"></iframe></td>
<td>Primjer asinhronog programiranja na strani servera. Korištenje asinhronog programiranja u optimizaciji ASP.NET aplikacija i mogućnosti povećavanja performansi i odziva aplikacija.</td>
</tr>
</tbody>
</table>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/programiranje/'>Programiranje</a>, <a href='http://bhrnjica.net/category/windows-8/'>Windows 8</a> Tagged: <a href='http://bhrnjica.net/tag/net4-5/'>.NET4.5</a>, <a href='http://bhrnjica.net/tag/async/'>async</a>, <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/msnetwork/'>MSNetwork</a>, <a href='http://bhrnjica.net/tag/parallelfx/'>Parallelfx</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5344/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5344&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/04/04/msnetwork-3-paralelno-i-asinhrono-programirnje-primjeri-i-prezentacijska-datoteka/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/msnetwork.png" medium="image">
			<media:title type="html">msnetwork</media:title>
		</media:content>
	</item>
		<item>
		<title>Function optimization with Genetic Algorithm by using GPdotNET</title>
		<link>http://bhrnjica.net/2013/03/26/function-optimization-with-genetic-algorithm-by-using-gpdotnet/</link>
		<comments>http://bhrnjica.net/2013/03/26/function-optimization-with-genetic-algorithm-by-using-gpdotnet/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 13:40:15 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[GPdotNET]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Function optimization]]></category>
		<category><![CDATA[Genetic Algorithm]]></category>
		<category><![CDATA[Genetic Programming]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5305</guid>
		<description><![CDATA[Content 1. Introduction 2. Analytic function optimization module in GPdotNET 3. Examples of function optimizations 4. C# Implementation behind GPdotNET Optimization module Introduction GPdotNET is artificial intelligence tool for applying Genetic Programming and Genetic Algorithm in modeling and optimization of various engineering problems. It is .NET (Mono) application written in C# programming language which can run on [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5305&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Content</p>
<p>1. Introduction<br />
2. Analytic function optimization module in GPdotNET<br />
3. Examples of function optimizations<br />
4. C# Implementation behind GPdotNET Optimization module</p>
<p><span style="font-size:2em;">Introduction</span></p>
<p><img class="alignnone" alt="" src="http://bhrnjica.files.wordpress.com/2009/11/gplogo_350x134pix.png?w=350&#038;h=132" width="350" height="132" /></p>
<p style="text-align:justify;">GPdotNET is artificial intelligence tool for applying Genetic Programming and Genetic Algorithm in modeling and optimization of various engineering problems. It is .NET (Mono) application written in C# programming language which can run on both Windows and Linux based OS, or any OS which can run Mono framework. On the other hand GPdotNET is very easy to use. Even if you have no deep knowledge of GP and GA, you can apply those methods in finding solution. The project can be used in modeling any kind of engineering process, which can be described with discrete data. It is also be used in education during teaching students about evolutionary methods, mainly GP and GA. GPdotNET is open source project hosted at <a href="http://gpdotnet.codeplex.com" rel="nofollow">http://gpdotnet.codeplex.com</a></p>
<p style="text-align:justify;">With releasing of  GPdotNET v2 it is also possible to find optimum for any analytic function regardless of independent variables. For example you can find optimum value for an analytically defined function with 2, 5, 10 or 100 independent variables. By using classic methods, function optimization of 3 or more independent variables is very difficult and sometimes impossible. It is also very hard to find optimum value for functions which are relatively complex regardless of number of independent variables.<br />
Because GPdotNET is based on Genetic Algorithm we can find approximated optimum value of any function regardless of the limitation of number of independent variables, or complex definition. This blog post is going to give you a detailed and full description how to use GPdotNET to optimize function. Blog post will also cover C# implementation behind optimization proce by showing representation of Chromosome with real number, as well as Fitness calculation which is based on Genetic Programming tree expression. In this blog post it will also be presented several real world problem of optimization which will be solved with GPdotNET.</p>
<h1 style="text-align:justify;">Analitic Function Optimization Module in GPdotNET</h1>
<p style="text-align:justify;">When GPdotNET is opened you can choose several predefined and calucalted models from various domain problems, as weel as creating New model among other options. By choosing New model new dialog box appears like picture below.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/image1.png"><img class="alignnone size-medium wp-image-5309" alt="image1" src="http://bhrnjica.files.wordpress.com/2013/03/image1.png?w=300&#038;h=191" width="300" height="191" /></a></p>
<p style="text-align:justify;">By choosing <strong>Optimization of Analytic Function</strong> (see pic above) and pressing OK button, GPdotNET prepares model for optimization and opens 3 tab pages:</p>
<ol>
<li style="text-align:justify;">Analytic function,</li>
<li style="text-align:justify;">Settings and</li>
<li style="text-align:justify;">Optimize Model.</li>
</ol>
<h2>Analytic function</h2>
<p style="text-align:justify;">By using “<strong>Analytic function</strong>” tab you can define expression of a function. More information about how to define mathematics expression of analytic function can be found on this <a href="http://bhrnjica.net/2012/10/06/how-to-optimize-analityc-function-in-gpdotnet/">blog post</a>.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/image2.png"><img class="alignnone size-medium wp-image-5310" alt="image2" src="http://bhrnjica.files.wordpress.com/2013/03/image2.png?w=300&#038;h=190" width="300" height="190" /></a></p>
<p style="text-align:justify;">By using “<strong>Analytic definition tool</strong>” at the bottom of the page, it is possible to define analytic expression. Expression tree builder generates function in Genetic Programming Expression tree, because GPdotNET fully implements both methods. Sharing features of Genetic programming  in Optimization based Genetic Algorithm is unique and it is implement only in GPdotNET.</p>
<p style="text-align:justify;">When the process of defining function is finished, press <strong>Finish</strong> button in order to proceed with further actions. Finish button action apply all changes with Optimization Model Tab. So if you have made some changed in function definition, by pressing Finish button changes will be send to optimization tab.<br />
Defining expression of function is relatively simple, but it is still not natural way for defining function, and will be changed in the future. For example on picture 2, you can see Expression tree which represent:</p>
<p style="text-align:center;"><img src='http://s0.wp.com/latex.php?latex=f%28x%2Cy%29%3Dy+sin%7B4x%7D%2B1.1+x+sin%7B2y%7D+&amp;bg=ffffff&amp;fg=4e4e4e&amp;s=0' alt='f(x,y)=y sin{4x}+1.1 x sin{2y} ' title='f(x,y)=y sin{4x}+1.1 x sin{2y} ' class='latex' />.</p>
<h2>Setting GA parameters</h2>
<p style="text-align:justify;">The second step in optimization is setting Genetic Algorithm parameter which will be used in optimization process. Open the <strong>Setting</strong> tab and set the main GA parameters, see pic. 3.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/image3.png"><img class="alignnone size-medium wp-image-5314" alt="image3" src="http://bhrnjica.files.wordpress.com/2013/03/image3.png?w=300&#038;h=190" width="300" height="190" /></a></p>
<p style="text-align:justify;">To successfully applied GA in the Optimization, it is necessary to define:</p>
<ol>
<li> population size,</li>
<li>probabilities of genetic operators and</li>
<li>selection methods.</li>
</ol>
<p style="text-align:justify;">These parameters are general for all GA and GP models. More information about parameters you can find at <a href="http://bhrnjica.net/gpdotnet">http://bhrnjica.net/gpdotnet</a>.</p>
<h2>Optimize model (running optimization)</h2>
<p style="text-align:justify;">When GA parameters are defined, we can start with optimization by selecting <b>Optimization model </b>tab. Before run, we have to define constrains for each independent variables. This is only limitation we have to define i  order to start optimization. The picture below shows how to define constrains in 3 steps:</p>
<ol>
<li> select row by left mouse click,</li>
<li>enter min and max value in text boxes</li>
<li>Press update button.</li>
</ol>
<p style="text-align:justify;">Perform these 3 actions for each independent variable defined in the function.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/image4.png"><img class="alignnone size-medium wp-image-5315" alt="image4" src="http://bhrnjica.files.wordpress.com/2013/03/image4.png?w=300&#038;h=190" width="300" height="190" /></a></p>
<p style="text-align:justify;">When the process of defining constrains is finished, it is time to run the calculation by pressing <b>Optimize</b> button, from the main toolbar(green button). During optimization process GPdotNET is presenting nice animation of fitness values, as well as showing current best optimal value. The picture above shows the result of optimization process with GPdotNET. It can be seen that the optimal value for this sample is <img src='http://s0.wp.com/latex.php?latex=f_%7Bopt%7D%289.96%29%3D-100.22&amp;bg=ffffff&amp;fg=4e4e4e&amp;s=0' alt='f_{opt}(9.96)=-100.22' title='f_{opt}(9.96)=-100.22' class='latex' />.</p>
<p style="text-align:justify;"><a href="http://bhrnjica.files.wordpress.com/2013/03/image5.png"><img class="alignnone size-medium wp-image-5319" alt="image5" src="http://bhrnjica.files.wordpress.com/2013/03/image5.png?w=300&#038;h=190" width="300" height="190" /></a></p>
<h1 style="text-align:justify;">Examples of function optimization</h1>
<p>In this topic we are going to calculate optimal value for some functions by using GPdotNET. Zo be prove that the optimal value is correct or very close to correct value we will use Wolfram Alpha or other method.</p>
<h3>Function: <b>x sin(4x)+1.1 x sin(2y)</b></h3>
<p>GP Expression tree looks like the following picture (left size):</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/image6.png"><img class="alignnone size-medium wp-image-5322" alt="image6" src="http://bhrnjica.files.wordpress.com/2013/03/image6.png?w=300&#038;h=172" width="300" height="172" /></a> <a href="http://bhrnjica.files.wordpress.com/2013/03/image7.png"><img class="alignnone size-medium wp-image-5323" alt="image7" src="http://bhrnjica.files.wordpress.com/2013/03/image7.png?w=300&#038;h=190" width="300" height="190" /></a></p>
<p>Optimal value is found (right above picture) for 0.054 min, at 363 generation of total of 500 generation. Optimal value is <strong>f(8.66,9.03)=-18.59</strong>.</p>
<p>Here is Wolfram Alpha calculation of the same function. <a href="http://www.wolframalpha.com/input/?i=min+x*sin%284*x%29%2B+1.1+*y*+sin%282+*y%29%2C+0%3Cx%3C10%2C0%3Cy%3C10">http://www.wolframalpha.com/input/?i=min+x*sin%284*x%29%2B+1.1+*y*+sin%282+*y%29%2C+0%3Cx%3C10%2C0%3Cy%3C10</a></p>
<h3>Function:  (x^2+x)cos(x),  -10≤x≤10</h3>
<p>GP expression tree looks like the following picture (left size):</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/image9.png"><img class="alignnone size-full wp-image-5326" alt="image9" src="http://bhrnjica.files.wordpress.com/2013/03/image9.png?w=604"   /></a><a href="http://bhrnjica.files.wordpress.com/2013/03/image10.png"><img class="alignnone size-medium wp-image-5327" alt="image10" src="http://bhrnjica.files.wordpress.com/2013/03/image10.png?w=300&#038;h=190" width="300" height="190" /></a></p>
<p>Optimal value is found for 0.125 min, at 10 generation of total of 500 generation. Optimal value is F(9.62)=-100.22.</p>
<p>Here is Wolfram Alpha calculation of the same function. <a href="http://www.wolframalpha.com/input/?i=minimum+%28x%5E2%2Bx%29*cos%28x%29+over+%5B-10%2C10%5D">http://www.wolframalpha.com/input/?i=minimum+%28x%5E2%2Bx%29*cos%28x%29+over+%5B-10%2C10%5D</a></p>
<h3>Easom&#8217;s function fEaso(x1,x2)=-cos(x1)•cos(x2)•exp(-((x1-pi)^2+(x2-pi)^2)), -100&lt;=x(i)&lt;=100, i=1:2.</h3>
<p>GP expression tree looks like the following picture (left size):</p>
<p><img class="alignnone size-medium wp-image-5328" alt="image12" src="http://bhrnjica.files.wordpress.com/2013/03/image12.png?w=300&#038;h=199" width="300" height="199" /><a href="http://bhrnjica.files.wordpress.com/2013/03/image13.png"><img class="alignnone size-medium wp-image-5329" alt="image13" src="http://bhrnjica.files.wordpress.com/2013/03/image13.png?w=300&#038;h=199" width="300" height="199" /></a></p>
<p>Optimal value is found for 0.061 min, at 477 generation of total of 500 generation. Optimal value is F(9.62)=-1, for x=y=3.14.</p>
<p>Function can be seen at this <a href="http://www.geatbx.com/docu/fcnindex-01.html#P226_12237">MatLab </a>link.</p>
<h1>C# Implementation behind GPdotNET Optimization module</h1>
<p>GPdotNET Optimization module is just a part which is incorporated in to GPdotNET Engine. Specific implementation for this module is Chromosome implementation, as well as Fitness function. Chromosome implementation is based on  floating point value instead of classic binary representation. Such a Chromosome contains array of floating point values and each element array represent function independent variable. If the function contains two independent variables (x,y) chromosome implementation will contains array with two floating points. Constrains of chromosome values represent constrains we defined during settings of the optimization process. The following source code listing shows implementation of GANumChrosomome class in GPdotNET:</p>
<pre class="brush: csharp; title: ; notranslate">
public class GANumChromosome: IChromosome
 {
 private double[] val = null;
 private float fitness = float.MinValue;
 //... rest of implementation
}
</pre>
<p>When the chromosome is generated array elements get values randomly generated between min and max value defined by function definition. Here is a source code of Generate method.</p>
<pre class="brush: csharp; title: ; notranslate">
///
/// Generate values for each represented variable
///
public void Generate(int param = 0)
{
	if(val==null)
		val = new double[functionSet.GetNumVariables()];
	else if (val.Length != functionSet.GetNumVariables())
		val = new double[functionSet.GetNumVariables()];

	for (int i = 0; i &lt; functionSet.GetNumVariables(); i++)
		val[i] = Globals.radn.NextDouble(functionSet.GetTerminalMinValue(i), functionSet.GetTerminalMaxValue(i));

}
</pre>
<p>Mutation is accomplish when randomly chosen array element randomly change itc value. Here is a listing:</p>
<pre class="brush: csharp; title: ; notranslate">
///
///  Select array element randomly and randomly change itc value
///
public void Mutate()
{
	//randomly select array element
	int crossoverPoint = Globals.radn.Next(functionSet.GetNumVariables());
	//randomly generate value for the selected element
	val[crossoverPoint] = Globals.radn.NextDouble(functionSet.GetTerminalMinValue(crossoverPoint), functionSet.GetTerminalMaxValue(crossoverPoint));
}
</pre>
<p>Crossover is little bit complicated. It is implemented based on Book <em><strong>Practical Genetic Algoritms</strong></em> see pages 56,57,48,59. Here is an implementation:</p>
<pre class="brush: csharp; title: ; notranslate">
///
/// Generate number between 0-1.
/// For each element array of two chromosomes exchange value based on random number.
///
///
public void Crossover(IChromosome ch2)
{
	GANumChromosome p = (GANumChromosome)ch2;
	int crossoverPoint = Globals.radn.Next(functionSet.GetNumVariables());
	double beta;
	for (int i = crossoverPoint; i &lt; functionSet.GetNumVariables(); i++)
	{
		beta = Globals.radn.NextDouble();
		val[i] = val[i] - beta * (val[i] - p.val[i]);
		p.val[i] = p.val[i] + beta * (val[i] - p.val[i]);
	}
}
</pre>
<p>Fitness function for Optimization is straightforward, it evaluates each chromosome against tree expression. For minimum the better chromosome is lower value. For maximum better chromosome is the chromosome with higher fitness value. Here is a implementation of Optimizatio Fitness function:</p>
<pre class="brush: csharp; title: ; notranslate">
///
/// Evaluates function agains terminals
///
///
///
///
public float Evaluate(IChromosome chromosome, IFunctionSet functionSet)
{
	GANumChromosome ch = chromosome as GANumChromosome;
	if (ch == null)
		return 0;
	else
	{
		//prepare terminals
		var term = Globals.gpterminals.SingleTrainingData;
		for (int i = 0; i &lt; ch.val.Length; i++)
			term[i] = ch.val[i];

		var y = functionSet.Evaluate(_funToOptimize, -1);

		if (double.IsNaN(y) || double.IsInfinity(y))
			y = float.NaN;

		//Save output in to output variable
		term[term.Length - 1] = y;

		if (IsMinimize)
			y *= -1;

		return (float)y;
	}
}
</pre>
<h1>Summary</h1>
<p style="text-align:justify;">We have seen that Function optimization module within GPdotNET is powerful optimization tool. It can find pretty close solution for very complex functions regardless of number of independent variables. Optimization module use Genetic Algorithm method with floating point value chromosome representation described in several books about GA. It is fast, simple and can be used in education as well as in solving real problems. More info about GPdotNET can be found at <a href="http://bhrnjica.net/gpdotnet" rel="nofollow">http://bhrnjica.net/gpdotnet</a>.</p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/codeproject/'>CodeProject</a>, <a href='http://bhrnjica.net/category/gpdotnet/'>GPdotNET</a> Tagged: <a href='http://bhrnjica.net/tag/ai/'>AI</a>, <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/codeproject/'>CodeProject</a>, <a href='http://bhrnjica.net/tag/function-optimization/'>Function optimization</a>, <a href='http://bhrnjica.net/tag/genetic-algorithm/'>Genetic Algorithm</a>, <a href='http://bhrnjica.net/tag/genetic-programming/'>Genetic Programming</a>, <a href='http://bhrnjica.net/tag/gpdotnet/'>GPdotNET</a>, <a href='http://bhrnjica.net/tag/optimization/'>Optimization</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5305&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/03/26/function-optimization-with-genetic-algorithm-by-using-gpdotnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2009/11/gplogo_350x134pix.png?w=350" medium="image" />

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image1.png?w=300" medium="image">
			<media:title type="html">image1</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image2.png?w=300" medium="image">
			<media:title type="html">image2</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image3.png?w=300" medium="image">
			<media:title type="html">image3</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image4.png?w=300" medium="image">
			<media:title type="html">image4</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image5.png?w=300" medium="image">
			<media:title type="html">image5</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image6.png?w=300" medium="image">
			<media:title type="html">image6</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image7.png?w=300" medium="image">
			<media:title type="html">image7</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image9.png" medium="image">
			<media:title type="html">image9</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image10.png?w=300" medium="image">
			<media:title type="html">image10</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image12.png?w=300" medium="image">
			<media:title type="html">image12</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/image13.png?w=300" medium="image">
			<media:title type="html">image13</media:title>
		</media:content>
	</item>
		<item>
		<title>MSNetwork 3. po redu Microsoft konferencija u BiH</title>
		<link>http://bhrnjica.net/2013/03/19/msnetwork-3-po-redu-microsoft-konferencija-u-bih/</link>
		<comments>http://bhrnjica.net/2013/03/19/msnetwork-3-po-redu-microsoft-konferencija-u-bih/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 13:14:06 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[async]]></category>
		<category><![CDATA[MSNetwork]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5290</guid>
		<description><![CDATA[Sada već tradicionalno po treći put se održava Bosanskohercegovačka Microsoft konferencija:  MSNetwork 3. Mjesto održavanja ovaj put je Banja Vrućica zdravstveno turistički centar koji se nalazi u blizini Teslica, gradića na putu izmedju Banjaluke i Doboja. Kao i prvi put kad se održavala u Banjaluci prije 3 godine, i ovaj put konferencija će ponuditi najbolje [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5290&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<div id="attachment_5291" class="wp-caption alignnone" style="width: 292px"><a href="http://msnetwork.ba"><img class="size-full wp-image-5291  " title="Banja Vrućica 3. i 4. aprila 2013 g." alt="msnetwork" src="http://bhrnjica.files.wordpress.com/2013/03/msnetwork.png?w=604"   /></a><p class="wp-caption-text">Banja Vrućica 3. i 4. aprila 2013 g.</p></div>
<p>Sada već tradicionalno po treći put se održava Bosanskohercegovačka Microsoft konferencija:  <a href="http://msnetwork.ba">MSNetwork 3</a>. Mjesto održavanja ovaj put je Banja Vrućica zdravstveno turistički centar koji se nalazi u blizini Teslica, gradića na putu izmedju Banjaluke i Doboja.</p>
<p>Kao i prvi put kad se održavala u Banjaluci prije 3 godine, i ovaj put konferencija će ponuditi najbolje teme, predavače i cijelu konferenciju učiniti nezaboravnom bas onako kako je to bilo i ranije. Naravno, svaki put ljudi iz Microsofta BiH se potrude da ona bude bolja od prethodne pa i ovaj put ne sumnjam u to. Ovaj put rekordan broj predavača kao i predavanja. Prva konferencija je krenula sa 3 tracka, da bi prošle godine bio i MSC track na kojem predavanja daju ljudi iz MS Communitya, da bi ove godine bio i EDU track, posvećen nekim stručnim  temama.</p>
<p>Na ovoj konferenciji se se naći zaista za svakog ponešto. Gotovo svi poznati  predavači iz Makedonije, Srbije, BiH, Hrvatske i Slovenije, posebno predavači iz Njemačke i drugih evropskih zemalja,  naći će se 3 i 4 aprila u Banja Vrućici. Ukupno 60 predavača govorit će na konferencij što konferenciji čini vrlo atraktivnom, kvalitetnom i zanimljivom.</p>
<p>Koristim ovu priliku da na MSNetwork najavim svoje predavanje. Predavati na MSNetwork konferenciji zaista me čini sretnim i zahvaljujem se organizatorima što su ovo predavanje  uključili u zvanični dio konferencije.</p>
<p>Naziv predavanja, level i kratki opis pročitajte u narednom tekstu.</p>
<p><strong>Paralelno i asinhrono programiranje – izazov za svakog programera (4.april. 2013, 11:30 dvorana Bosna)</strong></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/03/par_asyn_conc.png"><img class="alignnone size-full wp-image-5292" alt="par_asyn_conc" src="http://bhrnjica.files.wordpress.com/2013/03/par_asyn_conc.png?w=604"   /></a></p>
<p>Level: 300</p>
<p>Opis predavanja:</p>
<p><em>Multi-core procesori su realnost, proizvođači ih danas ugrađuju i u grafičke kartice, mobilne telefone pa čak i u veš-mašine. Direktna posljedica razvoja multi-core procesora je prestanak razvoja single-core procesora čiji takt već odavno stoji na magičnoj brojci oko 3 GHz. Kako proizvođači ovom tehnologijom ne mogu povećati takt počeli sa proizvodnjom multi-core procesora, ili višejezgrenih procesora u jednom hardverskom dijelu, što je dalo dodatni vjetar u leđa razvoju procesora. Danas se kućni računari kupuju sa 4 ili 8 jezgri, serveri i do 128 jezgri. Realno se pitanje postavlja: da li softver koji je razvijan nekoliko godina unazad odgovara takvom hardveru? Da li hardver na multi-core procesorima ima smisla vrtiti dosadašnja softverska rješenja? Moguće se upitati i to da li energija koju troši ovakav hardver odgovara korištenju softvera? Imate više od 1 procesora na PC-u, ali ne primjećujete da vaš softver radi brže? Još uvijek koristite klasu Thread ili BackgroundWorker ili Callback funkciju kako bi korisnika zavaravali dok se vaši podaci učitavaju u pozadini? Željeli bi programirati višenitne aplikacije, a da ne formirate niti? Ovo su samo neka od pitanja, čije odgovore daje paralelno i asinhrono programiranje u .NETu. Paralelno i asinhrono programiranje predstavlja novu paradigmu i izazove za moderne programere koji žele iskorištavati sve resurse PC-a, a ne samo jednu jezgru, koji žele programirati višenitno, a da ne formiraju niti, koji žele koristiti nova proširenja koja su sastavni dijelovi .NET 4.5 i C# 5.0.</em></p>
<p>Pored zvaničnog opisa ovdje bih dodao da će ovo predavanje obilovati realnim primjerima:</p>
<p>1. primjer paralelizacije riješavanje sistema linearnih jednačina sa više od 1000 nepoznatih.</p>
<p>2. primjer asinhronog procesuiranja zahtjeva na ASP.NET  web stranici.</p>
<p>3. procedura konverzije sekvencijalnog koda u asinhroni, praktična iskustva.</p>
<p>4. nekoliko jednostavnih primjera demonstracije Data Race, Thread-Safety, PLINQ,ThreadLocalState i sl.</p>
<p>Nadam se da će predavanje biti zanimljivo, a pogotovu za one koji žele više posmatrati Visual Studio od PowerPointa.</p>
<p>Vidimo se na konferenciji.</p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a> Tagged: <a href='http://bhrnjica.net/tag/async/'>async</a>, <a href='http://bhrnjica.net/tag/msnetwork/'>MSNetwork</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5290/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5290/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5290&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/03/19/msnetwork-3-po-redu-microsoft-konferencija-u-bih/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/msnetwork.png" medium="image">
			<media:title type="html">Banja Vrućica 3. i 4. aprila 2013 g.</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/03/par_asyn_conc.png" medium="image">
			<media:title type="html">par_asyn_conc</media:title>
		</media:content>
	</item>
		<item>
		<title>Implementation Traveling Salesman Problem (TSP) with GPdotNET</title>
		<link>http://bhrnjica.net/2013/02/13/implementation-traveling-salesman-problem-tsp-with-gpdotnet/</link>
		<comments>http://bhrnjica.net/2013/02/13/implementation-traveling-salesman-problem-tsp-with-gpdotnet/#comments</comments>
		<pubDate>Wed, 13 Feb 2013 18:48:46 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[GPdotNET]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5249</guid>
		<description><![CDATA[After only 2 months of releasing GPdotNET v2.0 the new update is coming. Architecture of GPdotNET v2 allows implementation of wide range of GA &#38; GP based problems. For this first update, it is implementation of Traveling Salesman Problem (TSP). Short description of this problem is to find the shortest path by visiting all cities [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5249&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:justify;">After only 2 months of releasing GPdotNET v2.0 the new update is coming. Architecture of GPdotNET v2 allows implementation of wide range of GA &amp; GP based problems. For this first update, it is implementation of Traveling Salesman Problem (TSP). Short description of this problem is to find the shortest path by visiting all cities only once. More info can be found <a href="http://en.wikipedia.org/wiki/Travelling_salesman_problem">here</a>.  This problem is implemented just for several hours, because all important phases are already implemented.</p>
<p>The main implementations for this problem were:</p>
<ol>
<li>TSPChromosome &#8211; class for chromosome representation</li>
<li>TSP Fitness &#8211; implementation</li>
<li>Other parts like selection, simulation of the result are mostly implemented.</li>
</ol>
<h2>TSPChromosome class implementation</h2>
<p style="text-align:justify;">Instead of binary value, TSP chromosome must be array of integers by representing path around cities. The main problem with this chromosome type is genetic operations, because you cannot implement it easily.</p>
<p style="text-align:justify;">For example standard Crossover in GA takes random point and split parents in two parts, see picture below. One part goes to first offspring, the second one goes to second offspring. The same action is performed for the second parent. The picture below shows standard crossover in GA.</p>
<p> <a href="http://bhrnjica.files.wordpress.com/2013/02/image1.png"><img class="alignnone size-full wp-image-5250" alt="image1" src="http://bhrnjica.files.wordpress.com/2013/02/image1.png?w=604"   /></a></p>
<p style="text-align:justify;">Unfortunately this operation cannot be applied to TSP, because every city can be visited only once. But how can we perform crossover at all? There are several methods can be found on internet. The method applied in GPdotNET is the following.</p>
<p style="text-align:justify;">Choose different random points for Parent 1 and Parent 2.</p>
<p style="text-align:justify;"><strong>Offspring 1</strong> is created based on the left part of Parent 1, and sub permutation of the rest of cities.</p>
<p style="text-align:justify;"><strong>Offspring 2</strong> is created based on the right part of Parent 2 and sub permutation of rest of the cities.</p>
<p style="text-align:justify;">Picture below show crossover used in GPdotNET.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image2.png"><img class="alignnone size-full wp-image-5251" alt="image2" src="http://bhrnjica.files.wordpress.com/2013/02/image2.png?w=604"   /></a></p>
<p>The problem with this crossover is that offsprings are not created based on genetic material from both parents.</p>
<p>Implementation of TSPChromosome crossover method is presented below:</p>
<pre class="brush: csharp; title: ; notranslate">
public void Crossover(IChromosome ch2)
{
    var ch22 = ch2 as GATSPChromosome;
    if (ch22 == null)
        throw new Exception(&quot;Chromosome cannot be null!&quot;);

    Order(true);
    ch22.Order(false);

    int randInd1 = Globals.radn.Next(length);
    int randInd2 = Globals.radn.Next(length);

    for (int i = 0; i &lt; randInd1; i++)
    {
        int rand1 = Globals.radn.Next(randInd1);
        int rand2 = Globals.radn.Next(randInd1);

        var temp = value[randInd1];
        value[randInd1] = value[randInd2];
        value[randInd2] = temp;
    }

    for (int i = randInd2; i &lt; length; i++)
     {
         int rand1 = Globals.radn.Next(randInd2,length);
         int rand2 = Globals.radn.Next(randInd2,length);
         var temp = ch22.Value[randInd1];
         ch22.Value[randInd1] = ch22.Value[randInd2];
         ch22.Value[randInd2] = temp;
     }
 }
</pre>
<p>Mutation operation for this chromosome can be implemented so that we randomly choose two cities and swap their positions in the path. Implementation for this operation is presented in code below:</p>
<pre class="brush: csharp; title: ; notranslate"> public void Mutate() {     int randInd1 = Globals.radn.Next(length);     int randInd2 = Globals.radn.Next(length);     if(randInd1&gt;randInd2)
    {
        int temp= randInd2;
        randInd2=randInd1;
        randInd1=temp;
    }
    int j = 0;
    for (int i = randInd1; i &lt;= randInd2; i++,j++)
     {
         if (i &gt; (randInd2 - j))
            break;
        var temp1 = value[i];
        var temp2 = value[randInd2-j];
        value[i] = temp2;
        value[randInd2 - j] = temp1;
    }
}
</pre>
<p>Fitness of TSP</p>
<p>Fitness function is relatively simple. It calculates total path based on Chromosome array of cities. Fitness will be better if the path is shorter.</p>
<pre class="brush: csharp; title: ; notranslate">
public float Evaluate(IChromosome chromosome, IFunctionSet functionSet)
{
    var ch = chromosome as GATSPChromosome;
    if (ch == null)
        return 0;
    else
    {
        double y = 0, fitness;
        double[] p1 = null;
        double[] p2 = null;
        int rCount = ch.Length;
        for (int i = 0; i &lt; rCount; i++)
        {
            p1 = Globals.GetTerminalRow(ch.Value[i]);
            if (i + 1 == rCount)
                p2 = Globals.GetTerminalRow(ch.Value[0]);
            else
                p2 = Globals.GetTerminalRow(ch.Value[i+1]);

            // calculate distance betwee two points and make the sum
            y += Math.Sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]));

            // check for correct numeric value
            if (double.IsNaN(y) || double.IsInfinity(y))
                return float.NaN;
        }
        //with this value we always search for maximum value of fitness
        fitness = ((1.0 / (1.0 + y)) * 1000.0);

        return (float)fitness;
    }
}
</pre>
<h2>Loading City Map</h2>
<p>TSP Solver needs City data of points in (X;Y) format. It must be loaded by CSV file format, the same as GPdotNET uses for loding data for modelling and optimization. The following data represent corect format:</p>
<p>CityMap data format:</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image8.png"><img class="alignnone size-full wp-image-5257" alt="image8" src="http://bhrnjica.files.wordpress.com/2013/02/image8.png?w=604&#038;h=388" width="604" height="388" /></a></p>
<h2>How to run TSP Solver on GPdotNET</h2>
<p>Running TSP solver with GPdotNET is relatively easy. The procedure follows global convention for creating new model or solver.</p>
<p>1. Choose <strong>New</strong>.. from mainpanel.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image3.png"><img class="alignnone size-full wp-image-5252" alt="image3" src="http://bhrnjica.files.wordpress.com/2013/02/image3.png?w=604&#038;h=384" width="604" height="384" /></a></p>
<p>2.  Choose <strong>Traveling Salesman Problem</strong>, and click OK button.</p>
<p>3. Open <strong>Load Data</strong> tab, (if it not opened), press <strong>Load Cities Map</strong> button, choose <em><strong>CityMap.CSV</strong></em>, and press OK. Data is presented on picture below.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image4.png"><img class="alignnone size-full wp-image-5253" alt="image4" src="http://bhrnjica.files.wordpress.com/2013/02/image4.png?w=604&#038;h=386" width="604" height="386" /></a></p>
<p>4. Sett GA parameters on Setting Tab panel:</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image5.png"><img class="alignnone size-full wp-image-5254" alt="image5" src="http://bhrnjica.files.wordpress.com/2013/02/image5.png?w=604&#038;h=384" width="604" height="384" /></a></p>
<p>5. Open Simulation Tab panel. You can see graphically representation of loaded map, and set of simulation parameters.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image6.png"><img class="alignnone size-full wp-image-5255" alt="image6" src="http://bhrnjica.files.wordpress.com/2013/02/image6.png?w=604&#038;h=384" width="604" height="384" /></a></p>
<p>6. Press <strong>Run</strong> ribon button, and Solver will start. During simulation you can see that the path length is becoming shorter and shorter</p>
<p>7. As final result, Solver find the path which is the shortest or very close to shorter one.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/image7.png"><img class="alignnone size-full wp-image-5256" alt="image7" src="http://bhrnjica.files.wordpress.com/2013/02/image7.png?w=604&#038;h=384" width="604" height="384" /></a></p>
<p>8. Exit and Save your solution.</p>
<p>We have seen how easy is to implement such a problem, base on existing foundation of the GPdotNET. More problems based on GA/GP is cumming in the GPdotNET.  Application is posted on <a href="http://gpdotnet.codeplex.com/releases/view/101870">codeplex.com</a>, as GPdotNET v2.1 beta 1.</p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/gpdotnet/'>GPdotNET</a> Tagged: <a href='http://bhrnjica.net/tag/net/'>.NET</a>, <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/gpdotnet/'>GPdotNET</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5249/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5249/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5249&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/02/13/implementation-traveling-salesman-problem-tsp-with-gpdotnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image1.png" medium="image">
			<media:title type="html">image1</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image2.png" medium="image">
			<media:title type="html">image2</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image8.png" medium="image">
			<media:title type="html">image8</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image3.png" medium="image">
			<media:title type="html">image3</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image4.png" medium="image">
			<media:title type="html">image4</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image5.png" medium="image">
			<media:title type="html">image5</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image6.png" medium="image">
			<media:title type="html">image6</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/image7.png" medium="image">
			<media:title type="html">image7</media:title>
		</media:content>
	</item>
		<item>
		<title>Matrakci Calculator for Android</title>
		<link>http://bhrnjica.net/2013/02/06/matrakci-calculator-for-android/</link>
		<comments>http://bhrnjica.net/2013/02/06/matrakci-calculator-for-android/#comments</comments>
		<pubDate>Wed, 06 Feb 2013 06:00:24 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[jQueryMobile]]></category>
		<category><![CDATA[Matematika]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5237</guid>
		<description><![CDATA[Matrakci Calculator on  Googel Play. After Windows Phone version of Matrakci Calculator, I wanted to make Andorid version too but I dont know much about Java and Eclipse. So I decided to implement JQueryMobile application, which sombody needs to merge in to Eclipse. After some time the result of work can be seen on picture [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5237&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>Matrakci Calculator on <a href="https://play.google.com/store/apps/details?id=feed.zire.maktracki&amp;feature=nav_result&amp;hl=en"> Googel Play</a>.</strong></p>
<p>After Windows Phone version of <a href="http://www.windowsphone.com/en-us/store/app/matrakci-calculator/59680235-b5e2-41a9-b2f5-49eebfc62301">Matrakci Calculator</a>, I wanted to make Andorid version too but I dont know much about Java and Eclipse. So I decided to implement JQueryMobile application, which sombody needs to merge in to Eclipse.</p>
<p>After some time the result of work can be seen on picture below. I have used canvas for lattice drawing  and  used different fill colors to differentiate which numbers needs to be summed. I liked this version, because I have learned more about HTML5 and JavaScript programming as well. So my future application will be in HTML5 as well.</p>
<p>You can download Matrakci Calcualtor from this <a href="https://play.google.com/store/apps/details?id=feed.zire.maktracki&amp;feature=nav_result&amp;hl=en">link </a>at Google Play.</p>
<p>I want to thank my fried <a href="http://bosnia-aspnet.blogspot.de/">Nezir Zahirovic</a> which he helped me in implementation of this app.</p>
<p><strong>If you want to play <strong>online </strong>this calculator right now, check this <a href="http://datasoft.ba/matrakci/">link</a>. It is described all you want to know about Matrakci and Lattice multiplication as well.</strong></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/screen1.png"><img class="alignnone size-full wp-image-5238" alt="Screen1" src="http://bhrnjica.files.wordpress.com/2013/02/screen1.png?w=604"   /></a></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/02/screen2.png"><img class="alignnone size-full wp-image-5239" alt="Screen2" src="http://bhrnjica.files.wordpress.com/2013/02/screen2.png?w=604"   /></a></p>
<br />Filed under: <a href='http://bhrnjica.net/category/android/'>Android</a> Tagged: <a href='http://bhrnjica.net/tag/android/'>Android</a>, <a href='http://bhrnjica.net/tag/jquerymobile/'>jQueryMobile</a>, <a href='http://bhrnjica.net/tag/matematika/'>Matematika</a>, <a href='http://bhrnjica.net/tag/mobile/'>Mobile</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5237/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5237/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5237&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/02/06/matrakci-calculator-for-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/screen1.png" medium="image">
			<media:title type="html">Screen1</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/02/screen2.png" medium="image">
			<media:title type="html">Screen2</media:title>
		</media:content>
	</item>
		<item>
		<title>SignalR Online Counter Sample</title>
		<link>http://bhrnjica.net/2013/01/28/signalr-hit-counter-sample/</link>
		<comments>http://bhrnjica.net/2013/01/28/signalr-hit-counter-sample/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 20:08:23 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[Asp.NET]]></category>
		<category><![CDATA[SignalR]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5196</guid>
		<description><![CDATA[SignalR is a web technology for building real time ASP.NET web applications. SignalR is an open source project which simplifies the complicated tasks of creating bidirectional communication between clients and server. SignalR is founded on top of WebSockets, as well as other similar technologies. As you probably know WebSockets introduced a new way to communicate between server [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5196&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>SignalR is a web technology for building real time ASP.NET web applications. SignalR is an open source project which simplifies the complicated tasks of creating bidirectional communication between clients and server. SignalR is founded on top of WebSockets, as well as other similar technologies.</p>
<p>As you probably know WebSockets introduced a new way to communicate between server and clients, and it is specified by the HTML5 API specification. When it is available SignalR will use this technology, otherwise it will use what is supported by your system. SignalR also provides a high-level API for server communication to client RPC (call JavaScript functions in clients’ browsers from server-side .NET code) in ASP.NET applications, as well as adds useful hooks for connection management, e.g., connect/disconnect events, grouping connections, authorization. More information about SignalR can be found on the official web site for <a href="http://signalr.org/">SignalR</a>.</p>
<p>For this post I have implemented a very simple SignalR Web Application which counts how many users are online, so it is called <strong>Online Counter</strong>. Online Counters are a very popular component for the web.</p>
<p>So let’s start with the implementation.</p>
<ol>
<li>Open Visual Studio 2012, and create new Empty Web Application called OnlineCounter.</li>
</ol>
<p><a href="http://bhrnjica.files.wordpress.com/2013/01/signalr_image1.png"><img class="alignnone size-full wp-image-5198" alt="SignalR_image1" src="http://bhrnjica.files.wordpress.com/2013/01/signalr_image1.png?w=604&#038;h=362" width="604" height="362" /></a></p>
<p>The first thing we will do is adding SignalR reference for the clients (JavaScript files) and the Server (.NET Components).</p>
<p>2. So open NuGet Manager console and input the following command: <strong>Install-Package Microsoft.AspNet.SignalR –Pre</strong></p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/01/signalr_image2.png"><img class="alignnone size-full wp-image-5199" alt="SignalR_image2" src="http://bhrnjica.files.wordpress.com/2013/01/signalr_image2.png?w=604&#038;h=258" width="604" height="258" /></a></p>
<p>After we added SignalR references, we are implementing Server side of the SignalR HitCounter Web Application.</p>
<p>3. Add a new class named <code>HitCounter</code>.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/01/signalr_image3.png"><img class="alignnone size-full wp-image-5200" alt="SignalR_image3" src="http://bhrnjica.files.wordpress.com/2013/01/signalr_image3.png?w=604&#038;h=559" width="604" height="559" /></a></p>
<p>The <code>HitCounter</code> class must be derived from the Hub. More info about Hub and other SignalR components you can find on the <a href="http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr">official site</a>.</p>
<p>The implementation for the <code>HitCounter</code> class is shown below:</p>
<pre class="brush: csharp; title: ; notranslate">
public class HitCounter : Hub
{

 private static int clientCounter = 0;

 public void Send()
 {
 string message = &quot;&quot;;
 // Call the recalculateOnlineUsers method to update clients
 if(clientCounter&lt;2)
 message = string.Format(&quot;Currently {0} user is online.&quot;,clientCounter);
 else
 message = string.Format(&quot;Currently {0} users are online.&quot;, clientCounter);

 Clients.All.recalculateOnlineUsers(message);
 }

 ///
/// register online user
 ///
 ///
 public override System.Threading.Tasks.Task OnConnected()
 {
 clientCounter++;
 return base.OnConnected();
 }

 ///
/// unregister disconected user
 ///
 ///
 public override System.Threading.Tasks.Task OnDisconnected()
 {
 clientCounter--;
 return base.OnDisconnected();
 }
}
</pre>
<p>As you can see from the source code, we have override two virtual methods when user is reach the page, and also when the user live the page. The <code>Send</code> method is responsible to send message to all available clients.</p>
<p>We need also to implement Global Application Class to register this hub.</p>
<p>4. Add Global Application Class in to your project, and register MapHubs, as picture shows below.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/01/signalr_image4.png"><img class="alignnone size-full wp-image-5201" alt="SignalR_image4" src="http://bhrnjica.files.wordpress.com/2013/01/signalr_image4.png?w=604&#038;h=367" width="604" height="367" /></a></p>
<p>The following code implementation shows how to register Hub in Global App Class.</p>
<pre class="brush: csharp; title: ; notranslate">
public class Global : System.Web.HttpApplication
{

    protected void Application_Start(object sender, EventArgs e)
    {
        // Register the default hubs route: ~/signalr/hubs
        RouteTable.Routes.MapHubs();
    }
//rest of the implememtation.....
</pre>
<p style="text-align:justify;">After we implemented Services side of SignalR, we need to implement client side.</p>
<p style="text-align:justify;">5. Add new html web page in to project.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/01/signalr_image6.png"><img class="alignnone size-full wp-image-5203" alt="SignalR_image6" src="http://bhrnjica.files.wordpress.com/2013/01/signalr_image6.png?w=604&#038;h=365" width="604" height="365" /></a></p>
<p>6. Include standard set of JavaScript files necessary for SignalR client to run.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!--Script references. --&gt;
&lt;!--Reference the jQuery library. --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;Scripts/jquery-1.6.4.min.js&quot;&gt;&lt;/script&gt;&lt;!--Reference the SignalR library. --&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;Scripts/jquery.signalR-1.0.0-rc2.js&quot;&gt;&lt;/script&gt;
&lt;!--Reference the autogenerated SignalR hub script. --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/signalr/hubs&quot;&gt;&lt;/script&gt;
</pre>
<p>7. Send Notification to Server that the new User is reached the page.<br />
8. Implemet JavaScript code to receive recalculateOnlineUser event sent from server.</p>
<pre class="brush: jscript; title: ; notranslate">
    $(function () {

        // Declare a proxy to reference the hub.
        var counter = $.connection.hitCounter;

        // register online user at the very begining of the page
        $.connection.hub.start().done(function () {
            // Call the Send method on the hub.
            counter.server.send();
        });

        // Create a function that the hub can call to recalculate online users.
        counter.client.recalculateOnlineUsers = function (message) {

            // Add the message to the page.
            $('paragraph').text(message);
        };

    });
</pre>
<p>9. Compile and run the code. Open two Browser Windows. You can see that SignalR has counted two online users.</p>
<p><a href="http://bhrnjica.files.wordpress.com/2013/01/signalr_image7.png"><img class="alignnone size-full wp-image-5210" alt="SignalR_image7" src="http://bhrnjica.files.wordpress.com/2013/01/signalr_image7.png?w=604&#038;h=627" width="604" height="627" /></a></p>
<p>Source code for this blog post demo you can find below.</p>
<iframe src="https://skydrive.live.com/embed?cid=8B11BBBF3F0ED903&#038;resid=8B11BBBF3F0ED903%2128589&#038;authkey=AFN1XTw9pKT3D_A" width="98" height="120" frameborder="0" scrolling="no"></iframe>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/codeproject/'>CodeProject</a> Tagged: <a href='http://bhrnjica.net/tag/asp-net/'>Asp.NET</a>, <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/codeproject/'>CodeProject</a>, <a href='http://bhrnjica.net/tag/signalr/'>SignalR</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5196/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5196&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/01/28/signalr-hit-counter-sample/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/signalr_image1.png" medium="image">
			<media:title type="html">SignalR_image1</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/signalr_image2.png" medium="image">
			<media:title type="html">SignalR_image2</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/signalr_image3.png" medium="image">
			<media:title type="html">SignalR_image3</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/signalr_image4.png" medium="image">
			<media:title type="html">SignalR_image4</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/signalr_image6.png" medium="image">
			<media:title type="html">SignalR_image6</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/signalr_image7.png" medium="image">
			<media:title type="html">SignalR_image7</media:title>
		</media:content>
	</item>
		<item>
		<title>Matrakci Calculator – my new Windows Phone app</title>
		<link>http://bhrnjica.net/2013/01/02/matrakci-calculator-my-new-windows-phone-app/</link>
		<comments>http://bhrnjica.net/2013/01/02/matrakci-calculator-my-new-windows-phone-app/#comments</comments>
		<pubDate>Wed, 02 Jan 2013 18:50:33 +0000</pubDate>
		<dc:creator>Bahrudin Hrnjica</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows Phone 7]]></category>
		<category><![CDATA[Matematika]]></category>
		<category><![CDATA[Matrakci Calculator]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://bhrnjica.net/?p=5183</guid>
		<description><![CDATA[Find this application on Windows Phone Marketplace at this location: http://www.windowsphone.com/s?appid=59680235-b5e2-41a9-b2f5-49eebfc62301 If you want to play online this calculator right now, check this link. It is described all you want to know about Matrakci and Lattice multiplication as well. During holidays I was working on a small Windows Phone app. The application simulates how people performed multiplication more than [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5183&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>Find this application on Windows Phone Marketplace at this location: <a href="http://www.windowsphone.com/s?appid=59680235-b5e2-41a9-b2f5-49eebfc62301">http://www.windowsphone.com/s?appid=59680235-b5e2-41a9-b2f5-49eebfc62301</a></strong></p>
<p><strong>If you want to play <strong>online </strong>this calculator right now, check this <a href="http://datasoft.ba/matrakci/">link</a>. It is described all you want to know about Matrakci and Lattice multiplication as well.</strong></p>
<p><img class="alignnone size-full wp-image-5184" alt="about_matrakci" src="http://bhrnjica.files.wordpress.com/2013/01/about_matrakci.png?w=604"   /></p>
<p>During holidays I was working on a small Windows Phone app. The application simulates how people performed multiplication more than 500 years ago. Before 500 years, people didn&#8217;t have devices we have today, so it was pretty complicated to calculate how much is e.g. 2345*6542. Those days, one of the discovered devices was Napier Bones, which could perform multiplication of pretty big numbers (with 2 or more digits). The device uses very clever method for multiplication, discovered 50 years before Napier constructed his Abacus. A recent study of  the book, &#8220;Support of arithmetic in propositions of all magnitudes&#8221; (org. &#8220;Umdet-ul Hisab&#8221;) revealed an unknown fact that Matrakci had invented this genuine multiplication method. Nasuh Maktrakci was 16th century Ottoman mathematician, teacher, historian, geographer, cartographer, swordmaster, and miniaturist of Bosniak origin.<br />
Currently application is preparing for sumbiting to marketplace, but there is a web silvelright version of the application which you can taste now. Just go to <a href="http://datasoft.ba/demos/matrakci/Matrakci.aspx">http://datasoft.ba/demos/matrakci/Matrakci.aspx</a> and taste this very clever method for multiplication.</p>
<br />Filed under: <a href='http://bhrnjica.net/category/net/'>.NET</a>, <a href='http://bhrnjica.net/category/c/'>C#</a>, <a href='http://bhrnjica.net/category/windows-phone-7/'>Windows Phone 7</a> Tagged: <a href='http://bhrnjica.net/tag/c/'>C#</a>, <a href='http://bhrnjica.net/tag/matematika/'>Matematika</a>, <a href='http://bhrnjica.net/tag/matrakci-calculator/'>Matrakci Calculator</a>, <a href='http://bhrnjica.net/tag/wp7/'>wp7</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bhrnjica.wordpress.com/5183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bhrnjica.wordpress.com/5183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bhrnjica.net&#038;blog=8583695&#038;post=5183&#038;subd=bhrnjica&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bhrnjica.net/2013/01/02/matrakci-calculator-my-new-windows-phone-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3b46d2436fb68e023ec7bcb24d3179d8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">BHrnjica</media:title>
		</media:content>

		<media:content url="http://bhrnjica.files.wordpress.com/2013/01/about_matrakci.png" medium="image">
			<media:title type="html">about_matrakci</media:title>
		</media:content>
	</item>
	</channel>
</rss>
