コード例 #1
0
    public Degree match(InternalWorkingMemory workingMemory, Object object, String typeName) {
      TraitableBean core = null;

      if (object instanceof Thing) {
        Thing thing = (Thing) object;
        core = (TraitableBean) thing.getCore();
        if (core.hasTrait(typeName)) {
          Thing proxy = core.getTrait(typeName.toString());
          return extractDegree(proxy);
        } else {
          return ChanceDegreeTypeRegistry.getSingleInstance().getDefaultOne().False();
        }
      } else if (object instanceof TraitableBean) {
        core = (TraitableBean) object;
        if (core.hasTrait(typeName)) {
          Thing proxy = core.getTrait(typeName.toString());
          return extractDegree(proxy);
        } else {
          return ChanceDegreeTypeRegistry.getSingleInstance().getDefaultOne().False();
        }
      } else {
        core = lookForWrapper(object, workingMemory);
        if (core == null || !core.hasTrait(typeName)) {
          return ChanceDegreeTypeRegistry.getDefaultOne().False();
        } else {
          Thing proxy = core.getTrait(typeName.toString());
          return extractDegree(proxy);
        }
      }
    }
コード例 #2
0
 private Degree extractDegree(Thing proxy) {
   if (proxy == null) {
     return ChanceDegreeTypeRegistry.getSingleInstance().getDefaultOne().False();
   } else {
     if (proxy instanceof ImperfectTraitProxy) {
       return ((ImperfectTraitProxy) proxy).isA();
     } else {
       return ChanceDegreeTypeRegistry.getSingleInstance().getDefaultOne().True();
     }
   }
 }
コード例 #3
0
 public Distribution<Double> newDistribution(Set<Double> focalElements) {
   Iterator<Double> iter = focalElements.iterator();
   return new GaussianDistribution(
       iter.next().doubleValue(),
       iter.next().doubleValue(),
       ChanceDegreeTypeRegistry.getSingleInstance().buildDegree(degreeType, 0.0));
 }
コード例 #4
0
 private Constructor getDegreeStringConstructor() {
   if (degreeStringConstr == null) {
     degreeStringConstr =
         ChanceDegreeTypeRegistry.getSingleInstance().getConstructorByString(degreeType);
   }
   return degreeStringConstr;
 }
コード例 #5
0
 private Distribution<T> createUniformDistribution(Collection<T> focalElements) {
   DiscreteDistribution<T> ret = new DiscreteDistribution<T>();
   for (Iterator<? extends T> currIt = focalElements.iterator(); currIt.hasNext(); ) {
     ret.put(
         currIt.next(),
         ChanceDegreeTypeRegistry.getSingleInstance()
             .buildDegree(degreeType, 1.0 / focalElements.size()));
   }
   return ret;
 }
コード例 #6
0
 public Distribution<Double> parse(String distrAsString) {
   if (distrAsString.startsWith("N")) {
     StringTokenizer tok = new StringTokenizer(distrAsString.substring(1), "(,) ");
     return new GaussianDistribution(
         tok.hasMoreTokens() ? Double.valueOf(tok.nextToken()) : 0.0,
         tok.hasMoreTokens() ? Double.valueOf(tok.nextToken()) : 1.0,
         ChanceDegreeTypeRegistry.getSingleInstance().buildDegree(degreeType, 0.0));
   } else {
     return newDistribution();
   }
 }
コード例 #7
0
 public Distribution<Double> newDistribution() {
   return new GaussianDistribution(
       0.0, 1.0, ChanceDegreeTypeRegistry.getSingleInstance().buildDegree(degreeType, 0.0));
 }
コード例 #8
0
 public Distribution<Double> toDistribution(Double value, Object... params) {
   return new GaussianDistribution(
       value.doubleValue(),
       Double.valueOf(params[0].toString()),
       ChanceDegreeTypeRegistry.getSingleInstance().buildDegree(degreeType, 0.0));
 }
コード例 #9
0
 public Distribution<Double> toDistribution(Double value, String strategy) {
   return new GaussianDistribution(
       value.doubleValue(),
       1.0,
       ChanceDegreeTypeRegistry.getSingleInstance().buildDegree(degreeType, 0.0));
 }