Skip to content

Commit e68d795

Browse files
committed
visualize runs with an off by 1 error
1 parent 590631b commit e68d795

File tree

5 files changed

+56
-36
lines changed

5 files changed

+56
-36
lines changed

pr2-scripts/snapshot-viz/js/viz-d3v4.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ function drawFullGraph(s) {
5858
node2id = {};
5959

6060
var i = 0;
61-
for (var nid in snapshots[s].solution.prpsearchnodes) {
62-
n = snapshots[s].solution.prpsearchnodes[nid]; // not doing anything with this for now
61+
for (var nid in snapshots[s].solution.pr2searchnodes) {
62+
n = snapshots[s].solution.pr2searchnodes[nid]; // not doing anything with this for now
6363
nodes.push({name: n.name, id: i, weight: 1});
6464
node2id[nid] = i;
6565
i++;
6666
}
6767

68-
for (i = 0; i < snapshots[s].solution.prpsearchnodelinks.length; ++i) {
69-
e = snapshots[s].solution.prpsearchnodelinks[i];
68+
for (i = 0; i < snapshots[s].solution.pr2searchnodelinks.length; ++i) {
69+
e = snapshots[s].solution.pr2searchnodelinks[i];
7070
links.push({source:node2id[e[0]], target:node2id[e[1]], id: i});
7171
}
7272

pr2-scripts/snapshot-viz/js/viz-dagre.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ function drawFullGraph(s) {
6262

6363
var node2id = {};
6464
var i = 1;
65-
for (var nid in snapshots[s].solution.prpsearchnodes) {
65+
for (var nid in snapshots[s].solution.pr2searchnodes) {
6666
node2id[nid] = i;
67-
g.setNode(i, {label:"<div>"+snapshots[s].solution.prpsearchnodes[nid].name+"</div>", labelType: "html"});
68-
//console.log(snapshots[s].solution.prpsearchnodes[nid].name);
67+
g.setNode(i, {label:"<div>"+snapshots[s].solution.pr2searchnodes[nid].name+"</div>", labelType: "html"});
68+
//console.log(snapshots[s].solution.pr2searchnodes[nid].name);
6969
}
70-
for (i = 0; i < snapshots[s].solution.prpsearchnodelinks.length; ++i)
71-
g.setEdge(node2id[snapshots[s].solution.prpsearchnodelinks[i][0]],
72-
node2id[snapshots[s].solution.prpsearchnodelinks[i][1]],
70+
for (i = 0; i < snapshots[s].solution.pr2searchnodelinks.length; ++i)
71+
g.setEdge(node2id[snapshots[s].solution.pr2searchnodelinks[i][0]],
72+
node2id[snapshots[s].solution.pr2searchnodelinks[i][1]],
7373
{label:''+i});
7474

7575
render(svgGroup, g);
@@ -97,15 +97,15 @@ function drawFullGraph(s) {
9797
node2id = {};
9898

9999
var i = 0;
100-
for (var nid in snapshots[s].solution.prpsearchnodes) {
101-
n = snapshots[s].solution.prpsearchnodes[nid]; // not doing anything with this for now
100+
for (var nid in snapshots[s].solution.pr2searchnodes) {
101+
n = snapshots[s].solution.pr2searchnodes[nid]; // not doing anything with this for now
102102
nodes.push({name: n.name, id: i, weight: 1});
103103
node2id[nid] = i;
104104
i++;
105105
}
106106

107-
for (i = 0; i < snapshots[s].solution.prpsearchnodelinks.length; ++i) {
108-
e = snapshots[s].solution.prpsearchnodelinks[i];
107+
for (i = 0; i < snapshots[s].solution.pr2searchnodelinks.length; ++i) {
108+
e = snapshots[s].solution.pr2searchnodelinks[i];
109109
links.push({source:node2id[e[0]], target:node2id[e[1]], id: i});
110110
}
111111

pr2-scripts/snapshot-viz/js/viz.js

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function drawSnapshot(s, round) {
107107
$('#snapshotList'+round + ' a').removeClass('active');
108108
$('#snapshotButton'+round+'-'+s).addClass('active');
109109

110+
console.log(snapshots[s]);
110111
drawFullGraph(s);
111112
drawPSGraph(s);
112113
};
@@ -249,8 +250,6 @@ function initializeGraphs() {
249250
});
250251
};
251252

252-
253-
254253
function drawFullGraph(s) {
255254

256255
fsnodes = []; // The actual nodes of the graph
@@ -263,29 +262,33 @@ function drawFullGraph(s) {
263262
newfspaths = {}; // The links that were newly added in this snapshot
264263
var fs2ps = {}; // Mapping from the full state graph to the partial state graph
265264

265+
//Checks if nodes are new nodes
266266
if ((s-1 in snapshots) && (snapshots[s].solution.round == snapshots[s-1].solution.round))
267-
for (n in snapshots[s].solution.prpsearchnodes)
268-
if (!(n in snapshots[s-1].solution.prpsearchnodes))
267+
for (n in snapshots[s].solution.pr2searchnodes)
268+
if (!(n in snapshots[s-1].solution.pr2searchnodes))
269269
newfsnodes[n] = true;
270270

271+
//Maps partial states and full states
271272
for (var psid in snapshots[s].solution.ps2fs)
272273
for (var fsid in snapshots[s].solution.ps2fs[psid])
273274
fs2ps[fsid] = psid;
274275

276+
//initialize nodes
275277
var i = 0;
276-
for (var nid in snapshots[s].solution.prpsearchnodes) {
277-
n = snapshots[s].solution.prpsearchnodes[nid]; // not doing anything with this for now
278+
for (var nid in snapshots[s].solution.pr2searchnodes) {
279+
n = snapshots[s].solution.pr2searchnodes[nid]; // not doing anything with this for now
278280
fsnodes.push({origname: n.name, name: n.name, id: i, weight: 1, nid: nid, psid: fs2ps[nid],
279281
open:n.open, subsumed:n.subsumed, poisoned:n.poisoned});
280282
fsnode2id[nid] = i;
281283
fssucc[i] = [];
282284
fspred[i] = [];
283285
i++;
284286
}
287+
288+
//find successors and previous nodes
289+
for (i = 0; i < snapshots[s].solution.pr2searchnodelinks.length; ++i) {
285290

286-
for (i = 0; i < snapshots[s].solution.prpsearchnodelinks.length; ++i) {
287-
288-
e = snapshots[s].solution.prpsearchnodelinks[i];
291+
e = snapshots[s].solution.pr2searchnodelinks[i];
289292
var u = fsnode2id[e[0]];
290293
var v = fsnode2id[e[1]];
291294

@@ -297,12 +300,12 @@ function drawFullGraph(s) {
297300

298301
if ((s-1 in snapshots) && (snapshots[s].solution.round == snapshots[s-1].solution.round)) {
299302
var oldpaths = {};
300-
for (i = 0; i < snapshots[s-1].solution.prpsearchnodelinks.length; ++i) {
301-
e = snapshots[s-1].solution.prpsearchnodelinks[i];
303+
for (i = 0; i < snapshots[s-1].solution.pr2searchnodelinks.length; ++i) {
304+
e = snapshots[s-1].solution.pr2searchnodelinks[i];
302305
oldpaths[fsnode2id[e[0]] + "-" + fsnode2id[e[1]]] = true;
303306
}
304-
for (i = 0; i < snapshots[s].solution.prpsearchnodelinks.length; ++i) {
305-
e = snapshots[s].solution.prpsearchnodelinks[i];
307+
for (i = 0; i < snapshots[s].solution.pr2searchnodelinks.length; ++i) {
308+
e = snapshots[s].solution.pr2searchnodelinks[i];
306309
if (!(fsnode2id[e[0]] + "-" + fsnode2id[e[1]] in oldpaths))
307310
newfspaths[fsnode2id[e[0]] + "-" + fsnode2id[e[1]]] = true;
308311
}
@@ -477,27 +480,30 @@ function drawPSGraph(s) {
477480
var ncount = 0;
478481
for (var nid in snapshots[s].solution.psgraph.nodes) {
479482
n = snapshots[s].solution.psgraph.nodes[nid];
483+
nid = String(parseInt(nid) - 1);
480484
nname = n.action + ' ('+n.distance+')';
481485
init = false;
482486
if (n.distance == 0)
483487
nname = 'Goal';
484488
if (nid == snapshots[s].solution.psgraph.init)
485489
init = true;
486490
psnodes.push({id: ncount, origname: nname, name: nname, data: n, init: init, weight: n.distance, nid: nid, sink:false});
487-
psnode2id[''+nid] = ncount;
491+
psnode2id['' + nid] = ncount;
488492
pssucc[ncount] = [];
489493
pspred[ncount] = [];
490494
ncount++;
491495
}
492496

493497
for (var i = 0; i < snapshots[s].solution.psgraph.edges.length; ++i) {
494498
e = snapshots[s].solution.psgraph.edges[i];
499+
console.log(e);
495500

496501
if (">" === e[1]) {
497502

498503
var u, v;
499504

500505
if (-1 == e[2]) {
506+
console.log("path 1");
501507
var nid = "undefined"+ncount;
502508
psnodes.push({id:ncount, origname: "undefined", name: "undefined", weight: 0, nid: nid, sink:true});
503509
psnode2id[nid] = ncount;
@@ -507,15 +513,28 @@ function drawPSGraph(s) {
507513
v = ncount;
508514
ncount++;
509515
} else {
516+
console.log("path 2");
510517
u = psnode2id[e[0]];
511518
v = psnode2id[e[2]];
512519
}
513520

514-
pslinks.push({source:u, target:v, id: u+'-'+v});
515-
516-
pssucc[u].push(v);
517-
pspred[v].push(u);
518-
521+
console.log(u);
522+
console.log(v);
523+
524+
console.log(psnodes);
525+
console.log(pslinks);
526+
console.log(pssucc);
527+
console.log(pspred);
528+
console.log(psstates);
529+
console.log(newpsnodes);
530+
console.log(newpspaths);
531+
console.log(psnode2id);
532+
533+
if (!(u === undefined || v === undefined)) {
534+
pslinks.push({ source: u, target: v, id: u + '-' + v });
535+
pssucc[u].push(v);
536+
pspred[v].push(u);
537+
}
519538
}
520539
}
521540

@@ -539,7 +558,7 @@ function drawPSGraph(s) {
539558
function gen_path(id) {
540559
// Base case is when this node isn't a 1-in / 1-out
541560
if ((1 != pssucc[id].length) || ((1 != pspred[id].length))) {
542-
return [id, ''];
561+
// return [id, ''];
543562
// Only use this label if it is the initial search node
544563
if (0 == pspred[id].length)
545564
return [id, '\n'+psnodes[id].origname];

src/deadend.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ void update_deadends(vector< DeadendTuple* > &failed_states) {
158158
PR2.deadend.nondetop2fsaps[fsap->get_index()]->push_back(fsap);
159159

160160
PR2.deadend.policy->update_policy(fsaps);
161-
for (auto fsap : PR2.deadend.policy->all_items)
162-
std::cout << fsap->get_index() << endl;
163161
PR2.deadend.states->update_policy(deadends);
164162
}
165163

src/partial_state_graph.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,13 @@ void PSGraph::record_snapshot(ofstream &outfile, string indent, bool keyname) {
293293
// Print out the nodes
294294
outfile << "," << endl << indent << " \"nodes\" : {" << endl;
295295
bool first = true;
296+
bool second = true;
296297
for (auto n : steps) {
297298
if (n) {
298299
if (first)
299300
first = false;
301+
else if (second)
302+
second = false;
300303
else
301304
outfile << "," << endl;
302305
n->record_snapshot(outfile, indent+" ");

0 commit comments

Comments
 (0)