Package cu.repsystestbed.graphs

Examples of cu.repsystestbed.graphs.ReputationGraph


          {
            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,
View Full Code Here


  {
    BasicConfigurator.configure();
   
    // create the graphs
    FeedbackHistoryGraph feedbackHistoryGraph = new FeedbackHistoryGraph(new FeedbackHistoryEdgeFactory());
    ReputationGraph repGraph = new ReputationGraph(new ReputationEdgeFactory());
    TrustGraph trustGraph = new TrustGraph(new TrustEdgeFactory());
   
    // populate the feedback history graph by parsing the feedbacks from a arff file
    DefaultArffFeedbackGenerator feedbackGen = new DefaultArffFeedbackGenerator();
    List<Feedback> feedbacks = feedbackGen.generateHardcoded("feedbacks.arff");
View Full Code Here

          {
            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,
View Full Code Here

     * Creates a Reputation Graph.
     * @param graphConfig This object contains all of the configurations for this graph
     * @param feedbackGraph The feedbackGraph is needed to find what Agents are currently on it.
     */
    public SimReputationGraph(GraphConfig graphConfig, SimFeedbackGraph feedbackGraph) {
        super(graphConfig, (SimpleDirectedGraph) new ReputationGraph(new ReputationEdgeFactory()));
        this.feedbackGraph = feedbackGraph;
    }
View Full Code Here

  {
    BasicConfigurator.configure();
   
    // create the graphs
    FeedbackHistoryGraph feedbackHistoryGraph = new FeedbackHistoryGraph(new FeedbackHistoryEdgeFactory());
    ReputationGraph repGraph = new ReputationGraph(new ReputationEdgeFactory());
    TrustGraph trustGraph = new TrustGraph(new TrustEdgeFactory());
   
    // populate the feedback history graph by parsing the feedbacks from a arff file
    DefaultArffFeedbackGenerator feedbackGen = new DefaultArffFeedbackGenerator();
    ArrayList<Feedback> feedbacks = (ArrayList<Feedback>) feedbackGen.generateHardcoded("feedbacks.arff");
View Full Code Here

{
  static private Logger logger = Logger.getLogger(ReputationGraphCreator.class);
 
  public static ReputationGraph createGraph(String arffFileName) throws Exception
  {
    ReputationGraph repGraph = new ReputationGraph(new ReputationEdgeFactory());
   
    Util.assertNotNull(arffFileName);
    Util.assertFileExists(arffFileName);
   
    DataSource source;
    try
    {
      source = new DataSource(arffFileName);
      Instances instances = source.getDataSet();
      logger.debug("Number of instances in arff file is " + instances.numInstances());
     
      Enumeration enu = instances.enumerateInstances();
      //get all the feedback lines
     
      while(enu.hasMoreElements())
      {
        Instance temp = (Instance)enu.nextElement();
        logger.info("Parsing " + temp);
        String[] feedbackInstance = new String[3];
        //go through each feedback line
       
        if(temp.numValues()!=3) throw new GenericTestbedException("Reputation line does not have 3 elements. This is illegal.");
       
        for(int i=0;i<temp.numValues();i++)
        {
          //number of values == 3
          feedbackInstance[i] = temp.stringValue(i);         
        }
        Agent src = new Agent(new Integer(feedbackInstance[0]));
        Agent sink = new Agent(new Integer(feedbackInstance[1]));
        Double reputation = new Double(feedbackInstance[2]);
       
        if(!repGraph.containsVertex(src))
        {
          repGraph.addVertex(src);
        }
       
        if(!repGraph.containsVertex(sink))
        {
          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

        }
    }
 
  public static void main(String[] args) throws Exception
  {
    ReputationGraph repGraph = new ReputationGraph(new ReputationEdgeFactory());
    Agent a0 = new Agent();
    Agent a1 = new Agent();
    Agent a2 = new Agent();
    Agent a3 = new Agent();
    Agent a4 = new Agent();
   
    repGraph.addVertex(a0);
    repGraph.addVertex(a1);
    repGraph.addVertex(a2);
    repGraph.addVertex(a3);
    repGraph.addVertex(a4);
   
    repGraph.addEdge(a0, a1, 0);
    repGraph.addEdge(a1, a2, 0);
    repGraph.addEdge(a2, a3, 0);
    repGraph.addEdge(a1, a3, 0);
    repGraph.addEdge(a0, a4, 0);
    repGraph.addEdge(a4, a3, 0);
    repGraph.addEdge(a1, a0, 0);
    repGraph.addEdge(a1, a4, 0);
   
    ArrayList<TestbedEdge> paths = Util.getPaths(repGraph, a0, a3, false);
    if(paths != null)
    {
      System.out.println(paths.size());
View Full Code Here

  {
    if(!(g instanceof FeedbackHistoryGraph))
      throw new Exception("Can only listen to a feedback history graph.");
   
    super.m_graph2Listen = (FeedbackHistoryGraph)g;
    if(m_graph2Output == null) m_graph2Output = new ReputationGraph(new ReputationEdgeFactory());
    super.produceCompleteGraph = false;
   
    //initialize the reputation graph
    Set<TestbedEdge> edges = super.m_graph2Listen.edgeSet();
    for(TestbedEdge e : edges)
View Full Code Here

   
    BasicConfigurator.configure();
   
    //create graphs
    FeedbackHistoryGraph feedbackHistoryGraph = new FeedbackHistoryGraph(new FeedbackHistoryEdgeFactory());
    ReputationGraph repGraph = new ReputationGraph(new ReputationEdgeFactory());
    TrustGraph trustGraph = new TrustGraph(new TrustEdgeFactory());
   
    //swing listeners
    Workflow2 workflow2 = new Workflow2(feedbackHistoryGraph, repGraph, trustGraph);
    workflow2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    workflow2.setSize(400, 320);
    workflow2.setVisible(true);
   
    //eigentrust needs to use the feedback history graph
    EigenTrust repAlg = (EigenTrust) ReputationAlgorithm.getInstance("cu.repsystestbed.algorithms.examples.EigenTrust");
    repAlg.setGraph2Listen(feedbackHistoryGraph);
    repAlg.setGraph2Output(repGraph);
   
    //add eigentrust as an observer to the feedback history graph
    feedbackHistoryGraph.addObserver(repAlg);
   
    //rank based trust alg needs to use the reputation graph
    RankbasedTrustAlg trustAlg = (RankbasedTrustAlg) TrustAlgorithm.getInstance("cu.repsystestbed.algorithms.examples.RankbasedTrustAlg");
    trustAlg.setRatio(0.7);
    //must be called in this sequence otherwise setReputationGraph() will create a new trust graph
    trustAlg.setGraph2Output(trustGraph);
    trustAlg.setGraph2Listen(repGraph);

   
    //add rank based trust alg as an observer to the reputation graph
    repGraph.addObserver(trustAlg);
   
    //parse the feedbacks from the arff file
    DefaultArffFeedbackGenerator feedbackGen = new DefaultArffFeedbackGenerator();
    ArrayList<Feedback> feedbacks = (ArrayList<Feedback>) feedbackGen.generateHardcoded("feedbacks.arff");
   
View Full Code Here

  public void setGraph2Listen(SimpleDirectedGraph feedbackHistoryGraph) throws Exception
  {

    assertGraph2ListenType(feedbackHistoryGraph);
    this.m_graph2Listen = (FeedbackHistoryGraph)feedbackHistoryGraph;
    if(m_graph2Output == null) m_graph2Output = new ReputationGraph(new ReputationEdgeFactory());
    //initialize the reputation graph
    if(produceCompleteGraph)
    {
      Set<FeedbackHistoryGraphEdge> edges = ((FeedbackHistoryGraph)this.m_graph2Listen).edgeSet();
      for(FeedbackHistoryGraphEdge edge : edges)
View Full Code Here

TOP

Related Classes of cu.repsystestbed.graphs.ReputationGraph

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.