Examples of Randomizer


Examples of aima.core.util.Randomizer

  @Test
  public void testPassiveTDAgent() {
    PassiveTDAgent<CellWorldPosition, String> agent = new PassiveTDAgent<CellWorldPosition, String>(
        fourByThree, policy);
    // Randomizer r = new JavaRandomizer();
    Randomizer r = new MockRandomizer(new double[] { 0.1, 0.9, 0.2, 0.8,
        0.3, 0.7, 0.4, 0.6, 0.5 });
    MDPUtilityFunction<CellWorldPosition> uf = null;
    for (int i = 0; i < 200; i++) {
      agent.executeTrial(r);
      uf = agent.getUtilityFunction();
View Full Code Here

Examples of aima.core.util.Randomizer

  @SuppressWarnings("unused")
  @Test
  public void testQLearningAgent() {
    QLearningAgent<CellWorldPosition, String> qla = new QLearningAgent<CellWorldPosition, String>(
        fourByThree);
    Randomizer r = new MockRandomizer(new double[] { 0.1, 0.9, 0.2, 0.8,
        0.3, 0.7, 0.4, 0.6, 0.5 });

    // Randomizer r = new JavaRandomizer();
    Hashtable<Pair<CellWorldPosition, String>, Double> q = null;
    QTable<CellWorldPosition, String> qTable = null;
View Full Code Here

Examples of aima.core.util.Randomizer

  @Test
  public void testFirstStepsOfQLAAgentUnderNormalProbability() {
    QLearningAgent<CellWorldPosition, String> qla = new QLearningAgent<CellWorldPosition, String>(
        fourByThree);

    Randomizer alwaysLessThanEightyPercent = new MockRandomizer(
        new double[] { 0.7 });
    CellWorldPosition startingPosition = new CellWorldPosition(1, 4);
    String action = qla.decideAction(new MDPPerception<CellWorldPosition>(
        startingPosition, -0.04));
    Assert.assertEquals(CellWorld.LEFT, action);
View Full Code Here

Examples of aima.core.util.Randomizer

    CellWorldPosition startingPosition = new CellWorldPosition(1, 4);
    String action = qla.decideAction(new MDPPerception<CellWorldPosition>(
        startingPosition, -0.04));
    Assert.assertEquals(CellWorld.LEFT, action);

    Randomizer betweenEightyANdNinetyPercent = new MockRandomizer(
        new double[] { 0.85 }); // to force left to become an "up"
    qla.execute(action, betweenEightyANdNinetyPercent);
    Assert.assertEquals(new CellWorldPosition(2, 4), qla.getCurrentState());
    Assert.assertEquals(-1.0, qla.getCurrentReward(), 0.001);
    Assert.assertEquals(0.0,
View Full Code Here

Examples of io.github.benas.jpopulator.api.Randomizer

    public static Populator buildCustomerPopulator() {
        Date today = new Date();
        Date nextYear = new Date();nextYear.setYear(today.getYear() + 1);
        return new PopulatorBuilder()
                .registerRandomizer(Customer.class, Integer.TYPE, "id", new Randomizer() {
                    Random random = new Random();
                    @Override
                    public Integer getRandomValue() {
                        return Math.abs(random.nextInt(1000000));
                    }
View Full Code Here

Examples of org.encog.mathutil.randomize.Randomizer

   */
  private void randomizeNeuron(final int targetLayer, final int neuron,
      final boolean useRange, final double low, final double high,
      final boolean usePercent, final double percent) {

    final Randomizer d;

    if (useRange) {
      d = new RangeRandomizer(low, high);
    } else {
      d = new Distort(percent);
    }

    // check for errors
    this.network.validateNeuron(targetLayer, neuron);

    // access the flat network
    final FlatNetwork flat = this.network.getStructure().getFlat();

    // allocate new weights now that we know how big the new weights will be
    final double[] newWeights = new double[flat.getWeights().length];

    // construct the new weights
    int weightsIndex = 0;

    for (int fromLayer = flat.getLayerCounts().length - 2; fromLayer >= 0; fromLayer--) {
      final int fromNeuronCount = this.network
          .getLayerTotalNeuronCount(fromLayer);
      final int toNeuronCount = this.network
          .getLayerNeuronCount(fromLayer + 1);
      final int toLayer = fromLayer + 1;

      for (int toNeuron = 0; toNeuron < toNeuronCount; toNeuron++) {
        for (int fromNeuron = 0; fromNeuron < fromNeuronCount; fromNeuron++) {
          boolean randomize = false;
          if ((toLayer == targetLayer) && (toNeuron == neuron)) {
            randomize = true;
          } else if ((fromLayer == targetLayer)
              && (fromNeuron == neuron)) {
            randomize = true;
          }

          double weight = this.network.getWeight(fromLayer,
              fromNeuron, toNeuron);

          if (randomize) {
            weight = d.randomize(weight);
          }

          newWeights[weightsIndex++] = weight;
        }
      }
View Full Code Here

Examples of org.encog.mathutil.randomize.Randomizer

  }

  public static FlatNetwork createNetwork() {
    BasicNetwork network = EncogUtility
        .simpleFeedForward(2, 4, 0, 1, false);
    Randomizer randomizer = new ConsistentRandomizer(-1, 1);
    randomizer.randomize(network);
    return network.getStructure().getFlat().clone();
  }
View Full Code Here

Examples of org.encog.mathutil.randomize.Randomizer

  public void testCompleteTrain()
  {
    MLDataSet trainingData = new BasicMLDataSet(XOR.XOR_INPUT,XOR.XOR_IDEAL);
   
    BasicNetwork network = EncogUtility.simpleFeedForward(2, 5, 7, 1, true);
    Randomizer randomizer = new ConsistentRandomizer(-1, 1, 19);
    //randomizer.randomize(network);
    System.out.println(network.dumpWeights());
    MLTrain rprop = new ResilientPropagation(network, trainingData);
    int iteration = 0;
    do {
View Full Code Here

Examples of org.encog.mathutil.randomize.Randomizer

    g.randomize((BasicNetwork) this.method);
    setDirty(true);
  }

  private void optionRandomize(RandomizeNetworkDialog dialog) {
    Randomizer r = null;

    switch (dialog.getType().getSelectedIndex()) {
    case 0: // Random
      r = new RangeRandomizer(dialog.getLow().getValue(), dialog
          .getHigh().getValue());
      break;
    case 1: // Nguyen-Widrow
      r = new NguyenWidrowRandomizer(dialog.getLow().getValue(), dialog
          .getHigh().getValue());
      break;
    case 2: // Fan in
      r = new FanInRandomizer(dialog.getLow().getValue(), dialog
          .getHigh().getValue(), false);
      break;
    }

    if (r != null) {
      r.randomize((BasicNetwork) this.method);
      setDirty(true);
    }
  }
View Full Code Here

Examples of org.encog.mathutil.randomize.Randomizer

   */
  private void randomizeNeuron(final int targetLayer, final int neuron,
      final boolean useRange, final double low, final double high,
      final boolean usePercent, final double percent) {

    final Randomizer d;

    if (useRange) {
      d = new RangeRandomizer(low, high);
    } else {
      d = new Distort(percent);
    }

    // check for errors
    this.network.validateNeuron(targetLayer, neuron);

    // access the flat network
    final FlatNetwork flat = this.network.getStructure().getFlat();

    // allocate new weights now that we know how big the new weights will be
    final double[] newWeights = new double[flat.getWeights().length];

    // construct the new weights
    int weightsIndex = 0;

    for (int fromLayer = flat.getLayerCounts().length - 2; fromLayer >= 0; fromLayer--) {
      final int fromNeuronCount = this.network
          .getLayerTotalNeuronCount(fromLayer);
      final int toNeuronCount = this.network
          .getLayerNeuronCount(fromLayer + 1);
      final int toLayer = fromLayer + 1;

      for (int toNeuron = 0; toNeuron < toNeuronCount; toNeuron++) {
        for (int fromNeuron = 0; fromNeuron < fromNeuronCount; fromNeuron++) {
          boolean randomize = false;
          if ((toLayer == targetLayer) && (toNeuron == neuron)) {
            randomize = true;
          } else if ((fromLayer == targetLayer)
              && (fromNeuron == neuron)) {
            randomize = true;
          }

          double weight = this.network.getWeight(fromLayer,
              fromNeuron, toNeuron);

          if (randomize) {
            weight = d.randomize(weight);
          }

          newWeights[weightsIndex++] = weight;
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.