Esempio n. 1
0
 @Test
 public void valid_ipv6_trailing_dot() {
   final Domain domain = Domain.parse("0.0.0.0.8.f.7.0.1.0.0.2.ip6.arpa.");
   assertThat(domain.getValue(), is(ciString("0.0.0.0.8.f.7.0.1.0.0.2.ip6.arpa")));
   assertThat((Ipv6Resource) domain.getReverseIp(), is(Ipv6Resource.parse("2001:7f8::/48")));
   assertThat(domain.getType(), is(Domain.Type.IP6));
 }
 @RequestMapping(value = "/medicalRecord/add", method = RequestMethod.POST)
 @ResponseBody
 public Boolean addMedicalRecord(
     @RequestParam(value = "codes[]", required = false) String[] codes,
     @RequestParam Integer patientId,
     @RequestParam String domain) {
   if (codes == null || codes.length == 0) {
     throw new AjaxBadRequest("Please select codes for add");
   }
   User patient = userService.getByPrimaryKey(patientId);
   for (String entryStr : codes) {
     String[] entry = entryStr.split(Constants.HYPHEN);
     DictionaryEntry dictionaryEntry =
         new DictionaryEntry(entry[0], entry[1], Domain.valueOf(domain));
     if (entry.length < 3) {
       throw new AjaxBadRequest("Date can't be empty");
     }
     String dateStr = entry[2];
     if (dateStr.trim().isEmpty()) {
       throw new AjaxBadRequest("Date can't be empty");
     }
     Date date;
     try {
       date = new SimpleDateFormat("mm/dd/yyyy").parse(dateStr);
     } catch (ParseException e) {
       throw new AjaxBadRequest("Date format error");
     }
     String value = entry.length == 4 && !entry[3].trim().isEmpty() ? entry[3] : null;
     patient
         .getMedicalRecords()
         .add(new MedicalRecord(patientId, Domain.valueOf(domain), dictionaryEntry, date, value));
   }
   userService.update(patient);
   return true;
 }
Esempio n. 3
0
 @Test
 public void enum_domain() {
   final Domain domain = Domain.parse("2.1.2.1.5.5.5.2.0.2.1.e164.arpa");
   assertThat(domain.getValue(), is(ciString("2.1.2.1.5.5.5.2.0.2.1.e164.arpa")));
   assertNull(domain.getReverseIp());
   assertThat(domain.getType(), is(Domain.Type.E164));
 }
Esempio n. 4
0
 @Test
 public void valid_ipv4() {
   final Domain domain = Domain.parse("200.193.193.in-addr.arpa");
   assertThat(domain.getValue(), is(ciString("200.193.193.in-addr.arpa")));
   assertThat((Ipv4Resource) domain.getReverseIp(), is(Ipv4Resource.parse("193.193.200/24")));
   assertThat(domain.getType(), is(Domain.Type.INADDR));
 }
Esempio n. 5
0
 private void buildListOfAllPatterns(Domain domain, String prefix, int level)
     throws TermWareException {
   SortedSet directSystemNames = domain.getNamesOfSystems();
   Iterator systemsIterator = directSystemNames.iterator();
   while (systemsIterator.hasNext()) {
     String name = (String) systemsIterator.next();
     TermSystem system = domain.resolveSystem(name);
     SortedSet<String> names = system.getPatternNames();
     Iterator namesIterator = names.iterator();
     while (namesIterator.hasNext()) {
       String patternName = (String) namesIterator.next();
       if (!allPatterns_.containsKey(patternName)) {
         HashSet indexEntries = new HashSet();
         allPatterns_.put(patternName, indexEntries);
       }
       HashSet systemsSet = (HashSet) allPatterns_.get(patternName);
       systemsSet.add(new APIGen.PatternIndexEntry(prefix, domain, name, level));
     }
   }
   SortedSet domainsSet = domain.getNamesOfDirectSubdomains();
   Iterator domainsIterator = domainsSet.iterator();
   while (domainsIterator.hasNext()) {
     String subdomainName = (String) domainsIterator.next();
     Domain subdomain = domain.getDirectSubdomain(subdomainName);
     buildListOfAllPatterns(subdomain, prefix + subdomainName + "/", level + 1);
   }
 }
Esempio n. 6
0
  public static LinkedList<Plan> getPlans() {
    LinkedList<Plan> returnedPlans = new LinkedList<Plan>();
    TermConstant.initialize(5);

    Domain d = new foralltest();

    d.setProblemConstants(defineConstants());

    State s = new State(3, d.getAxioms());

    JSHOP2.initialize(d, s);

    TaskList tl;
    SolverThread thread;

    createState0(s);

    tl = new TaskList(1, true);
    tl.subtasks[0] = new TaskList(new TaskAtom(new Predicate(0, 0, TermList.NIL), false, false));

    thread = new SolverThread(tl, 1);
    thread.start();

    try {
      while (thread.isAlive()) Thread.sleep(500);
    } catch (InterruptedException e) {
    }

    returnedPlans.addAll(thread.getPlans());

    return returnedPlans;
  }
Esempio n. 7
0
  public void printRCP(String RCPName) {
    Domain dominio = null;
    DiscreteChanceNode nodo;
    NodeList list;

    if (RCPName.equalsIgnoreCase("livello_difficolta_iniziale")) {
      dominio = livello_difficolta_iniziale;
    } else if (RCPName.equalsIgnoreCase("ogni_livello")) {
      dominio = ogni_livello;
    } else if (RCPName.equalsIgnoreCase("visualizzazione_iniziale")) {
      dominio = visualizzazione_iniziale;
    }

    try {
      System.out.println("RCP: " + dominio.getFileName());
      list = dominio.getNodes();
      for (Object n : list) {
        nodo = (DiscreteChanceNode) n;
        System.out.println("Nodo: " + nodo.getName());
        for (int i = 0; i < nodo.getNumberOfStates(); i++) {
          System.out.println(nodo.getStateLabel(i) + ": " + nodo.getBelief(i));
        }
      }
      System.out.println("");
      System.out.println("");
    } catch (ExceptionHugin EH) {
      System.out.println(EH.getMessage());
    }
  }
Esempio n. 8
0
 @Test
 public void ipv4_dash() {
   final Domain domain = Domain.parse("0-127.10.10.10.in-addr.arpa");
   assertThat(domain.getValue(), is(ciString("0-127.10.10.10.in-addr.arpa")));
   assertThat((Ipv4Resource) domain.getReverseIp(), is(Ipv4Resource.parse("10.10.10.0/25")));
   assertThat(domain.getType(), is(Domain.Type.INADDR));
 }
Esempio n. 9
0
  public Domain saveDomain(Domain domain) {
    if (domain.getId() == null) {
      domain.setId((long) domains.size());
      domains.add(domain);
    }

    return domain;
  }
Esempio n. 10
0
 @Test
 public void ipv4_dash_non_prefix_range() {
   final Domain domain = Domain.parse("1-2.10.10.10.in-addr.arpa");
   assertThat(domain.getValue(), is(ciString("1-2.10.10.10.in-addr.arpa")));
   assertThat(
       (Ipv4Resource) domain.getReverseIp(), is(Ipv4Resource.parse("10.10.10.1-10.10.10.2")));
   assertThat(domain.getType(), is(Domain.Type.INADDR));
 }
Esempio n. 11
0
 @Test
 public void testCreation() {
   final String name = "Programming";
   final String description = "Program to solve the problems.";
   Domain domain = new Domain(name, description);
   assertEquals(name, domain.getName());
   assertEquals(description, domain.getDescription());
 }
  public static void main(String[] args) {

    GridWorldDomain gw = new GridWorldDomain(11, 11); // 11x11 grid world
    gw.setMapToFourRooms(); // four rooms layout
    gw.setProbSucceedTransitionDynamics(0.8); // stochastic transitions with
    // 0.8 success rate
    final Domain domain = gw.generateDomain(); // generate the grid world
    // domain

    // setup initial state
    State s = GridWorldDomain.getOneAgentOneLocationState(domain);
    GridWorldDomain.setAgent(s, 0, 0);
    GridWorldDomain.setLocation(s, 0, 10, 10);

    // ends when the agent reaches a location
    final TerminalFunction tf =
        new SinglePFTF(domain.getPropFunction(GridWorldDomain.PFATLOCATION));

    // reward function definition
    final RewardFunction rf = new GoalBasedRF(new TFGoalCondition(tf), 5., -0.1);

    // initial state generator
    final ConstantStateGenerator sg = new ConstantStateGenerator(s);

    // set up the state hashing system for looking up states
    final DiscreteStateHashFactory hashingFactory = new DiscreteStateHashFactory();

    /** Create factory for Q-learning agent */
    LearningAgentFactory qLearningFactory =
        new LearningAgentFactory() {

          @Override
          public String getAgentName() {
            return "Q-learning";
          }

          @Override
          public LearningAgent generateAgent() {
            return new QLearning(domain, rf, tf, 0.99, hashingFactory, 0.3, 0.1);
          }
        };

    // define experiment
    LearningAlgorithmExperimenter exp =
        new LearningAlgorithmExperimenter((SADomain) domain, rf, sg, 10, 100, qLearningFactory);

    exp.setUpPlottingConfiguration(
        500,
        250,
        2,
        1000,
        TrialMode.MOSTRECENTANDAVERAGE,
        PerformanceMetric.CUMULATIVESTEPSPEREPISODE,
        PerformanceMetric.AVERAGEEPISODEREWARD);

    // start experiment
    exp.startExperiment();
  }
Esempio n. 13
0
 @Test
 public void testToString() {
   assertTrue(
       "(ipv4) toString should return expected format",
       domain1.toString().equals("200.193.193.in-addr.arpa(193.193.200.0/24 INADDR not-dashed)"));
   assertTrue(
       "(ipv6) toString should return expected format",
       domain4.toString().equals("2.1.2.1.5.5.5.2.0.2.1.e164.arpa(E164 not-dashed)"));
 }
  private OOFactSet create_factset(Class<?> classObj, boolean all_discrete) {
    // System.out.println("WorkingMemory.create_factset element "+ element );

    OOFactSet newfs = new OOFactSet(classObj);

    Field[] element_fields = classObj.getDeclaredFields();
    for (Field f : element_fields) {
      String f_name = f.getName();
      Class<?>[] f_class = {f.getType()};
      System.out.println(
          "WHat is this f: "
              + f.getType()
              + " the name "
              + f_name
              + " class "
              + f.getClass()
              + " and the name"
              + f.getClass().getName());
      if (Util.isSimpleType(f_class)) {

        Domain<?> fieldDomain;
        if (!domainset.containsKey(f_name)) {
          fieldDomain = DomainFactory.createDomainFromClass(f.getType(), f_name);
          domainset.put(f_name, fieldDomain);
        } else fieldDomain = domainset.get(f_name);

        Annotation[] annotations = f.getAnnotations();
        // iterate over the annotations to locate the MaxLength constraint if it exists
        DomainSpec spec = null;
        for (Annotation a : annotations) {
          if (a instanceof DomainSpec) {
            spec = (DomainSpec) a; // here it is !!!
            break;
          }
        }

        if (spec != null) {
          fieldDomain.setReadingSeq(spec.readingSeq());
          if (!all_discrete) fieldDomain.setDiscrete(spec.discrete());
        }
        /*
         * ID3 would
         * if it is integer and the annotation saying that the field is continuous
         * 		ignore the domain
         * if it is double / float and the annotation saying that the field is continuous
         * 		ignore the domain if it has more than 10 values ?
         * if it is string and the annotation saying that the field is continuous
         * 		what to do??
         */

        newfs.addDomain(f_name, fieldDomain);
      }
    }
    factsets.put(classObj.getName(), newfs);
    return newfs;
  }
  public void addDomainRoutingTable(Domain domain) {
    if (this.interDomainRoutingTable.put(domain.getDomainName(), domain) == null) {
      setChanged();
      Object[] o = new Object[] {GUISemantiCore.ADD_DOMAIN, domain};
      notifyObservers(o);

      SemantiCore.notification.print(
          "[ I ] ControlBridge : Domain " + domain.getDomainName() + " added");
    }
  }
Esempio n. 16
0
 /**
  * Retorna o valor de um campo do registro ou o valor de uma função.
  *
  * @param key o campo do registro cujo valor deve ser retornado.
  * @return o valor de um campo do registro ou o valor de uma função.
  * @throws ProcessException se houver falha no processamento.
  */
 public String get(String key, boolean updated) throws ProcessException {
   if (key.equals("owner")) {
     return owner;
   } else if (key.equals("ownerid")) {
     return ownerid;
   } else if (reduced && updated) {
     // Ultima consulta com informação reduzida.
     // Demais campos estão comprometidos.
     throw new ProcessException("ERROR: WHOIS QUERY LIMIT");
   } else if (key.equals("responsible")) {
     return responsible;
   } else if (key.equals("country")) {
     return country;
   } else if (key.equals("owner-c")) {
     return owner_c;
   } else if (key.equals("created")) {
     if (created == null) {
       return null;
     } else {
       return DATE_FORMATTER.format(created);
     }
   } else if (key.equals("changed")) {
     if (changed == null) {
       return null;
     } else {
       return DATE_FORMATTER.format(changed);
     }
   } else if (key.equals("provider")) {
     return provider;
   } else if (key.equals("domain")) {
     return domainList.toString();
   } else if (key.startsWith("owner-c/")) {
     int index = key.indexOf('/') + 1;
     key = key.substring(index);
     Handle owner = getOwner();
     if (owner == null) {
       return null;
     } else {
       return owner.get(key);
     }
   } else if (key.startsWith("domain/")) {
     int index = key.indexOf('/') + 1;
     key = key.substring(index);
     TreeSet<String> resultSet = new TreeSet<String>();
     for (String domainName : domainList) {
       Domain domain = Domain.getDomain(domainName);
       String result = domain.get(key, updated);
       resultSet.add(domainName + "=" + result);
     }
     return resultSet.toString();
   } else {
     return null;
   }
 }
Esempio n. 17
0
  public Domain[] split() {
    Domain[] splitDomain = new Domain[getNumCategories()];
    for (int i = 0; i < getNumCategories(); i++) splitDomain[i] = new Domain();

    for (Vector v : attributesAndCategory) {
      int index = (int) v.last();
      Domain d = splitDomain[index - 1];
      d.addVector(v);
    }

    return splitDomain;
  }
Esempio n. 18
0
  public Domain[] split(int attribute, int numattr) {
    Domain[] splitDomain = new Domain[numattr];
    for (int i = 0; i < numattr; i++) splitDomain[i] = new Domain();

    for (Vector v : attributesAndCategory) {
      int index = (int) v.get(attribute);
      Domain d = splitDomain[index - 1];
      d.addVector(v);
    }

    return splitDomain;
  }
Esempio n. 19
0
  private void generateSystemPages(Domain domain, String prefix, int level)
      throws IOException, TermWareException {
    SortedSet directSystemNames = domain.getNamesOfSystems();
    Iterator systemsIterator = directSystemNames.iterator();
    while (systemsIterator.hasNext()) {
      String name = (String) systemsIterator.next();
      PrintStream out = openPrintStream(prefix + name, "all-patterns.html");
      printHeader(out, "patterns for " + name);
      out.println("<BODY BGCOLOR=\"white\">");
      out.println("<TABLE BORDER=\"0\" WIDTH=\"100%\">");
      out.println("<TR>");
      out.println("<TD NOWRAP><FONT size=\"+1\">");
      out.println("Patterns");
      out.println("</FONT></TD>");
      out.println("</TR></TABLE>");
      out.println("<TABLE BORDER=\"0\" WIDTH=\"100%\">");
      out.println("<TR><TD NOWRAP><P>");
      out.println("<FONT>");

      TermSystem system = domain.resolveSystem(name);
      SortedSet names = system.getPatternNames();
      Iterator namesIterator = names.iterator();
      while (namesIterator.hasNext()) {
        String patternName = (String) namesIterator.next();
        String uri = prefix + name + "/index.html#" + patternName;
        out.print("<A href=\"../");
        for (int i = 0; i < level; ++i) {
          out.print("../");
        }
        out.print(uri + "\" TARGET=\"transformerFrame\" >");
        out.print(patternName);
        out.println("</A>");
        out.println("<BR>");
      }
      out.println("</FONT>");
      out.println("</TD>");
      out.println("</TR>");
      out.println("</TABLE>");
      out.println("<P>&nbsp;</BODY></HTML>");
      out.close();
      out = openPrintStream(prefix + name, "index.html");
      TermSystem ts = domain.resolveSystem(name);
      printSystemIndexPage(out, prefix + name, ts);
      out.close();
    }
    SortedSet domainsSet = domain.getNamesOfDirectSubdomains();
    Iterator domainsIterator = domainsSet.iterator();
    while (domainsIterator.hasNext()) {
      String subdomainName = (String) domainsIterator.next();
      Domain subdomain = domain.getDirectSubdomain(subdomainName);
      generateSystemPages(subdomain, prefix + subdomainName + "/", level + 1);
    }
  }
Esempio n. 20
0
  private static final void listdomains(List<Domain> domains) {

    int i = -1;
    for (Domain dom : domains) {
      i++;
      System.out.println("DOMAIN:" + i + " size:" + dom.size + " " + dom.score);
      List<Segment> segments = dom.getSegments();

      for (Segment s : segments) {
        System.out.println("   Segment: " + s);
      }
    }
  }
  @Test
  public void singletonSet() {
    check(!ImmutableOrdinalSet.of(a0).isEmpty());
    check(ImmutableOrdinalSet.of(a0).size()).is(1);
    check(ImmutableOrdinalSet.of(a0)).asString().notEmpty();

    check(ImmutableOrdinalSet.of(a0)).isOf(a0);
    check(ImmutableOrdinalSet.of(a0)).has(a0);
    check(ImmutableOrdinalSet.of(a0).contains(a0));
    check(!ImmutableOrdinalSet.of(a0).contains(a1));
    check(ImmutableOrdinalSet.of(a0)).not(ImmutableOrdinalSet.of(da.get(4)));
    check(ImmutableOrdinalSet.of(a0).containsAll(ImmutableOrdinalSet.of(a0)));
    check(ImmutableOrdinalSet.of(a0).containsAll(ImmutableSet.of(a0)));
    check(ImmutableOrdinalSet.of(a0)).not().hasAll(ImmutableSet.of(da.get(5)));
  }
  @Test
  public void incrementCountersLarge() {
    Domain dc = new Domain();
    Ord[] cs = new Ord[120];
    for (int i = 0; i < cs.length; i++) {
      cs[i] = dc.get(i);
    }

    int[] counters = new int[dc.length()];
    ImmutableOrdinalSet.of(cs[62], cs[119], cs[98]).incrementCounters(counters);
    ImmutableOrdinalSet.of(cs[119], cs[1]).incrementCounters(counters);

    check(new int[] {counters[0], counters[1], counters[62], counters[98], counters[119]})
        .isOf(0, 1, 1, 1, 2);
  }
Esempio n. 23
0
 /**
  * \brief Select random coordinates for the new agent within a restricted birth area
  *
  * <p>Select random coordinates for the new agent within a restricted birth area. This restricted
  * area is set within the protocol file, and defined as a ContinuousVector by the method
  * defineSquareArea
  *
  * @param cc ContinuousVector that will hold the coordinates of this agent
  * @param area Area within which these coordinates should be restricted
  */
 public void shuffleCoordinates(ContinuousVector cc, ContinuousVector[] area) {
   do {
     cc.x = ExtraMath.getUniRandDbl(area[0].x, area[1].x);
     cc.y = ExtraMath.getUniRandDbl(area[0].y, area[1].y);
     cc.z = ExtraMath.getUniRandDbl(area[0].z, area[1].z);
   } while (domain.testCrossedBoundary(cc) != null);
 }
Esempio n. 24
0
  public Domain[] split(int numFolds) {
    if (numFolds == 0) {
      numFolds = 1;
    } else if (numFolds == -1) {
      numFolds = attributesAndCategory.size() - 1;
    }
    Domain[] splitDomain = new Domain[numFolds];
    for (int i = 0; i < numFolds; i++) splitDomain[i] = new Domain();

    for (int i = 0; i < attributesAndCategory.size(); i++) {
      Domain d = splitDomain[i % numFolds];
      d.addVector(attributesAndCategory.get(i));
    }

    return splitDomain;
  }
Esempio n. 25
0
  public List<GdlRule> flatten() {
    // Find universe and initial domains
    for (Gdl gdl : description) {
      initializeDomains(gdl);
    }

    for (Domain d : domains.values()) d.buildIndices();

    // Compute the actual domains of everything
    updateDomains();

    // printDomains();
    // printDomainRefs();

    return getAllInstantiations();
  }
Esempio n. 26
0
 private void doUpdateDomain(HttpServletRequest req, HttpServletResponse resp) throws IOException {
   final String domainName = req.getParameter("name");
   final String storageEngineOptions = req.getParameter("storageEngineOptions");
   final Domain domain = coordinator.getDomain(domainName);
   if (domain == null) {
     throw new IOException("Could not get Domain '" + domainName + "' from Configurator.");
   } else {
     coordinator.updateDomain(
         domainName,
         domain.getNumParts(),
         domain.getStorageEngineFactoryClass().getName(),
         storageEngineOptions,
         domain.getPartitioner().getClass().getName());
   }
   resp.sendRedirect("/domains.jsp");
 }
Esempio n. 27
0
  @Test
  public void testHashCode() {
    assertTrue(
        "(ipv4)Identical domains should have matching hashcodes",
        domain1.hashCode() == domain1_2.hashCode());
    assertFalse(
        "(ipv4)Different domains hashcodes shouldn't match",
        domain1.hashCode() == domain2.hashCode());

    assertTrue(
        "(ipv6) Identical domains should have matching hashcodes",
        domain4.hashCode() == domain4_2.hashCode());
    assertFalse(
        "(ipv6) Different domains shouldn't have matching hashcodes",
        domain4.hashCode() == domain5.hashCode() || domain5.hashCode() == domain4.hashCode());
  }
 public String toString() {
   String out = "FAD: attr: " + domain.getName() + " total num: " + this.getTotal() + "\n";
   for (Object attr : this.getAttributes()) {
     FactTargetDistribution ftd = facts_at_attr.get(attr);
     out += ftd;
   }
   return out;
 }
Esempio n. 29
0
  /**
   * Test if the implementation of "AnnotatedProviderInterface", which is annotated with OSGi
   * R6 @ProviderType, causes import of the api package to use the provider version policy
   */
  public static void testProviderTypeR6() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setPrivatePackage("test.versionpolicy.implemented.osgi");
    b.setProperty("build", "123");

    Jar jar = b.build();
    assertTrue(b.check());
    Manifest m = jar.getManifest();
    m.write(System.err);

    Domain d = Domain.domain(m);
    Parameters params = d.getImportPackage();
    Attrs attrs = params.get("test.version.annotations.osgi");
    assertNotNull(attrs);
    assertEquals("[1.2,1.3)", attrs.get("version"));
  }
Esempio n. 30
0
  /**
   * Tests if the implementation of the EventHandler (which is marked as a ConsumerType) causes the
   * import of the api package to use the consumer version policy.
   */
  public static void testConsumerType() throws Exception {
    Builder a = new Builder();
    a.addClasspath(new File("bin"));
    a.setPrivatePackage("test.versionpolicy.uses");
    a.setExportPackage("test.versionpolicy.api");
    a.setProperty("build", "123");
    Jar jar = a.build();
    assertTrue(a.check());
    Manifest m = jar.getManifest();
    m.write(System.err);
    Domain d = Domain.domain(m);

    Parameters parameters = d.getImportPackage();
    Attrs attrs = parameters.get("test.versionpolicy.api");
    assertNotNull(attrs);
    assertEquals("[1.2,2)", attrs.get("version"));
  }