Package org.encog.ml.bayesian

Examples of org.encog.ml.bayesian.BayesianError


  }
 
  public RandomVariable requireEvent(String label) {
    RandomVariable result = this.map.get(label);
    if( result==null ) {
      throw new BayesianError("The variable " + label + " is not defined.");
    }
    return result;
  }
View Full Code Here


   * @param result The resulting probability.
   * @param args The arguments.
   */
  public void addLine(double prob, int result, int... args) {
    if (args.length != this.event.getParents().size()) {
      throw new BayesianError("Truth table line with " + args.length
          + ", specied for event with "
          + this.event.getParents().size()
          + " parents.  These numbers must be the same");
    }

    TableLine line = findLine(result, args);

    if (line == null) {
      if (this.lines.size() == this.getMaxLines()) {
        throw new BayesianError("This truth table is already full.");
      }

      line = new TableLine(prob, result, args);
      this.lines.add(line);
    } else {
View Full Code Here

  /**
   * Validate the truth table.
   */
  public void validate() {
    if (this.lines.size() != this.getMaxLines()) {
      throw new BayesianError("Truth table for " + this.event.toString()
          + " only has " + this.lines
          + " line(s), should have " + this.getMaxLines()
          + " line(s).");
    }

View Full Code Here

          return line.getResult();
        }
      }
    }

    throw new BayesianError("Incomplete logic table for event: "
        + this.event.toString());
  }
View Full Code Here

    try {
      fis = new FileInputStream(f);
      return readBIF(fis);
    } catch (IOException ex) {
      throw new BayesianError(ex);
    } finally {
      if (fis != null) {
        try {
          fis.close();
        } catch (IOException ex) {
View Full Code Here

      SAXParserFactory spf = SAXParserFactory.newInstance();
      SAXParser sp = spf.newSAXParser();
      sp.parse(is, h);
      return h.getNetwork();
    } catch (IOException ex) {
      throw new BayesianError(ex);
    } catch (ParserConfigurationException ex) {
      throw new BayesianError(ex);
    } catch (SAXException ex) {
      throw new BayesianError(ex);
    }
  }
View Full Code Here

    FileOutputStream fos = null;
    try {
      fos = new FileOutputStream(file);
      writeBIF(fos, network);
    } catch (IOException ex) {
      throw new BayesianError(ex);
    } finally {
      if (fos != null) {
        try {
          fos.close();
        } catch (IOException e) {
View Full Code Here

  /**
   * @return The child events.
   */
  public ParsedEvent getChildEvent() {
    if( this.baseEvents.size()>1 ) {
      throw new BayesianError("Only one base event may be used to define a probability, i.e. P(a), not P(a,b).");
    }
   
    if( this.baseEvents.size()==0) {
      throw new BayesianError("At least one event must be provided, i.e. P() or P(|a,b,c) is not allowed.");
    }
   
    return this.baseEvents.get(0);
  }
View Full Code Here

              parser.advance();
              parser.eatWhiteSpace();
              double min = Double.parseDouble(parser.readToWhiteSpace());
              parser.eatWhiteSpace();
              if(!parser.lookAhead("to", true) ) {
                throw new BayesianError("Expected \"to\" in probability choice range.");
              }
              parser.advance(2);
              double max = CSVFormat.EG_FORMAT.parse(parser.readToChars(",]"));
              parsedEvent.getList().add(new ParsedChoice(labelName,min,max));
             
View Full Code Here

      addEvents(parser, result.getGivenEvents(), ",)=[]");

    }

    if (parser.peek() != ')') {
      throw new BayesianError("Probability not properly terminated.");
    }

    return result;
 
  }
View Full Code Here

TOP

Related Classes of org.encog.ml.bayesian.BayesianError

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.