Package cu.repsystestbed.graphs

Examples of cu.repsystestbed.graphs.ReputationEdge


   
    ArrayList<Agent> trustedAgents = new ArrayList<Agent>(numberOfAgentsToBeTrusted);
   
    for(int i=0;i<numberOfAgentsToBeTrusted;i++)
    {
      ReputationEdge trustedEdge = outGoingEdgesList.get(outGoingEdgesList.size() - 1 - i);
      trustedAgents.add((Agent) trustedEdge.sink);
//      logger.info("Added " + (Agent) trustedEdge.sink + "as trusted.");
    }
   
    for(Agent trustedAgent : trustedAgents)
View Full Code Here


          }
         
          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;
View Full Code Here

          }
         
          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;
View Full Code Here

                FeedbackHistoryGraphEdge fhe = (FeedbackHistoryGraphEdge) e;
                display += "Feedbacks: "  + fhe.toString3() + "\n";
              }
              else if(e instanceof ReputationEdge)
              {
                ReputationEdge re = (ReputationEdge) e;
                display += "Reputation: "  + re.getReputation() + "\n";
              }
             
            }
           
            display += "--";
           
            edges = m_viewer.m_graphModel.outgoingEdgesOf(new Agent(agentId));
            Util.assertNotNull(edges);
            if(edges.size() > 0)
            {
              display += "\n" + "Outgoing Edges:" + "\n";
            }
           
            for(TestbedEdge e : edges)
            {
              display += e.sink + "\n";
              if(e instanceof FeedbackHistoryGraphEdge)
              {
                FeedbackHistoryGraphEdge fhe = (FeedbackHistoryGraphEdge) e;
                display += "Feedbacks: "  + fhe.toString3() + "\n";
              }
              else if(e instanceof ReputationEdge)
              {
                ReputationEdge re = (ReputationEdge) e;
                display += "Reputation: "  + re.getReputation() + "\n";
              }
            }
           
            m_infoTextBox.setText(display);
         
View Full Code Here

        HashSet<ReputationEdge> outgoingEdges2 = new HashSet<ReputationEdge>(outgoingEdges1);
        for(ReputationEdge edge : outgoingEdges1)
        {
          if(!v_1.contains(edge.sink))
          {
            ReputationEdge e = new ReputationEdge((Agent) edge.sink, s);
            e.setReputation(1);
            outgoingEdges2.add(e);
          }
        }
       
        //calculate the sum of edge weights
View Full Code Here

        {
          repGraph.addVertex(sink);
        }
       
        repGraph.addEdge(src, sink);
        ReputationEdge repEdge = (ReputationEdge) repGraph.getEdge(src, sink);
        repEdge.setReputation(reputation);
        System.out.println(repGraph);
      }
     
      return repGraph;
View Full Code Here

                !(m_graph2Output.getEdge(src, sink) instanceof ReputationEdge))
            {
              throw new GenericTestbedException("Expected edge type is ReputationEdge.");
            }
           
            ReputationEdge repEdge = (ReputationEdge) m_graph2Output.getEdge(src, sink);
           
            //repEdge may be null. all edges in the graph this alg listens to may have been added but that is not
            //reflected in the reputation graph edge. So reputationGraph.getEdge(src, sink) may return null.
           
            if(repEdge==null)
            {
              if(!m_graph2Output.containsVertex(src)) m_graph2Output.addVertex(src);
              if(!m_graph2Output.containsVertex(sink)) m_graph2Output.addVertex(sink);
              m_graph2Output.addEdge(src, sink)
              repEdge = (ReputationEdge) m_graph2Output.getEdge(src, sink)
            }
           
            repEdge.setReputation(trustScore);
            m_graph2Output.setEdgeWeight(repEdge, trustScore);
            edgesTobeUpdated.add(repEdge);
          }
        }
      }
    }else if(outputGraphType == OutputGraphType.TRANSITIVE_GRAPH)
    {
     
      /**
       * Calculate trust scores of sink agents that are reachable from the source.
       * that is determine the transitive closure of the graph that this alg listens to
       * and set the weights of the edges.
       */
     
      Graph transitiveGraph = m_graph2Listen.getTransitiveClosureGraph();
      
      for(Agent src : agents)
      {
        Set<TestbedEdge> outgoingEdges = transitiveGraph.outgoingEdgesOf(src);
        for(TestbedEdge e : outgoingEdges)
        {
          double trustScore = calculateTrustScore(src, (Agent)e.sink);
          if(!assertVariablePrecondition(trustScore))
          {
            throw new GenericTestbedException("Failed postconditions: assertVariablePrecondition()");
          }
         
          if(!((ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink) instanceof ReputationEdge))
          {
            throw new GenericTestbedException("Expected edge type is ReputationEdge.");
          }
         
          ReputationEdge repEdge = (ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink);
         
          //repEdge may be null. see setFeedbackHistoryGraph(). a feedback history graph edge may have been added but that is not
          //reflected in the reputation graph edge. So reputationGraph.getEdge(src, sink) may return null.
         
          if(repEdge==null)
          {
            if(!m_graph2Output.containsVertex(src)) m_graph2Output.addVertex(src);
            if(!m_graph2Output.containsVertex((Agent)e.sink)) m_graph2Output.addVertex((Agent)e.sink);
            m_graph2Output.addEdge(src, (Agent)e.sink);
            repEdge = (ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink);
            repEdge.setReputation(trustScore);
          }
          m_graph2Output.setEdgeWeight(repEdge, trustScore);
          edgesTobeUpdated.add(repEdge);
         
        }
      }
    }
    else
    {
      for(Agent src : agents)
      {
        Set<TestbedEdge> outgoingEdges = super.m_graph2Listen.outgoingEdgesOf(src);
        for(TestbedEdge e : outgoingEdges)
        {
          double trustScore = calculateTrustScore(src, (Agent)e.sink);
          if(!assertVariablePrecondition(trustScore))
          {
            throw new GenericTestbedException("Failed postconditions: assertVariablePrecondition()");
          }
         
          if(!((ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink) instanceof ReputationEdge))
          {
            throw new GenericTestbedException("Expected edge type is ReputationEdge.");
          }
         
          ReputationEdge repEdge = (ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink);
         
          if(repEdge==null)
          {
            if(!m_graph2Output.containsVertex(src)) m_graph2Output.addVertex(src);
            if(!m_graph2Output.containsVertex((Agent)e.sink)) m_graph2Output.addVertex((Agent)e.sink);
            m_graph2Output.addEdge(src, (Agent)e.sink);
            repEdge = (ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink);
            repEdge.setReputation(trustScore);
          }
          m_graph2Output.setEdgeWeight(repEdge, trustScore);
          edgesTobeUpdated.add(repEdge);
        }
      }
View Full Code Here

        if(trustScore < this.MINIMUM_TRUST_SCORE || trustScore > this.MAXIMUM_TRUST_SCORE)
        {
          throw new GenericTestbedException("Algorithm returned a trust score ("
              + trustScore + ")that is not within [0,1]. ");
        }*/
        ReputationEdge repEdge = (ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink);
       
        if(repEdge==null)
        {
          if(!m_graph2Output.containsVertex(src)) m_graph2Output.addVertex(src);
          if(!m_graph2Output.containsVertex((Agent)e.sink)) m_graph2Output.addVertex((Agent)e.sink);
          m_graph2Output.addEdge(src, (Agent)e.sink);
          repEdge = (ReputationEdge) m_graph2Output.getEdge(src, (Agent)e.sink);
          repEdge.setReputation(trustScore);
        }
        m_graph2Output.setEdgeWeight(repEdge, trustScore);
        edgesToBeUpdated.add(repEdge);
      }
    }
View Full Code Here

TOP

Related Classes of cu.repsystestbed.graphs.ReputationEdge

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.