5 #ifndef LYDIASYFT_GR1_H
6 #define LYDIASYFT_GR1_H
9 #include "string_utilities.h"
53 std::vector<CUDD::BDD> env_justices;
54 std::vector<CUDD::BDD> agn_justices;
61 std::size_t &line_number) {
63 CUDD::BDD justice = var_mgr->cudd_mgr()->bddOne();
65 while (std::getline(in, line) && (line.find(
"Justice-End") == std::string::npos)) {
67 CUDD::BDD clause = var_mgr->cudd_mgr()->bddZero();
69 clause = var_mgr->cudd_mgr()->bddOne();
70 }
else if (line ==
"false") {
71 clause = var_mgr->cudd_mgr()->bddZero();
73 std::vector<std::string> tokens;
75 tokens = split(line,
" ");
76 std::vector<std::string> variable_names;
78 for (std::string token: tokens) {
79 std::string variable_name;
80 variable_name = (line.find(
"!") == std::string::npos) ? token : token.substr(2,
83 variable_names.push_back(variable_name);
84 var_mgr->create_named_variables(variable_names);
85 CUDD::BDD variable_bdd = var_mgr->name_to_variable(variable_name);
86 clause = (line.find(
"!") == std::string::npos) ? (clause | variable_bdd) : (clause |
90 justice = justice & clause;
96 static std::runtime_error bad_file_format_exception(
97 std::size_t line_number) {
98 return std::runtime_error(
"Incorrect format in line " +
99 std::to_string(line_number) +
100 " of the GR(1) file.");
110 const std::string &gr1_filename) {
112 std::ifstream in(gr1_filename);
113 std::size_t line_number = 0;
115 while (std::getline(in, line) && line !=
"End") {
116 if (line.find(
"Justice") != std::string::npos) {
117 if (line.find(
"Env") == std::string::npos && line.find(
"Agn") == std::string::npos) {
118 throw bad_file_format_exception(line_number);
122 if (line.find(
"Env") != std::string::npos) {
123 gr1.env_justices.push_back(justice);
125 gr1.agn_justices.push_back(justice);
static GR1 read_from_gr1_file(const std::shared_ptr< VarMgr > &var_mgr, const std::string &gr1_filename)
Stores a GR(1) condition.
Definition: GR1.h:109
static CUDD::BDD read_gr1_justice(const std::shared_ptr< VarMgr > &var_mgr, std::istream &in, std::size_t &line_number)
Stores a player justice.
Definition: GR1.h:59