本文整理汇总了C++中Formula::set_number_variables方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::set_number_variables方法的具体用法?C++ Formula::set_number_variables怎么用?C++ Formula::set_number_variables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formula
的用法示例。
在下文中一共展示了Formula::set_number_variables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DIMACS_Input
void DIMACS_Input(std::istream& in, Formula& F) {
// NOCH ZU TUN:
// Verbesserte Fehlermeldungen:
// - mehrsprachig
// - Position im Eingabe-Strom (Zeilennummer, absolute Position)
// Klaerung der DIMACS-Syntax
// Formula : Concept Formula-Constructor
// Assumption: Formula::Lit::Var can be constructed via strings as names
// Syntax:
// First lines with comments, starting with "c";
// then a line "p cnf n c";
// then the clauses, where variables are denoted by names, literals are separated by spaces, completed by "0";
// names: non-empty sequence of characters without space symbols and not starting with "-" and not equal to "0"
// literals: either a name or "-" immediately followed by a name
typedef typename Formula::size_type size_type;
typedef typename Formula::Lit Lit;
typedef typename Lit::Var Var;
using namespace std;
streamsize nr_lines = 1;
{
vector<string> comment_lines;
string token;
// reading comments, until the parameter line is found
for (;; ++nr_lines) {
in >> token;
if (not in)
throw ReadError("DIMACS_Input(std::istream& in, Formula& F) : line " + StringHandling::toString(nr_lines));
if (token == "p") {
in >> token;
if (token == "cnf")
break;
else
throw MissingCnfError("DIMACS_Input(std::istream& in, Formula& F) : line " + StringHandling::toString(nr_lines) + ", parameter line has token \"" + token + "\" instead of \"cnf\"");
}
if (token[0] != 'c')
throw SyntaxError("DIMACS_Input(std::istream& in, Formula& F) : Non-comment line before parameter line; line " + StringHandling::toString(nr_lines) + ", first token \"" + token + "\"");
string rest_of_line;
getline(in, rest_of_line);
comment_lines.push_back(token + rest_of_line);
}
{
size_type n, c;
in >> n >> c;
if (not in)
throw ParameterError("DIMACS_Input(std::istream& in, Formula& F) : invalid parameter values; line " + StringHandling::toString(nr_lines));
{
string rest_of_line;
getline(in, rest_of_line);
if (not rest_of_line.empty())
throw AfterParameterError("DIMACS_Input(std::istream& in, Formula& F) : line " + StringHandling::toString(nr_lines) + ", rest of line after parameter values is not empty, but is \"" + rest_of_line + "\"");
}
F.set_number_variables(n);
F.set_number_clauses(c);
F.begin_construction();
}
for (vector<string>::const_iterator i = comment_lines.begin(); i != comment_lines.end(); ++i)
F.comment_line(*i);
}