Skip to content

Commit

Permalink
added output of data for regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mensch72 committed Jan 17, 2024
1 parent df9bba0 commit f7e8f14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/runVerySimpleGW.wppl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ var trajDist = Infer({ model() {
return simulate(mdp.startState, aleph0).trajectory;
}}).getDist();

//console.log("trajDist", trajDist);
console.log("\nDATA FOR REGRESSION TESTS: \ntrajDist");
var regressionTestData = webpplAgents.trajDist2simpleJSON(trajDist);
console.log(JSON.stringify(regressionTestData));
console.log("END OF DATA FOR REGRESSION TESTS\n");

var trajData = trajDist2TrajData(trajDist, agent);

Expand Down
20 changes: 20 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var onlyNonnegativeFormat = function (x) {
;
};

var prettyState = function (state) { return "(" + state.loc[0] + "," + state.loc[1] + ")-" + state.timeLeft; };

module.exports = {

emptySet: () => new Set(),
Expand Down Expand Up @@ -155,6 +157,24 @@ module.exports = {
}
},

prettyState,

trajDist2simpleJSON: function(trajDist) {
var keys = Object.keys(trajDist),
result = [];
for (var index in keys) {
var trajString = keys[index],
traj = JSON.parse(trajString),
val = trajDist[trajString],
prob = val.prob,
trajOut = traj.map((stepData) => [prettyState(stepData.state), stepData.action]);
res = [prob, trajOut]
;
result.push(res);
}
return result;
},

// TO BE MOVED TO src/utils/metalog.js:

/* TODO:
Expand Down

0 comments on commit f7e8f14

Please sign in to comment.