{
Util.assertNotNull(m_alg);
}
catch(Exception e)
{
throw new EvaluationException("The inner algorithm is not set. ", e);
}
if(!(m_alg.getGraph2Listen() instanceof FeedbackHistoryGraph))
{
throw new EvaluationException("This evaluation needs a FeedbackHistoryGraph as input.");
}
if(changes != null)
{
if(changes.size() < 1)
{
throw new EvaluationException("Changes is not null but there are no changes.");
}
try
{
for(FeedbackHistoryGraphEdge fhge : (ArrayList<FeedbackHistoryGraphEdge>) changes)
{
EvolData data = dataPoints.remove(getHashCode((Agent)fhge.src, (Agent)fhge.sink));
if(data == null)
{
data = new EvolData(new ArrayList<Double>(), new ArrayList<Double>(),
new ArrayList<Double>(), new ArrayList<Double>());
}
Feedback f1 = null, f0 = null;
double ts1 = Double.MIN_VALUE, ts0 = Double.MIN_VALUE;
if(fhge.feedbacks.size() >= 2)
{
f1 = fhge.feedbacks.get(fhge.feedbacks.size() - 1);
f0 = fhge.feedbacks.get(fhge.feedbacks.size() - 2);
}
ReputationGraph rg = (ReputationGraph) m_alg.getGraph2Output();
Util.assertNotNull(rg);
ReputationEdge re = (ReputationEdge) rg.getEdge((Agent) fhge.src, (Agent) fhge.sink);
Util.assertNotNull(re);
/*
* It is ok to assume that feedback additions results in change in reputation. So we
* can do take the first and the last In fact,
* if this assumption fails, the inner alg does not comply with Marsh's trust evolution
* conditions.
*/
if(re.getReputationHistory().size() >= 2)
{
ts1 = re.getReputationHistory().get(re.getReputationHistory().size() - 1);
ts0 = re.getReputationHistory().get(re.getReputationHistory().size() - 2);
}
if(f1 != null && f0 != null && ts1 > Double.MIN_VALUE && ts0 > Double.MIN_VALUE )
{
double x = f1.value - f0.value;
double y = ts1 - ts0;
if(f1.value > f0.value)
{
logger.info("feedbacks[i+1] is greater than feedbacks[i]");
data.m_positiveXPoints.add(x);
data.m_positiveYPoints.add(y);
}
else if(f1.value < f0.value)
{
logger.info("feedbacks[i+1] is less than feedbacks[i]");
data.m_negativeXPoints.add(x);
data.m_negativeYPoints.add(y);
}
else
{
logger.info("feedbacks[i+1] = feedbacks[i]");
}
}
dataPoints.put(getHashCode((Agent)fhge.src, (Agent)fhge.sink), data);
logger.debug("Data point added. Key=" + getHashCode((Agent)fhge.src, (Agent)fhge.sink) + "Data: " + data);
}
}
catch(ClassCastException e)
{
throw new EvaluationException("Changes does not contain a list of FeedbackHistoryGraphEdge. ", e);
}
}
else
{
logger.info("No changes passed.");