Package org.encog

Examples of org.encog.EncogError


    final MLMethod method = (MLMethod) EncogDirectoryPersistence
        .loadObject(methodFile);

    if (!(method instanceof MLFactory)) {
      throw new EncogError("Code generation not yet supported for: "
          + method.getClass().getName());
    }

    final MLFactory factoryMethod = (MLFactory) method;
View Full Code Here


  private void levelOff() {
    int total = 0;
    final List<Species> list = this.population.getSpecies();

    if (list.size() == 0) {
      throw new EncogError(
          "Can't speciate, next generation contains no species.");
    }

    Collections.sort(list, new SpeciesComparator(this.owner));
View Full Code Here

      // a species
      result.remove(s.getLeader());
    }

    if (this.population.getSpecies().size() == 0) {
      throw new EncogError("Can't speciate, the population is empty.");
    }

    return result;
  }
View Full Code Here

   */
  private void speciateAndCalculateSpawnLevels(final List<Genome> genomes) {
    double maxScore = 0;

    if (genomes.size() == 0) {
      throw new EncogError("Can't speciate, the population is empty.");
    }

    final List<Species> speciesCollection = this.population.getSpecies();

    if (speciesCollection.size() == 0) {
      throw new EncogError("Can't speciate, there are no species.1");
    }

    // calculate compatibility between genomes and species
    adjustCompatibilityThreshold();

    // assign genomes to species (if any exist)
    for (final Genome g : genomes) {
      Species currentSpecies = null;
      final Genome genome = g;

      if (!Double.isNaN(genome.getAdjustedScore())
          && !Double.isInfinite(genome.getAdjustedScore())) {
        maxScore = Math.max(genome.getAdjustedScore(), maxScore);
      }

      for (final Species s : speciesCollection) {
        final double compatibility = getCompatibilityScore(genome,
            s.getLeader());

        if (compatibility <= this.compatibilityThreshold) {
          currentSpecies = s;
          addSpeciesMember(s, genome);
          genome.setSpecies(s);
          break;
        }
      }

      // if this genome did not fall into any existing species, create a
      // new species
      if (currentSpecies == null) {
        currentSpecies = new BasicSpecies(this.population, genome);
        this.population.getSpecies().add(currentSpecies);
      }
    }

    //
    double totalSpeciesScore = 0;
    for (final Species species : speciesCollection) {
      totalSpeciesScore += species.calculateShare(this.owner
          .getScoreFunction().shouldMinimize(), maxScore);
    }

    if (speciesCollection.size() == 0) {
      throw new EncogError("Can't speciate, there are no species.2");
    }
    if (totalSpeciesScore < Encog.DEFAULT_DOUBLE_EQUAL) {
      // This should not happen much, or if it does, only in the
      // beginning.
      // All species scored zero. So they are all equally bad. Just divide
View Full Code Here

      return this.neatFactory.create(architecture, input, output);
    } else if (MLMethodFactory.TYPE_EPL.equals(methodType)) {
      return this.eplFactory.create(architecture, input, output);
    }
   
    throw new EncogError("Unknown method type: " + methodType);
  }
View Full Code Here

      return this.neatGAFactory.create(method, training, args2);
    } else if (MLTrainFactory.TYPE_EPL_GA.equals(type) ) {
      return this.eplTrainFctory.create(method, training, args2);
    }
    else {
      throw new EncogError("Unknown training type: " + type);
    }
  }
View Full Code Here

   * Update the species share of the next population.
   */
  private void updateShare() {
    final int speciesCount = this.owner.getPopulation().getSpecies().size();
    if (speciesCount != 1) {
      throw new EncogError(
          "SingleSpeciation can only be used with a species count of 1, species count is "
              + speciesCount);
    }

    final Species species = this.owner.getPopulation().getSpecies().get(0);
View Full Code Here

    int index = fn.indexOf('[');
    if (index != -1) {
      name = fn.substring(0, index).toLowerCase();
      int index2 = fn.indexOf(']');
      if (index2 == -1) {
        throw new EncogError(
            "Unbounded [ while parsing activation function.");
      }
      String a = fn.substring(index + 1, index2);
      params = NumberList.fromList(CSVFormat.EG_FORMAT, a);

    } else {
      name = fn.toLowerCase();
      params = new double[0];
    }

    ActivationFunction af = allocateAF(name);
   
    if( af==null ) {
      return null;
    }

    if (af.getParamNames().length != params.length) {
      throw new EncogError(name + " expected "
          + af.getParamNames().length + ", but " + params.length
          + " were provided.");
    }

    for (int i = 0; i < af.getParamNames().length; i++) {
View Full Code Here

        ScriptProperties.ML_CONFIG_TYPE,
        MLMethodFactory.TYPE_EPL);
    String vars = "";
   
    if( inputColumns>26 ) {
      throw new EncogError("More than 26 input variables is not supported for EPL.");
    } else if( inputColumns<=3 ) {
      StringBuilder temp = new StringBuilder();
      for(int i=0;i<inputColumns;i++) {
        if( temp.length()>0 ) {
          temp.append(',');
View Full Code Here

    final MLMethod method = (MLMethod) EncogDirectoryPersistence
        .loadObject(methodFile);

    if (!(method instanceof MLFactory)) {
      throw new EncogError("Code generation not yet supported for: "
          + method.getClass().getName());
    }

    final MLFactory factoryMethod = (MLFactory) method;
View Full Code Here

TOP

Related Classes of org.encog.EncogError

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.