<?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/"
	>

<channel>
	<title>TECHiE TALKS &#187; JAVA</title>
	<atom:link href="http://www.icpep.org/category/programming/java-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icpep.org</link>
	<description>Just another techie stuff</description>
	<lastBuildDate>Fri, 23 Jul 2010 04:53:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Neural Network Programming</title>
		<link>http://www.icpep.org/neural-network-programming/</link>
		<comments>http://www.icpep.org/neural-network-programming/#comments</comments>
		<pubDate>Wed, 13 May 2009 12:27:51 +0000</pubDate>
		<dc:creator>paparts</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[Neural Networks]]></category>

		<guid isPermaLink="false">http://www.icpep.org/?p=573</guid>
		<description><![CDATA[Thank You to Jovencito Talasan One method of Neural Network Programming is Q Learning that will be applied for ai robots. Q learning is is an off-policy method that can be run on top of any strategy wandering in the Markov Decision Process (MDP). It uses the information observed to approximate the optimal function, from [...]]]></description>
			<content:encoded><![CDATA[<p>Thank You to Jovencito Talasan</p>
<p align="justify">
One method of Neural Network Programming is Q Learning that will be applied for ai robots.  Q learning is is an off-policy method that can be run on top of any strategy wandering in the Markov Decision Process (MDP). It uses the information observed to approximate the optimal function, from which one can construct the optimal policy or to summarize the function of Q learning, only the state-action function needs to be stored and updated.</p>
<p>
This the intelliBrain Mobot&#8217;s <strong>Flow Chart</strong>:</p>
<p align="center"><img class="aligncenter size-full wp-image-485" title="flow-chart-of-mobile-robot-function" src="http://www.icpep.org/wp-content/uploads//flow-chart-of-mobile-robot-function.jpg" alt="flow-chart-of-mobile-robot-function" width="297" height="240" /></p>
<p><span id="more-573"></span></p>
<p align="justify">The Language used for the Neural Network Programming is JAVA.  The Program was then loaded to the controller. </p>
<pre>LEARN_RATE = 0.35f; // the learning rate constant
public static float EXPLORE_RATE = 0.15f; // the rate it tries out random
//actions
private static Servo mLeftServo;
private static Servo mRightServo;
byte [][] state;
byte [][]action;
private static float [][] Q; // table of Q-values (action,state)
byte i = -1; // last state
byte a = -1; // last action
byte a1 = 0; // action with highest q-value
float r = 0; // Last reward
public ObstacleAvoidance(byte actions, byte states) // constructor
{
state = new byte[states][4]; // 16 unique states, 4 unique SENSOR
action = new byte[actions][2]; // 4 unique actions with 2 actuators
initAction(action);
initState(state);
Q = new float[actions][states]; // table of Q-values for action-states
//setRandomValues(Q);
setLearnedQValues(Q);
}
public static void main(String [] args)
{
byte actions = 4;
byte states = 16;
long iterMax=100000;
ObstacleAvoidance qutil = new ObstacleAvoidance(actions, states);
ObstacleAvoidance qbrain = new ObstacleAvoidance(actions, states);
byte[] e = new byte[8]; // The environment values
2
byte [] motorCommand = new byte[2]; // Commands to send to motors
mLeftServo=IntelliBrain.getServo(1);
mRightServo=IntelliBrain.getServo(2);
for (long iter=0;iter&lt;=3)
e[0]=1;
else
e[0]=0;
if(e[5]&lt;=4)
e[1]=1;
else
e[1]=0;
if (e[6]&lt;=3)
e[2]=1;
else
e[2]=0;
if (e[7]&lt;=3)
e[3]=1;
else
e[3]=0;
}
public static void initAction(byte [][] state)
{
byte count = 0;
for(byte i=0;i&lt;2;++i)
for(byte j=0;j&lt;2;++j)
{
state[count][0] = i;
state[count][1] = j;
++count;
}
}
public static void initState(byte [][] state)
{
byte count = 0;
for(byte i=0;i&lt;2;++i)
for(byte j=0;j&lt;2;++j)
for(byte k=0;k&lt;2;++k)
for(byte l=0;l&lt;2;++l)
{
state[count][0] = i;
state[count][1] = j;
state[count][2] = k;
state[count][3] = l;
5
++count;
}
}
public static void setRandomValues(float [][] Q)
{
for(byte i=0;i=0)
{
r = getRewardValue(e);
a1 = getMaxAction(j);
Q[a][i] = Q[a][i] + LEARN_RATE * (r + Q[a1][j] - Q[a][i]);
// Q["+a+"]["+i+"] = " + System.out.println(""+Q[a][i]);
}
i = j;
// GREEDY
float rand = (float)Math.random();
if(rand &gt; EXPLORE_RATE)
{
a = getMaxAction(j);
//System.out.println("Q["+a+"]["+j+"] = " + Q[a][j]);
}
// E-GREEDY
else
a = (byte)(Math.random() * 4);
buzzer.beep();
return a;
}
// find the largest Q-value for a given state (j), and return action
public byte getMaxAction(byte state)
8
{
float max = -1000;
byte action = 0;
for(byte a=0;a max)
{
max = Q[a][state];
action = a;
}
}
return action;
}
public byte getState(byte [] e)
{
byte count = 0;
for(byte i=0;i&lt;2;++i)
for(byte j=0;j&lt;2;++j)
for(byte k=0;k&lt;2;++k)
for(byte l=0;l&lt;2;++l)
{
if (e[0] == state[count][0])
if (e[1] == state[count][1])
if (e[2] == state[count][2])
if (e[3] == state[count][3])
return count;
++count;
}
return -1;
}
public float getRewardValue(byte [] e)
{
byte reward=0;
if(a==0)
reward += 3; // good reward
if (e[0] == 1||e[1] == 1||e[2] == 1||e[3] == 1)
reward -= 2; // give bad reward: penalize
return reward ;
}
}</pre>
<p>To view the Result of the intellibrain Neural Network Programming on ai Robots.  Click <a href="http://www.icpep.org/robot-kits/"> here</a></p>
<p class="buymebeer"><form action="https://www.paypal.com/cgi-bin/webscr" target="paypal" method="post"><input type="hidden" name="cmd" value="_xclick" /><input type="hidden" name="business" value="allajosephcagadas@gmail.com" /><input type="hidden" name="return" value="" /><input type="hidden" name="item_name" value="Can You Buy Me a Beer? for Neural Network Programming" /><input type="hidden" name="currency_code" value="USD" /><input type="hidden" name="amount" value="" /><input type="image" src="http://www.icpep.org/wp-content/plugins/buy-me-beer/icon_beer.gif" align="left" alt="Buy Me a Beer" title="Buy Me a Beer" hspace="3" /></form><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=allajosephcagadas@gmail.com&amp;currency_code=USD&amp;amount=&amp;return=&amp;item_name=Can+You+Buy+Me+a+Beer?+for+Neural+Network+Programming" target="paypal">Did find the post very useful? Maybe you want to buy me a glass of beer!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.icpep.org/neural-network-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
