Package trust.jfcm

Examples of trust.jfcm.FcmConnection


         
          // Get Fcm Connections
          Collection<FcmConnection> links = maps.get(map).getConnections().values();
          Iterator<FcmConnection> it = links.iterator();
          while(it.hasNext()){
            FcmConnection c = it.next();
            String source = c.getFrom().getName();
            String destination = c.getTo().getName();
            if(concept.equals(source))
              outgoing+=destination + "\n";
            if(concept.equals(destination))
              incoming+=source + "\n";
            
View Full Code Here


     */
    Set<FcmConnection> out = c.getOutConnections();
    Iterator<FcmConnection> it = out.iterator();
    double val = 0;
    while(it.hasNext()){
      FcmConnection conn = it.next();
     
      WeightedConnection wconn = null;
      if(conn instanceof WeightedConnection)
        wconn = (WeightedConnection) conn;
     
View Full Code Here

        LearningConcept lc = (LearningConcept) c;
        Set<FcmConnection> out = lc.getOutConnections();
        Iterator<FcmConnection> it1 = out.iterator();
       
        while(it1.hasNext()){
          FcmConnection conn = it1.next();
         
          LearningWeightedConnection wconn = null;
          if(conn instanceof LearningWeightedConnection){
            wconn = (LearningWeightedConnection) conn;
            /*
 
View Full Code Here

    Element elemConnections = doc.createElement("connections");
    elem.appendChild(elemConnections);

    Iterator<FcmConnection> connIter = map.getConnectionsIterator();
    while (connIter.hasNext()) {
      FcmConnection conn = connIter.next();
      Element elemConn = doc.createElement("connection");
      elemConn.setAttribute("name", conn.getName());
      if (conn.getDescription() != null) {
        Element elemDescription = doc.createElement("description");
        elemDescription.setTextContent(conn.getDescription());
        elemConn.appendChild(elemDescription);
      }

      if (conn.getFrom() != null) {
        elemConn.setAttribute("from", conn.getFrom().getName());
      }
      if (conn.getTo() != null) {
        elemConn.setAttribute("to", conn.getTo().getName());
      }
      if (conn instanceof WeightedConnection) {
        elemConn.setAttribute("type", "WEIGHTED");

        WeightedConnection wc = (WeightedConnection) conn;
        Element param = doc.createElement("param");
        param.setAttribute("name", "name");
        param.setAttribute("value", Double.toString(wc.getWeight()));
        elemConn.appendChild(param);

      } else {
        throw new UnsupportedOperationException(
            "FcmConnection implementation not supported: " + conn.getClass().getName());
      }

      elemConnections.appendChild(elemConn);
    }
  }
View Full Code Here

    }

    // TODO optimize
    Iterator<FcmConnection> iter = map.getConnectionsIterator();
    while (iter.hasNext()) {
      FcmConnection conn = (FcmConnection) iter.next();
      map.connect(conn.getFrom().getName(), conn.getName(), conn.getTo().getName());
    }

    return map;
  }
View Full Code Here

  }

  private static FcmConnection parseLearningConnection(FcmLearning map, XPath xpath, Element connElem)
        throws Exception {
 
      FcmConnection conn;
      String s;
 
      String name;
      name = xpath.evaluate("@name", connElem);
      if (StringUtils.isBlank(name)) {
        throw new Exception("Missing connection name");
      }
 
      String type = xpath.evaluate("@type", connElem);
 
      /* Set weight if weighted*/
      if ("WEIGHTED".equalsIgnoreCase(type)) {
        LearningWeightedConnection wConn = new LearningWeightedConnection();
        NodeList params = (NodeList) xpath.evaluate("param", connElem, XPathConstants.NODESET);
       
          Element param = (Element) params.item(0);
          s = xpath.evaluate("@value", param);
          if ("weight".equals(param.getAttribute("name"))) {
            wConn.setWeight(Double.parseDouble(s));
           
            // by default the uncertainty is set equal to the weight
            wConn.setWeightUncertainty(wConn.getWeight());
          }
          /* set weight uncertainty*/
          if(params.getLength()>1){
            param = (Element) params.item(1);
            s = xpath.evaluate("@value", param);
            if ("uncertainty".equals(param.getAttribute("name"))) {
              wConn.setWeightUncertainty(Double.parseDouble(s));
 
            }
          }
        conn = wConn;
 
      } else {
        throw new UnsupportedOperationException("Connection type not supported: \"" + type
            + "\"");
      }
 
      conn.setName(name);
 
      String description = xpath.evaluate("description/text()", connElem);
      if (StringUtils.isNotBlank(description)) {
        conn.setDescription(description);
      }
 
      Concept c;
 
      s = xpath.evaluate("@from", connElem);
      if (StringUtils.isBlank(s)) {
        throw new Exception("Missing \"from\" reference in connection \"" + conn.getName()
            + "\"");
      }
      c = map.getConcept(s);
      if (c == null) {
        throw new Exception("Missing \"from\" reference in connection \"" + conn.getName()
            + "\"");
      }
      conn.setFrom(c);
 
      s = xpath.evaluate("@to", connElem);
      if (StringUtils.isBlank(s)) {
        throw new Exception("Missing \"to\" reference in connection \"" + conn.getName() + "\"");
      }
      c = map.getConcept(s);
      if (c == null) {
        throw new Exception("Missing \"to\" reference in connection \"" + conn.getName() + "\"");
      }
      conn.setTo(c);
 
      //System.out.println(conn);
     
      return conn;
    }
View Full Code Here

     */
    Set<FcmConnection> in = c.getInConnections();
    Iterator<FcmConnection> it = in.iterator();
    double val = 0;
    while(it.hasNext()){
      FcmConnection conn = it.next();
     
      LearningWeightedConnection wconn = null;
      if(conn instanceof LearningWeightedConnection)
        wconn = (LearningWeightedConnection) conn;
     
View Full Code Here

        LearningConcept lc = (LearningConcept) c;
        Set<FcmConnection> out = lc.getOutConnections();
        Iterator<FcmConnection> it1 = out.iterator();
       
        while(it1.hasNext()){
          FcmConnection conn = it1.next();
         
          LearningWeightedConnection wconn = null;
          if(conn instanceof LearningWeightedConnection){
            wconn = (LearningWeightedConnection) conn;
            /*
 
View Full Code Here

    }
   
    /* clone connections */
    Iterator<FcmConnection> iter = this.getConnectionsIterator();
    while(iter.hasNext()){
      FcmConnection old_conn = (FcmConnection) iter.next();
      WeightedConnection new_conn = (WeightedConnection) old_conn.clone();
      new_conn.setFrom(map.getConcept(old_conn.getFrom().getName()));
      new_conn.setTo(map.getConcept(old_conn.getTo().getName()));
      map.addConnection(new_conn);
      map.connect(new_conn.getFrom().getName(), new_conn.getName(), new_conn.getTo().getName());
    }
   
    map.resetConcepts();
View Full Code Here

TOP

Related Classes of trust.jfcm.FcmConnection

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.