-/* Copyright (C) 2009 Charles Vaske [cvaske at soe dot ucsc dot edu]
- University of California Santa Cruz
-
- This file is part of libDAI.
-
- libDAI is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- libDAI is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libDAI; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+/* This file is part of libDAI - http://www.libdai.org/
+ *
+ * libDAI is licensed under the terms of the GNU General Public License version
+ * 2, or (at your option) any later version. libDAI is distributed without any
+ * warranty. See the file COPYING for more details.
+ *
+ * Copyright (C) 2009 Charles Vaske [cvaske at soe dot ucsc dot edu]
+ * Copyright (C) 2009 University of California, Santa Cruz
+ */
#include <sstream>
for( std::map<Var, size_t>::const_iterator i = _obs.begin(); i != _obs.end(); ++i )
alg.clamp( alg.fg().findVar(i->first), i->second );
}
-
+
void Evidence::addEvidenceTabFile( std::istream &is, FactorGraph &fg ) {
std::map<std::string, Var> varMap;
void Evidence::addEvidenceTabFile( std::istream &is, std::map<std::string, Var> &varMap ) {
std::string line;
getline( is, line );
-
+
// Parse header
std::vector<std::string> header_fields;
tokenizeString( line, header_fields );
std::vector<std::string>::const_iterator p_field = header_fields.begin();
- if( p_field == header_fields.end() )
+ if( p_field == header_fields.end() )
DAI_THROW(INVALID_EVIDENCE_FILE);
std::vector<Var> vars;
DAI_THROW(INVALID_EVIDENCE_FILE);
vars.push_back( elem->second );
}
-
+
// Read samples
while( getline(is, line) ) {
std::vector<std::string> fields;
tokenizeString( line, fields );
- if( fields.size() != vars.size() )
+ if( fields.size() != vars.size() )
DAI_THROW(INVALID_EVIDENCE_FILE);
-
+
Observation sampleData;
for( size_t i = 0; i < vars.size(); ++i ) {
if( fields[i].size() > 0 ) { // skip if missing observation