Package org.jamesii.core.math.random.generators

Examples of org.jamesii.core.math.random.generators.IRandom


    IRandom rng = usingFactory.create(seed);
    return rng;
  }

  public static synchronized long getNextSeed(long ofGroup) {
    IRandom seedGen = instance.groups.get(ofGroup);
    if (seedGen == null) {
      throw new IllegalArgumentException(NO_GROUP_FOUND_FOR + ofGroup);
    }

    long seed = seedGen.nextLong();
    return seed;
  }
View Full Code Here


    }

    // add edges as good as possible (better more than wished to make graph
    // connected)
    // last node must be touched to test if it is connected
    IRandom rnd = SimSystem.getRNGGenerator().getNextRNG();
    for (int i = 0; i < nodeList.size(); i++) {
      // get a list of possible partners by getting all 'right' of i and sort
      // out the ones with max degree
      ArrayList<Integer> possibleNeighbourIndices = new ArrayList<>();
      for (int j = i + 1; j < nodeList.size(); j++) {
        if (nodeHasDeg.get(j) < nodeShouldDeg.get(j)) {
          possibleNeighbourIndices.add(j);
        }
      }

      /*
       * if (nodeList.get(i).equals(18)) { i=i; }
       */

      while (nodeHasDeg.get(i) < nodeShouldDeg.get(i)) {
        if (possibleNeighbourIndices.isEmpty()) {
          // we want more edges but no more partners are there
          if (nodeHasDeg.get(i) == 0) {
            // but we are not connected at all, so we try to force an edge
            // to predecessor or successor
            if (i > 0) {
              graph.addEdge(new AnnotatedEdge<>(nodeList.get(i), nodeList
                  .get(i - 1), elDistri.getRandomNumber()));
              System.out.println("Force edge from " + nodeList.get(i) + " to "
                  + nodeList.get(i - 1));
              nodeHasDeg.set(i - 1, nodeHasDeg.get(i - 1) + 1);
              nodeHasDeg.set(i, 1);
            }
            if (i < nodeList.size() - 1) {
              graph.addEdge(new AnnotatedEdge<>(nodeList.get(i), nodeList
                  .get(i + 1), elDistri.getRandomNumber()));
              System.out.println("Force edge from " + nodeList.get(i) + " to "
                  + nodeList.get(i + 1));
              nodeHasDeg.set(i + 1, nodeHasDeg.get(i + 1) + 1);
              nodeHasDeg.set(i, 1);
            } else {
              // we are connected, so we give up
              break;
            }
          }
          // no success - we are one node only and therefore also connected by
          // definition
          break;
        }

        // ok, we have possible partners, lets make an edge
        // pick one randomly
        int partnerIndex = rnd.nextInt(possibleNeighbourIndices.size());
        graph.addEdge(new AnnotatedEdge<>(nodeList.get(i), nodeList
            .get(possibleNeighbourIndices.get(partnerIndex)), elDistri
            .getRandomNumber()));

        // update degrees
View Full Code Here

   * @see org.jamesii.core.model.variables.IQualitativeVariable#setRandomValue()
   */
  @Override
  public void setRandomValue() {

    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    int rand1 = r1.nextInt(getCategories().size());

    setValue(getCategory(rand1));
  }
View Full Code Here

    return getValue().add(addVal);
  }

  @Override
  public void setRandomValue() {
    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    double rand1 = r1.nextDouble();

    if (getLowerBound() == null) {
      setLowerBound(new BigDecimal(Double.MIN_VALUE));
    }
View Full Code Here

    return (int) newVal;
  }

  @Override
  public void setRandomValue() {
    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    int rand1;
    int increment = 1;

    if (getUpperBound() == null) {
      setUpperBound(Integer.MAX_VALUE / 2);
      increment = 0;
    }
    if (getLowerBound() == null) {
      setLowerBound(Integer.MIN_VALUE / 2);
    }

    rand1 = r1.nextInt(getUpperBound() - getLowerBound() + increment);

    rand1 += getLowerBound();

    setValue(rand1);
  }
View Full Code Here

    if (getUpperBound() == null) {
      setUpperBound(Float.MAX_VALUE / 2);
    }

    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    float rand1 = r1.nextFloat();

    setValue(getLowerBound() + (getUpperBound() - getLowerBound()) * rand1);
  }
View Full Code Here

    return (short) newVal;
  }

  @Override
  public void setRandomValue() {
    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    double rand1 = r1.nextDouble();

    if (getLowerBound() == null) {
      setLowerBound(Short.valueOf(Short.MIN_VALUE));
    }
View Full Code Here

    return Math.round(getValue() + factor * getStepWidth());
  }

  @Override
  public void setRandomValue() {
    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    long rand1 = r1.nextLong();

    if (getLowerBound() == null) {
      setLowerBound(Long.MIN_VALUE / 2);
    }

View Full Code Here

    return getValue().add(addVal.toBigInteger());
  }

  @Override
  public void setRandomValue() {
    IRandom r1 = SimSystem.getRNGGenerator().getNextRNG();
    double rand1 = r1.nextDouble();

    if (getLowerBound() == null) {
      setLowerBound(new BigInteger(String.valueOf(Long.MIN_VALUE)));
    }
View Full Code Here

   *           Signals that an I/O exception has occurred.
   */
  public static void saveGraphToDOT(String fileName,
      ILabeledGraph<Integer, ?, Double, Double> graph,
      Map<Integer, Integer> partition) throws IOException {
    IRandom rand = SimSystem.getRNGGenerator().getNextRNG();
    try (FileWriter file = new FileWriter(fileName)) {
      int vertexCount = graph.getVertexCount();
      Map<Integer, Double> vertexLabels = graph.getVertexLabels();
      Map<Integer, Map<Integer, Double>> edgeLabels = graph.getEdgeLabels();
      List<List<Integer>> adjacencyLists = graph.getAdjacencyLists();
View Full Code Here

TOP

Related Classes of org.jamesii.core.math.random.generators.IRandom

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.