/** {@inheritDoc} */
  @Override
  public Object read(final InputStream is) {
    final BoltzmannMachine result = new BoltzmannMachine();
    final EncogReadHelper in = new EncogReadHelper(is);
    EncogFileSection section;

    while ((section = in.readNextSection()) != null) {
      if (section.getSectionName().equals("BOLTZMANN")
          && section.getSubSectionName().equals("PARAMS")) {
        final Map<String, String> params = section.parseParams();
        result.getProperties().putAll(params);
      }
      if (section.getSectionName().equals("BOLTZMANN")
          && section.getSubSectionName().equals("NETWORK")) {
        final Map<String, String> params = section.parseParams();
        result.setWeights(
            NumberList.fromList(CSVFormat.EG_FORMAT, params.get(PersistConst.WEIGHTS)));
        result.setCurrentState(
            NumberList.fromList(CSVFormat.EG_FORMAT, params.get(PersistConst.OUTPUT)));
        result.setNeuronCount(EncogFileSection.parseInt(params, PersistConst.NEURON_COUNT));

        result.setThreshold(
            NumberList.fromList(CSVFormat.EG_FORMAT, params.get(PersistConst.THRESHOLDS)));
        result.setAnnealCycles(EncogFileSection.parseInt(params, BoltzmannMachine.ANNEAL_CYCLES));
        result.setRunCycles(EncogFileSection.parseInt(params, BoltzmannMachine.RUN_CYCLES));
        result.setTemperature(EncogFileSection.parseDouble(params, PersistConst.TEMPERATURE));
      }
    }

    return result;
  }
  /** {@inheritDoc} */
  @Override
  public ActivationFunction createActivationFunction(String fn) {
    String name;
    double[] params;

    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++) {
      af.setParam(i, params[i]);
    }

    return af;
  }