コード例 #1
0
ファイル: Transform.java プロジェクト: CategoricalData/fql
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Transform other = (Transform) obj;
   if (data == null) {
     if (other.data != null) return false;
   } else if (!data.equals(other.data)) return false;
   if (dst == null) {
     if (other.dst != null) return false;
   } else if (!dst.equals(other.dst)) return false;
   if (src == null) {
     if (other.src != null) return false;
   } else if (!src.equals(other.src)) return false;
   return true;
 }
コード例 #2
0
  private boolean containInstance(Instance sel, Slot slot, Instance instance) {
    if (itsInstance == null) return false;
    Collection instances = sel.getOwnSlotValues(slot);
    Iterator i = instances.iterator();
    while (i.hasNext()) {

      Instance tmpInstance = (Instance) i.next();
      if (tmpInstance.equals(instance)) return true;
    }
    return false;
  }
 /**
  * Returns the k instances of the given data set that are the closest to the instance that is
  * given as a parameter.
  *
  * @param dm the distance measure used to calculate the distance between instances
  * @param inst the instance for which we need to find the closest
  * @return the instances from the supplied data set that are closest to the supplied instance
  */
 @Override
 public Set<Instance> kNearest(int k, Instance inst, DistanceMeasure dm) {
   Map<Instance, Double> closest = new HashMap<Instance, Double>();
   double max = dm.getMaxValue();
   for (Instance tmp : this) {
     double d = dm.measure(inst, tmp);
     if (dm.compare(d, max) && !inst.equals(tmp)) {
       closest.put(tmp, d);
       if (closest.size() > k) max = removeFarthest(closest, dm);
     }
   }
   return closest.keySet();
 }
コード例 #4
0
 public void addForwardReferences() {
   KnowledgeBase kb = this.getKnowledgeBase();
   Collection transitions = getOwnSlotValues(kb.getSlot("transitions"));
   Slot fromSlot = kb.getSlot(":FROM");
   Slot toSlot = kb.getSlot(":TO");
   Instance from = null;
   Instance to = null;
   Slot branches = kb.getSlot("branches");
   Slot followed_by = kb.getSlot("followed_by");
   Slot label = kb.getSlot("label");
   for (Iterator transition = transitions.iterator(); transition.hasNext(); ) {
     Instance inst = (Instance) transition.next();
     from = (Instance) inst.getOwnSlotValue(fromSlot);
     if (from != null) {
       to = (Instance) inst.getOwnSlotValue(toSlot);
       if (to != null) {
         try {
           if (from.hasOwnSlot(branches)) {
             /*logger.debug("addForwardReferences: "+ from.getOwnSlotValue(label)+
             " has branches"); */
             if ((from.getOwnSlotValues(branches) == null)
                 || (!from.getOwnSlotValues(branches).contains(to)))
               from.addOwnSlotValue(branches, to);
           } else if (from.hasOwnSlot(followed_by)) {
             /*logger.debug("addForwardReferences: "+ from.getOwnSlotValue(label)+
             " has followed by");*/
             if (!(to.equals(from.getOwnSlotValue(followed_by))))
               from.setOwnSlotValue(followed_by, to);
           } else
             logger.error(
                 "addForwardReferences: "
                     + from.getOwnSlotValue(label)
                     + "has no followed_by or branches slot");
         } catch (Exception e) {
           logger.error(
               "Exception adding "
                   + to.getOwnSlotValue(label)
                   + " to "
                   + from.getOwnSlotValue(label));
         }
       }
     }
   }
 }
コード例 #5
0
ファイル: Deployment.java プロジェクト: bkvarda/director-sdk
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Deployment other = (Deployment) o; // NOPMD

    if (enableEnterpriseTrial != null
        ? !enableEnterpriseTrial.equals(other.enableEnterpriseTrial)
        : other.enableEnterpriseTrial != null) return false;
    if (hostname != null ? !hostname.equals(other.hostname) : other.hostname != null) return false;
    if (managerInstance != null
        ? !managerInstance.equals(other.managerInstance)
        : other.managerInstance != null) return false;
    if (name != null ? !name.equals(other.name) : other.name != null) return false;
    if (port != null ? !port.equals(other.port) : other.port != null) return false;
    if (repository != null ? !repository.equals(other.repository) : other.repository != null)
      return false;
    if (repositoryKeyUrl != null
        ? !repositoryKeyUrl.equals(other.repositoryKeyUrl)
        : other.repositoryKeyUrl != null) return false;
    if (username != null ? !username.equals(other.username) : other.username != null) return false;
    return true;
  }