Package cu.repsystestbed.exceptions

Examples of cu.repsystestbed.exceptions.EvaluationException


    {
      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.");
View Full Code Here


        continue;
      }
         
      if(Math.abs(nSlope) <= Math.abs(pSlope))
      {
        throw new EvaluationException(" Negative regression line slope (" + nSlope
            + ") is less than positive regression line slope (" + pSlope + ").");
      }
         
      logger.debug("Evaluation passed. Negative regression line slope=" + negative.getSlope()
          + ". Positive regression line slope=" + positive.getSlope());
View Full Code Here

    {
      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)
        {

          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]");
             
              if((ts1 - ts0) <= 0)
              {
                logger.error("trustScore[i+1] is less than trustScore[i]");
                throw new EvaluationException("Feedback change = " + (f1.value - f0.value)
                    + ". Trust score change = " + (ts1 - ts0) + ". Expected an increase in trust score."
                    + " Src = " + fhge.src  + ",Sink = " + fhge.sink);
              }
            }
            else if(f1.value < f0.value)
            {
              logger.info("feedbacks[i+1] is less than feedbacks[i]");
             
              if((ts1 - ts0) >= 0)
              {
                logger.error("trustScore[i+1] is greater or equal to trustScore[i]");
                throw new EvaluationException("Feedback change = " + (f1.value - f0.value)
                    + ". Trust score change = " + (ts1 - ts0) + ". Expected a decrease in trust score."
                    + " Src = " + fhge.src  + ",Sink = " + fhge.sink);
              }
            }
            else
            {
              logger.info("feedbacks[i+1] = feedbacks[i]");
           
          }
         
        }
      }
      catch(ClassCastException e)
      {
        throw new EvaluationException("Changes does not contain a list of FeedbackHistoryGraphEdge. ", e);
      }
     
    }
    else
    {
View Full Code Here

TOP

Related Classes of cu.repsystestbed.exceptions.EvaluationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.