Beispiel #1
0
  public static BeliefNetwork load(FileInputStream FIS, String file) {
    IOPlugInLoader pil = IOPlugInLoader.getInstance();
    Importer IMP = pil.GetImporterByExt(pil.GetExt(file));
    OmniFormatV1_Reader ofv1r = new OmniFormatV1_Reader();
    IMP.load(FIS, ofv1r);
    BeliefNetwork bn = ofv1r.GetBeliefNetwork(0);
    if (_RATIONAL) {
      BeliefNode[] n = bn.getNodes();
      for (int i = 0; i < n.length; i++) n[i].getCPF().convertDouble2Rational();
    }
    if (_FLOAT) {
      BeliefNode[] n = bn.getNodes();
      for (int i = 0; i < n.length; i++) n[i].getCPF().convertDouble2Float();
    }

    return bn;
  }
Beispiel #2
0
 public static BeliefNetwork load(String file) {
   try {
     IOPlugInLoader pil = IOPlugInLoader.getInstance();
     Importer IMP = pil.GetImporterByExt(pil.GetExt(file));
     FileInputStream FIS = new FileInputStream(file);
     OmniFormatV1_Reader ofv1r = new OmniFormatV1_Reader();
     IMP.load(FIS, ofv1r);
     BeliefNetwork bn = ofv1r.GetBeliefNetwork(0);
     if (_RATIONAL) {
       BeliefNode[] n = bn.getNodes();
       for (int i = 0; i < n.length; i++) n[i].getCPF().convertDouble2Rational();
     }
     if (_FLOAT) {
       BeliefNode[] n = bn.getNodes();
       for (int i = 0; i < n.length; i++) n[i].getCPF().convertDouble2Float();
     }
     return bn;
   } catch (Exception e) {
     outputln("file: `" + file + "` was not found");
     return null;
   }
 }