nomad
22-03-2008, 10:06
hi leute,
beschaeftige mich z.Z. mit Learning-Algos.
hab im web dazu ein java-prog gefunden. -> BotQLearning.java ss.Attachment ->
um dieses prog unter <C> verwenden zu koennen hab ich mich daran gemacht die einzelnen java-teile
als c-proceduren zu verwandeln.
ging gestern ganz gut:
ausser einen grossen compiler fehler:
qLearningSystem10.c: In function ‘updateQ’:
qLearningSystem10.c:569: error: invalid operands to binary *
in anweisung:
Q[s1Old][s2Old][move]=oldStateValue+alpha*(aReward+gamma*getMaxQ(s1Cur, s2Cur)-oldStateValue);
ich komm einfach nicht dahinter wie man diesen fehler beheben koennte:
Also:
1) java-code:
double updateQ(int move)
{
int s1Old=s1Cur, s2Old=s2Cur;
double oldStateValue, aReward;
System.out.println("updateQ");
if (move==indefinite) move=chooseMovement(s1Cur,s2Cur);
switch (move)
{
case armMinus: s1Cur--; break;
case armPlus: s1Cur++; break;
case handMinus: s2Cur--; break;
case handPlus: s2Cur++; break;
}
//
// Inside the paper about Q-learning, we are using a special notation.
// The correspondence between this notation and the variables of the
// program is the following:
// y = (s1cur,s2cur)
// x = (s1Old,s2old)
// a = move
// Q^*(x,a) = Q[s1Old][s2Old][move]
// V^*(y) = getMaxQ(s1Cur,s2Cur)
// r = aReward
//
oldStateValue=Q[s1Old][s2Old][move];
aReward=reward(s1Old,s2Old,s1Cur,s2Cur);
Xpos+=aReward;
--> Q[s1Old][s2Old][move]=oldStateValue+alpha*(aReward
+gamma*getMaxQ(s1Cur,s2Cur)
-oldStateValue);
System.out.println(Q[s1Old][s2Old][move]);
return aReward;
}
2) mein c-code
double updateQ(int move)
{
int s1Old=s1Cur, s2Old=s2Cur;
double oldStateValue;
//double aReward;
printf("updateQ");
if(move==indefinite) move=chooseMovement(s1Cur,s2Cur);
switch (move)
{
case 0: s1Cur--; break; // armMinus
case 1: s1Cur++; break; // armPlus
case 2: s2Cur--; break; // handMinus
case 3: s2Cur++; break; // handPlus
}
//
// Inside the paper about Q-learning, we are using a special notation.
// The correspondence between this notation and the variables of the
// program is the following:
// y = (s1cur,s2cur)
// x = (s1Old,s2old)
// a = move
// Q^*(x,a) = Q[s1Old][s2Old][move]
// V^*(y) = getMaxQ(s1Cur,s2Cur)
// r = aReward
//
oldStateValue = Q[s1Old][s2Old][move];
aReward = reward(s1Old,s2Old,s1Cur,s2Cur);
reward(s1Old,s2Old,s1Cur,s2Cur);
Xpos += aReward;
// FEHLER with error: invalid operands to binary *
Q[s1Old][s2Old][move] = oldStateValue+alpha*(aReward+gamma*getMaxQ(s1Cur,s 2Cur)-oldStateValue);
return aReward;
}
koennt mir mir bitte helfen diesen fehler zu beheben.
ohne diese funktion ist das ganze sinnlos.
ist es ueberhaupt moeglich, mit meiner zugegebenen blauaeugige
vorgehensweise dieses c-prog zu entwickeln.
waere um jede hilfe und tips sehr dankbar
frohe ostern
gruss
nomad
attachments:
- BotQLearning-java.txt
- gRLearning10-c.txt
beschaeftige mich z.Z. mit Learning-Algos.
hab im web dazu ein java-prog gefunden. -> BotQLearning.java ss.Attachment ->
um dieses prog unter <C> verwenden zu koennen hab ich mich daran gemacht die einzelnen java-teile
als c-proceduren zu verwandeln.
ging gestern ganz gut:
ausser einen grossen compiler fehler:
qLearningSystem10.c: In function ‘updateQ’:
qLearningSystem10.c:569: error: invalid operands to binary *
in anweisung:
Q[s1Old][s2Old][move]=oldStateValue+alpha*(aReward+gamma*getMaxQ(s1Cur, s2Cur)-oldStateValue);
ich komm einfach nicht dahinter wie man diesen fehler beheben koennte:
Also:
1) java-code:
double updateQ(int move)
{
int s1Old=s1Cur, s2Old=s2Cur;
double oldStateValue, aReward;
System.out.println("updateQ");
if (move==indefinite) move=chooseMovement(s1Cur,s2Cur);
switch (move)
{
case armMinus: s1Cur--; break;
case armPlus: s1Cur++; break;
case handMinus: s2Cur--; break;
case handPlus: s2Cur++; break;
}
//
// Inside the paper about Q-learning, we are using a special notation.
// The correspondence between this notation and the variables of the
// program is the following:
// y = (s1cur,s2cur)
// x = (s1Old,s2old)
// a = move
// Q^*(x,a) = Q[s1Old][s2Old][move]
// V^*(y) = getMaxQ(s1Cur,s2Cur)
// r = aReward
//
oldStateValue=Q[s1Old][s2Old][move];
aReward=reward(s1Old,s2Old,s1Cur,s2Cur);
Xpos+=aReward;
--> Q[s1Old][s2Old][move]=oldStateValue+alpha*(aReward
+gamma*getMaxQ(s1Cur,s2Cur)
-oldStateValue);
System.out.println(Q[s1Old][s2Old][move]);
return aReward;
}
2) mein c-code
double updateQ(int move)
{
int s1Old=s1Cur, s2Old=s2Cur;
double oldStateValue;
//double aReward;
printf("updateQ");
if(move==indefinite) move=chooseMovement(s1Cur,s2Cur);
switch (move)
{
case 0: s1Cur--; break; // armMinus
case 1: s1Cur++; break; // armPlus
case 2: s2Cur--; break; // handMinus
case 3: s2Cur++; break; // handPlus
}
//
// Inside the paper about Q-learning, we are using a special notation.
// The correspondence between this notation and the variables of the
// program is the following:
// y = (s1cur,s2cur)
// x = (s1Old,s2old)
// a = move
// Q^*(x,a) = Q[s1Old][s2Old][move]
// V^*(y) = getMaxQ(s1Cur,s2Cur)
// r = aReward
//
oldStateValue = Q[s1Old][s2Old][move];
aReward = reward(s1Old,s2Old,s1Cur,s2Cur);
reward(s1Old,s2Old,s1Cur,s2Cur);
Xpos += aReward;
// FEHLER with error: invalid operands to binary *
Q[s1Old][s2Old][move] = oldStateValue+alpha*(aReward+gamma*getMaxQ(s1Cur,s 2Cur)-oldStateValue);
return aReward;
}
koennt mir mir bitte helfen diesen fehler zu beheben.
ohne diese funktion ist das ganze sinnlos.
ist es ueberhaupt moeglich, mit meiner zugegebenen blauaeugige
vorgehensweise dieses c-prog zu entwickeln.
waere um jede hilfe und tips sehr dankbar
frohe ostern
gruss
nomad
attachments:
- BotQLearning-java.txt
- gRLearning10-c.txt