[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory
TraceAnalyser.java, 1.10, 1.11
Chien-Liang Fok
chien-liang at users.sourceforge.net
Tue Apr 11 08:26:59 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/DirectoryService/GetClosestAgent
Querier 10s.ma, NONE, 1.1 Intruder.ma, 1.1, 1.2 Querier 1s.ma,
1.3, 1.4
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/DirectoryService/GetAgents
Intruder 10s.ma, NONE, 1.1 Intruder 1s.ma, NONE,
1.1 Intruder 5s.ma, NONE, 1.1 Querier 10s.ma, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27460/edu/wustl/mobilab/directory
Modified Files:
TraceAnalyser.java
Log Message:
Index: TraceAnalyser.java
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/wustl/tools/java/edu/wustl/mobilab/directory/TraceAnalyser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** TraceAnalyser.java 11 Apr 2006 06:06:11 -0000 1.10
--- TraceAnalyser.java 11 Apr 2006 15:26:55 -0000 1.11
***************
*** 105,109 ****
log("Bad Result: (" + line.loc.getx() + ", " + line.loc.gety() + "), Reality: (" + intruderLoc.getx() + ", " + intruderLoc.gety() + "), Dist: " + line.loc.dist(intruderLoc));
numBadQueries++;
! errorSum = line.loc.dist(intruderLoc);
}
} else
--- 105,109 ----
log("Bad Result: (" + line.loc.getx() + ", " + line.loc.gety() + "), Reality: (" + intruderLoc.getx() + ", " + intruderLoc.gety() + "), Dist: " + line.loc.dist(intruderLoc));
numBadQueries++;
! errorSum += line.loc.dist(intruderLoc);
}
} else
***************
*** 115,143 ****
if (line.agentID == QUERIER_AGENT_ID) {
if (line.success) {
// Check to see whether there is an agent at the specified location
! if (agentLocTable.containsValue(line.loc)) {
! AgillaLocation qLoc = agentLocTable.get(new AgillaAgentID(QUERIER_AGENT_ID));
double closestDist = qLoc.dist(line.loc);
- boolean goodResult = true;
! for (Enumeration<AgillaAgentID> keys = agentLocTable.keys(); goodResult && keys.hasMoreElements();) {
! AgillaAgentID aid = keys.nextElement();
! if (aid.getID() != QUERIER_AGENT_ID) {
! if (agentLocTable.get(aid).dist(qLoc) < closestDist) {
! goodResult = false;
! log("Detected a bad GetClosestAgent result:");
! log("\tLocation of the querier: " + qLoc);
! log("\tReported location of closest agent: " + line.loc + " (" + closestDist + ")");
! log("\tEven closer agent at: " + agentLocTable.get(aid) + " (" + agentLocTable.get(aid).dist(qLoc) + ")");
! }
! }
! }
! if (goodResult)
! numGoodQueries++;
! else
numBadQueries++;
} else {
! log("GetClosestAgent returned a location " + line.loc + " where there is no agent.");
numBadQueries++;
}
} else
--- 115,144 ----
if (line.agentID == QUERIER_AGENT_ID) {
if (line.success) {
+ AgillaLocation qLoc = agentLocTable.get(new AgillaAgentID(QUERIER_AGENT_ID));
+
// Check to see whether there is an agent at the specified location
! if (agentLocTable.containsValue(line.loc)) {
double closestDist = qLoc.dist(line.loc);
! // See if there are any agents closer to the specified agent
! AgillaLocation closestNode = findClosestAgent(qLoc);
! if (closestNode.dist(qLoc) < closestDist) {
! log("Detected a bad GetClosestAgent result:");
! log("\tQuerier location: " + qLoc);
! log("\tReported closest agent location: " + line.loc + " (" + closestDist + ")");
! log("\tEven closer agent at: (" + closestNode.getx() + ", " + closestNode.gety() + "), dist = " + closestNode.dist(qLoc));
numBadQueries++;
+ errorSum += closestDist - closestNode.dist(qLoc);
+ } else {
+ numGoodQueries++;
+ }
} else {
! log(line.timeStamp + " GetClosestAgent returned (" + line.loc.getx() + ", " +
! line.loc.gety() + ") at which there is no agent.");
! AgillaLocation closestAgent = findClosestAgent(qLoc);
! double error = Math.abs(qLoc.dist(line.loc) - qLoc.dist(closestAgent));
! log("\tError amount: " + error);
numBadQueries++;
+ errorSum += error;
}
} else
***************
*** 146,150 ****
}
! if (line.action.equals("QUERY_GET_CLOSEST_AGENT_RESULTS_RECEIVED")) {
if (line.agentID == QUERIER_AGENT_ID) {
--- 147,151 ----
}
! if (line.action.equals("QUERY_GET_AGENTS_RESULT_RECEIVED")) {
if (line.agentID == QUERIER_AGENT_ID) {
***************
*** 163,166 ****
--- 164,193 ----
}
+ /**
+ * Finds the location of the agent closest to the specified location.
+ *
+ * @param qLoc The relative location.
+ * @return The location closest to qLoc.
+ */
+ private AgillaLocation findClosestAgent(AgillaLocation qLoc) {
+ AgillaLocation closestLoc = null;
+ double dist = 0;
+
+ for (Enumeration<AgillaAgentID> keys = agentLocTable.keys(); keys.hasMoreElements();) {
+ AgillaAgentID aid = keys.nextElement();
+ if (aid.getID() != QUERIER_AGENT_ID) {
+ AgillaLocation currLoc = agentLocTable.get(aid);
+ if (closestLoc == null) {
+ closestLoc = currLoc;
+ dist = currLoc.dist(qLoc);
+ } else if (currLoc.dist(qLoc) < dist) {
+ closestLoc = currLoc;
+ dist = currLoc.dist(qLoc);
+ }
+ }
+ }
+ return closestLoc;
+ }
+
private class TraceLine implements Comparable<TraceLine> {
long timeStamp;
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/DirectoryService/GetClosestAgent
Querier 10s.ma, NONE, 1.1 Intruder.ma, 1.1, 1.2 Querier 1s.ma,
1.3, 1.4
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/DirectoryService/GetAgents
Intruder 10s.ma, NONE, 1.1 Intruder 1s.ma, NONE,
1.1 Intruder 5s.ma, NONE, 1.1 Querier 10s.ma, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list