Skip to content

Commit

Permalink
Merge pull request #34 from dityas/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dityas authored Dec 24, 2019
2 parents a710f26 + c1cc5fe commit 565e9cb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
Binary file modified Protos/build/Protos.jar
Binary file not shown.
12 changes: 10 additions & 2 deletions Protos/src/thinclab/belief/SSGABeliefExpansion.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,20 @@ public SSGABeliefExpansion(POMDP p, int maxDepth, int iterations) {
this.allPossibleObs = this.p.getAllPossibleObservations();
this.nIterations = iterations;

/* add initial beliefs from the POMDP */
/*
* Run a full belief expansion for 3 time steps to facilitate proper exploration
*/

FullBeliefExpansion fb = new FullBeliefExpansion(this.p, 3);
fb.expand();

this.initialBeliefs = new ArrayList<DD>();
this.initialBeliefs.addAll(this.p.getInitialBeliefs());

this.exploredBeliefs = new HashSet<DD>();
this.exploredBeliefs.addAll(this.p.getInitialBeliefs());
this.exploredBeliefs.addAll(fb.getBeliefPoints());

fb = null;

logger.debug("SSGA expansion search initialized");
}
Expand Down
26 changes: 20 additions & 6 deletions Protos/src/thinclab/representations/StructuredTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,29 @@ public static String jsonBeliefStringToDotNode(String beliefString, String actio
for (JsonElement mj: mjArray) {

/* convert to JSON object */
JsonObject mjJSON = mj.getAsJsonObject();
JsonObject mjJSON = mj.getAsJsonObject();

JsonObject mjBeliefMap =
mjJSON.get("model")
.getAsJsonObject()
.get("belief_j")
.getAsJsonObject();

/* Print each belief on a new line for Mj */
String mjString = "";

for (String state : mjBeliefMap.keySet())
mjString +=
state
+ seperator
+ gsonHandler.toJson(mjBeliefMap.get(state))
.replace("{", "(")
.replace("}", ")")
+ seperator;

dotString +=
seperator + "{" +
"{" + gsonHandler.toJson(
mjJSON.get("model").getAsJsonObject().get("belief_j"))
.replace("{", "(")
.replace("}", ")")

"{" + mjString
+ seperator + gsonHandler.toJson(
mjJSON.get("model").getAsJsonObject().get("A_j"))
+ seperator + gsonHandler.toJson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void testSSGABeliefExpansion() {

LOGGER.info("Testing initial beliefs");
List<DD> beliefs0 = ssgaBE.getBeliefPoints();
assertTrue(beliefs0.size() == this.pomdp.getInitialBeliefs().size());
assertTrue(beliefs0.size() >= this.pomdp.getInitialBeliefs().size());

LOGGER.info("Testing policy based expansion");
LOGGER.info("computing policy...");
Expand Down
4 changes: 2 additions & 2 deletions Protos/src/thinclab/tests/TestIPOMDP.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ void testIPOMDPsteppingSingleFrame() throws Exception {
Random rand = new Random();

/* run for 100 iters */
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 5; i++) {

List<String> actions = ipomdp.getActions();
String action = actions.get(rand.nextInt(actions.size()));
Expand Down Expand Up @@ -700,7 +700,7 @@ void testIPOMDPstepping2Frames() throws Exception {
Random rand = new Random();

/* run for 100 iters */
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 5; i++) {

List<String> actions = ipomdp.getActions();
String action = actions.get(rand.nextInt(actions.size()));
Expand Down

0 comments on commit 565e9cb

Please sign in to comment.