Commit 25a52007 authored by Nicola Gatto's avatar Nicola Gatto

Add ddpg test files

parent 8a8ed262
......@@ -38,6 +38,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertFalse;
......@@ -284,4 +285,12 @@ public class GenerationTest extends AbstractSymtabTest {
} catch(IOException e){
}
}
@Test
public void gluonDdpgTest() {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/reinforcementModel", "-r", "mountaincar.Master", "-b", "GLUON", "-f", "n", "-c", "n"};
EMADLGeneratorCli.main(args);
assertEquals(0, Log.getFindings().stream().filter(Finding::isError).count());
}
}
package mountaincar;
import mountaincar.agent.*;
component Master {
ports
in Q^{2} state,
out Q(-1:1)^{1} action;
instance MountaincarActor actor;
connect state -> actor.state;
connect actor.action -> action;
}
\ No newline at end of file
configuration MountaincarActor {
context : cpu
learning_method : reinforcement
rl_algorithm : ddpg-algorithm
critic : mountaincar.agent.mountaincarCritic
environment : gym {name : "MountainCarContinuous-v0"}
num_episodes : 200
discount_factor : 0.999
num_max_steps : 1000
training_interval : 1
snapshot_interval : 20
loss : euclidean
replay_memory : buffer{
memory_size : 10000
sample_size : 32
}
action_selection : epsgreedy{
epsilon : 1.0
min_epsilon : 0.01
epsilon_decay_method: linear
epsilon_decay : 0.01
}
optimizer : rmsprop{
learning_rate : 0.001
}
}
\ No newline at end of file
package mountaincar.agent;
component MountaincarActor {
ports
in Q^{2} state,
out Q(-1:1)^{1} action;
implementation CNN {
state ->
FullyConnected(units=300) ->
Relu() ->
FullyConnected(units=300) ->
Relu() ->
FullyConnected(units=1) ->
Tanh() ->
action
}
}
\ No newline at end of file
implementation Critic(state, action) {
(state ->
FullyConnected(units=400) ->
Relu() ->
FullyConnected(units=300)
|
action ->
FullyConnected(units=300) ->
) ->
Add() ->
Relu() ->
FullyConnected(units=1) ->
Tanh() ->
critic
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment