From edcab9c0a34e8777c04691229f9370fc51162fd9 Mon Sep 17 00:00:00 2001 From: sp Date: Wed, 10 Jan 2024 18:55:15 +0100 Subject: [PATCH 1/8] removed unused options from cli option parsing Note: Some of these functionalities might return in the future --- main.cpp | 40 +--------------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/main.cpp b/main.cpp index be33399..4e7a95a 100644 --- a/main.cpp +++ b/main.cpp @@ -48,15 +48,6 @@ int main(int argc, char* argv[]) { auto helpOption = optionParser.add("h", "help", "Print this help message."); auto inputFilename = optionParser.add>("i", "input-file", "Filename of the input file."); auto outputFilename = optionParser.add>("o", "output-file", "Filename for the output file."); - - auto agentsToBeConsidered = optionParser.add, popl::Attribute::optional>("a", "agents", "Which parsed agents should be considered in the output. WIP."); - auto viewForAgents = optionParser.add, popl::Attribute::optional>("v", "view", "Agents for which the 'view'('direction') variable should be included. WIP."); - - auto probabilisticBehaviourAgents = optionParser.add, popl::Attribute::optional>("p", "prob-beh", "Agents for which we want to include probabilistic actions"); - auto probabilities = optionParser.add, popl::Attribute::optional>("q", "probs", "The probabilities for which probabilistic actions should be added. WIP"); - - auto enforceOneWays = optionParser.add("f", "force-oneways", "Enforce encoding of oneways. This entails that slippery tiles do not allow turning and have prob 1 to shift the agent by one and makes turning impossible if in a one tile wide section of the grid."); - auto configFilename = optionParser.add, popl::Attribute::optional>("c", "config-file", "Filename of the predicate configuration file."); @@ -75,35 +66,6 @@ int main(int argc, char* argv[]) { } GridOptions gridOptions = { {}, {} }; - if(agentsToBeConsidered->is_set()) { - gridOptions.agentsToBeConsidered = parseCommaSeparatedString(agentsToBeConsidered->value(0)); - } - if(viewForAgents->is_set()) { - gridOptions.agentsWithView = parseCommaSeparatedString(viewForAgents->value(0)); - } - if(enforceOneWays->is_set()) { - gridOptions.enforceOneWays = true; - } - if(probabilisticBehaviourAgents->is_set()) { - gridOptions.agentsWithProbabilisticBehaviour = parseCommaSeparatedString(probabilisticBehaviourAgents->value(0)); - for(auto const& a : gridOptions.agentsWithProbabilisticBehaviour) { - std::cout << a << std::endl; - } - if(probabilities->is_set()) { - std::vector parsedStrings = parseCommaSeparatedString(probabilities->value(0)); - - std::transform(parsedStrings.begin(), parsedStrings.end(), std::back_inserter(gridOptions.probabilitiesForActions), [](const std::string& string) { - return std::stof(string); - }); - for(auto const& a : gridOptions.probabilitiesForActions) { - std::cout << a << std::endl; - } - } else { - throw std::logic_error{ "When adding agents with probabilistic behaviour, you also need to specify a list of probabilities via --probs." }; - } - } - - std::fstream file {outputFilename->value(0), file.trunc | file.out}; std::fstream infile {inputFilename->value(0), infile.in}; std::string line, content, background, rewards, properties; @@ -149,7 +111,7 @@ int main(int argc, char* argv[]) { cells backgroundCells; std::vector configurations; std::map stateRewards; - float faultyProbability = 0.0; + float faultyProbability = 0.1; float probIntended = 0.9; try { -- 2.20.1 From 74645d95b3b1dabd866b467bc61d3824011a3a77 Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Wed, 10 Jan 2024 21:29:00 +0100 Subject: [PATCH 2/8] basic support for probabiliteis in config --- main.cpp | 5 ++++- util/ConfigYaml.cpp | 29 +++++++++++++++++++++++++++-- util/ConfigYaml.h | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 4e7a95a..21bcc22 100644 --- a/main.cpp +++ b/main.cpp @@ -110,6 +110,7 @@ int main(int argc, char* argv[]) { cells contentCells; cells backgroundCells; std::vector configurations; + std::vector probabilities; std::map stateRewards; float faultyProbability = 0.1; float probIntended = 0.9; @@ -121,7 +122,9 @@ int main(int argc, char* argv[]) { // TODO } if (configFilename->is_set()) { YamlConfigParser parser(configFilename->value(0)); - configurations = parser.parseConfiguration(); + auto parseResult = parser.parseConfiguration(); + configurations = parseResult.configurations_; + probabilities = parseResult.probabilities_; } boost::escaped_list_separator seps('\\', ';', '\n'); diff --git a/util/ConfigYaml.cpp b/util/ConfigYaml.cpp index 07c2b8e..3a62b37 100644 --- a/util/ConfigYaml.cpp +++ b/util/ConfigYaml.cpp @@ -185,11 +185,32 @@ bool YAML::convert::decode(const YAML::Node& node, Constant& rhs) { return true; } +YAML::Node YAML::convert::encode(const Probability& rhs) { + YAML::Node node; + + node.push_back(rhs.probability_); + node.push_back(rhs.value_); + + return node; +} + +bool YAML::convert::decode(const YAML::Node& node, Probability& rhs) { + if (!node.IsDefined() || !node["probability"] || !node["value"]) { + return false; + } + + rhs.probability_ = node["probability"].as(); + rhs.value_ = node["value"].as(); + + return true; +} + const std::string Configuration::configuration_identifier_ { "; // created through configuration"}; const std::string Configuration::overwrite_identifier_{"; // Overwritten through configuration"}; - std::vector YamlConfigParser::parseConfiguration() { +YamlConfigParseResult YamlConfigParser::parseConfiguration() { std::vector configuration; + std::vector probabilities; try { YAML::Node config = YAML::LoadFile(file_); @@ -211,6 +232,10 @@ const std::string Configuration::overwrite_identifier_{"; // Overwritten through if (config["constants"]) { constants = config["constants"].as>(); } + + if (config["probabilities"]) { + probabilities = config["probabilities"].as>(); + } for (auto& label : labels) { configuration.push_back({label.createExpression(), label.label_ , ConfigType::Label, label.overwrite_}); @@ -234,5 +259,5 @@ const std::string Configuration::overwrite_identifier_{"; // Overwritten through std::cout << "while parsing configuration " << file_ << std::endl; } - return configuration; + return YamlConfigParseResult(configuration, probabilities); } \ No newline at end of file diff --git a/util/ConfigYaml.h b/util/ConfigYaml.h index 6b4e93a..1b28eda 100644 --- a/util/ConfigYaml.h +++ b/util/ConfigYaml.h @@ -2,6 +2,7 @@ #include #include +#include #include "yaml-cpp/yaml.h" @@ -43,6 +44,17 @@ struct Configuration } }; +struct Probability { + Probability() = default; + Probability(const Probability&) = default; + ~Probability() = default; + + std::string probability_; + double value_; + + friend std::ostream& operator <<(std::ostream& os, const Probability& property); +}; + struct Constant { private: @@ -137,6 +149,22 @@ struct YAML::convert { static bool decode(const YAML::Node& node, Constant& rhs); }; +template<> +struct YAML::convert { + static YAML::Node encode(const Probability& rhs); + static bool decode(const YAML::Node& node, Probability& rhs); +}; + +struct YamlConfigParseResult { + YamlConfigParseResult(std::vector configurations, std::vector probabilities) + : configurations_(configurations), probabilities_(probabilities) {} + + ~YamlConfigParseResult() = default; + YamlConfigParseResult(const YamlConfigParseResult&) = default; + + std::vector configurations_; + std::vector probabilities_; +}; struct YamlConfigParser { public: @@ -144,8 +172,8 @@ struct YamlConfigParser { YamlConfigParser(const YamlConfigParser&) = delete; ~YamlConfigParser() = default; - std::vector parseConfiguration(); + YamlConfigParseResult parseConfiguration(); private: std::string file_; -}; \ No newline at end of file +}; -- 2.20.1 From aad118cf62593be2fb152bce732a1f8fb9982bf5 Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Wed, 10 Jan 2024 23:09:35 +0100 Subject: [PATCH 3/8] config parsing for probabilities --- main.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index 21bcc22..e41ac3a 100644 --- a/main.cpp +++ b/main.cpp @@ -42,6 +42,24 @@ void print_info(boost::spirit::info const& what) { boost::apply_visitor(walker, what.value); } +void setProbability(const std::string& gridProperties, const std::vector configProperties, const std::string& identifier, float& prop) { + auto start_pos = gridProperties.find(identifier); + std::string seperator = ";"; + + if (start_pos != std::string::npos) { + auto end_pos = gridProperties.find('\n', start_pos); + auto value = gridProperties.substr(start_pos + identifier.length() + seperator.size(), end_pos - start_pos - identifier.length()); + prop = std::stod(value); + } + + auto yaml_config_prop = std::find_if(configProperties.begin(), configProperties.end(), [&identifier](const Probability& obj) -> bool {return obj.probability_ == identifier;} ); + + if (yaml_config_prop != configProperties.end()) { + prop = (*yaml_config_prop).value_; + } +} + + int main(int argc, char* argv[]) { popl::OptionParser optionParser("Allowed options"); @@ -114,6 +132,7 @@ int main(int argc, char* argv[]) { std::map stateRewards; float faultyProbability = 0.1; float probIntended = 0.9; + float probTurnIntended = 1; try { bool ok = phrase_parse(contentIter, contentLast, contentParser, qi::space, contentCells); @@ -136,15 +155,13 @@ int main(int argc, char* argv[]) { stateRewards[std::make_pair(x,y)] = reward; } if (!properties.empty()) { - auto faultProbabilityIdentifier = std::string("FaultProbability:"); - auto start_pos = properties.find(faultProbabilityIdentifier); - + auto faultProbabilityIdentifier = std::string("FaultProbability"); + auto probForwardIntendedIdentifier = std::string("ProbForwardIntended"); + auto probTurnIntendedIdentifier = std::string("ProbTurnIntended"); - if (start_pos != std::string::npos) { - auto end_pos = properties.find('\n', start_pos); - auto value = properties.substr(start_pos + faultProbabilityIdentifier.length(), end_pos - start_pos - faultProbabilityIdentifier.length()); - faultyProbability = std::stod(value); - } + setProbability(properties, probabilities, faultProbabilityIdentifier, faultyProbability); + setProbability(properties, probabilities, probForwardIntendedIdentifier, probIntended); + setProbability(properties, probabilities, probTurnIntendedIdentifier, probTurnIntended); } if(ok) { Grid grid(contentCells, backgroundCells, gridOptions, stateRewards, probIntended, faultyProbability); -- 2.20.1 From 91dcfb400ebf1fa3f291a15e90fd720f66e5a59b Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Wed, 10 Jan 2024 23:13:23 +0100 Subject: [PATCH 4/8] renamed action to command --- util/ConfigYaml.cpp | 22 +++++++++++----------- util/ConfigYaml.h | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/util/ConfigYaml.cpp b/util/ConfigYaml.cpp index 3a62b37..7dc392c 100644 --- a/util/ConfigYaml.cpp +++ b/util/ConfigYaml.cpp @@ -11,8 +11,8 @@ std::ostream& operator << (std::ostream &os, const Formula& formula) { return os; } -std::ostream& operator << (std::ostream& os, const Action& action) { - os << action.action_; +std::ostream& operator << (std::ostream& os, const Command& command) { + os << command.action_; return os; } @@ -23,8 +23,8 @@ std::ostream& operator << (std::ostream& os, const Constant& constant) { std::ostream& operator << (std::ostream& os, const Module& module) { os << "Module: " << module.module_ << std::endl; - for (auto& action : module.actions_) { - os << action << std::endl; + for (auto& command : module.commands_) { + os << command << std::endl; } return os; } @@ -45,7 +45,7 @@ std::string Formula::createExpression() const { return "formula " + formula_ + " = " + content_ + Configuration::configuration_identifier_; } -std::string Action::createExpression() const { +std::string Command::createExpression() const { if (overwrite_) { return action_ + "\t" + guard_ + "-> " + update_ + Configuration::overwrite_identifier_; } @@ -65,7 +65,7 @@ YAML::Node YAML::convert::encode(const Module& rhs) { YAML::Node node; node.push_back(rhs.module_); - node.push_back(rhs.actions_); + node.push_back(rhs.commands_); return node; } @@ -74,12 +74,12 @@ bool YAML::convert::decode(const YAML::Node& node, Module& rhs) { if (!node.Type() == NodeType::Map) { return false; } - rhs.actions_ = node["actions"].as>(); + rhs.commands_ = node["commands"].as>(); rhs.module_ = node["module"].as(); return true; } -YAML::Node YAML::convert::encode(const Action& rhs) { +YAML::Node YAML::convert::encode(const Command& rhs) { YAML::Node node; node.push_back(rhs.action_); @@ -90,7 +90,7 @@ YAML::Node YAML::convert::encode(const Action& rhs) { return node; } -bool YAML::convert::decode(const YAML::Node& node, Action& rhs) { +bool YAML::convert::decode(const YAML::Node& node, Command& rhs) { if (!node.Type() == NodeType::Map) { return false; } @@ -244,8 +244,8 @@ YamlConfigParseResult YamlConfigParser::parseConfiguration() { configuration.push_back({formula.createExpression(), formula.formula_ ,ConfigType::Formula, formula.overwrite_}); } for (auto& module : modules) { - for (auto& action : module.actions_) { - configuration.push_back({action.createExpression(), action.action_, ConfigType::Module, action.overwrite_, module.module_, action.index_}); + for (auto& command : module.commands_) { + configuration.push_back({command.createExpression(), command.action_, ConfigType::Module, command.overwrite_, module.module_, command.index_}); } } for (auto& constant : constants) { diff --git a/util/ConfigYaml.h b/util/ConfigYaml.h index 1b28eda..ccaa34c 100644 --- a/util/ConfigYaml.h +++ b/util/ConfigYaml.h @@ -95,7 +95,7 @@ struct Formula { friend std::ostream& operator << (std::ostream &os, const Formula& formula); }; -struct Action { +struct Command { public: std::string action_; std::string guard_; @@ -105,13 +105,13 @@ struct Action { std::string createExpression() const; - friend std::ostream& operator << (std::ostream& os, const Action& action); + friend std::ostream& operator << (std::ostream& os, const Command& command); }; struct Module { public: - std::vector actions_; + std::vector commands_; std::string module_; friend std::ostream& operator << (std::ostream& os, const Module& module); @@ -125,9 +125,9 @@ struct YAML::convert { }; template<> -struct YAML::convert { - static YAML::Node encode(const Action& rhs); - static bool decode(const YAML::Node& node, Action& rhs); +struct YAML::convert { + static YAML::Node encode(const Command& rhs); + static bool decode(const YAML::Node& node, Command& rhs); }; -- 2.20.1 From 5a94f004fb035c7fbf15f92be61cc8a1916c3be0 Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Wed, 10 Jan 2024 23:14:02 +0100 Subject: [PATCH 5/8] added exampleconfig --- exampleConfig.yaml | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 exampleConfig.yaml diff --git a/exampleConfig.yaml b/exampleConfig.yaml new file mode 100644 index 0000000..dd51aa6 --- /dev/null +++ b/exampleConfig.yaml @@ -0,0 +1,55 @@ +--- +labels: + - label: "AgentIsInGoal" + text: "AgentIsInGoal" + +constants: + - constant: "prop_slippery_turn" + type: "double" + value: "9/9" + overwrite: True + - constant: "prop_next_neighbour_turn" + type: "double" + value: "0/9" + overwrite: True + - constant: "prop_slippery_move_forward" + type: "double" + value: "3/4" + overwrite: True + - constant: "prop_direct_neighbour" + type: "double" + value: "1/4" + - constant: "prop_next_neighbour" + type: "double" + value: "1/8" + overwrite: True + - constant: "total_prop" + type: "double" + value: "4" + overwrite: True + +probabilities: + - probability: "FaultProbability" + value: 0.1 + - probability: "ProbForwardIntended" + value: 0.1 + - probability: "ProbTurnIntended" + value: 0.1 + +modules: + - module: "Agent" + commands: + - action: "[Agent_turn_left]" + guard: "AgentIsOnSlippery" + update: "True" + overwrite: True + +... + +const double prop_zero = 0/9; +const double prop_next_neighbour = 1/9; +const double prop_slippery_move_forward = 7/9; +const double prop_slippery_turn = 6/9; +const double prop_next_neighbour_turn = 1/9; +const double prop_direct_neighbour = 2/9; +const double total_prop = 9; \ No newline at end of file -- 2.20.1 From 78c42f034e236189d599a82e027c7f6c2eaa1aaf Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Thu, 11 Jan 2024 21:52:41 +0100 Subject: [PATCH 6/8] overwrite indices as vector --- exampleConfig.yaml | 48 ++++++++++++--------------------------------- main.cpp | 2 +- util/ConfigYaml.cpp | 9 +++++++-- util/ConfigYaml.h | 6 +++--- util/Grid.cpp | 39 ++++++++++++++++++------------------ 5 files changed, 44 insertions(+), 60 deletions(-) diff --git a/exampleConfig.yaml b/exampleConfig.yaml index dd51aa6..8c3042b 100644 --- a/exampleConfig.yaml +++ b/exampleConfig.yaml @@ -3,34 +3,15 @@ labels: - label: "AgentIsInGoal" text: "AgentIsInGoal" -constants: - - constant: "prop_slippery_turn" - type: "double" - value: "9/9" - overwrite: True - - constant: "prop_next_neighbour_turn" - type: "double" - value: "0/9" - overwrite: True - - constant: "prop_slippery_move_forward" - type: "double" - value: "3/4" - overwrite: True - - constant: "prop_direct_neighbour" - type: "double" - value: "1/4" - - constant: "prop_next_neighbour" - type: "double" - value: "1/8" - overwrite: True - - constant: "total_prop" - type: "double" - value: "4" - overwrite: True +# constants: +# - constant: "prop_slippery_turn" +# type: "double" +# value: "9/9" +# overwrite: True probabilities: - probability: "FaultProbability" - value: 0.1 + value: 0.2 - probability: "ProbForwardIntended" value: 0.1 - probability: "ProbTurnIntended" @@ -43,13 +24,10 @@ modules: guard: "AgentIsOnSlippery" update: "True" overwrite: True - -... - -const double prop_zero = 0/9; -const double prop_next_neighbour = 1/9; -const double prop_slippery_move_forward = 7/9; -const double prop_slippery_turn = 6/9; -const double prop_next_neighbour_turn = 1/9; -const double prop_direct_neighbour = 2/9; -const double total_prop = 9; \ No newline at end of file + index: 3 + - action: "[Agent_turn_right]" + guard: "AgentIsOnSlippery" + update: "True" + overwrite: True + index: [0,1] +... \ No newline at end of file diff --git a/main.cpp b/main.cpp index e41ac3a..2760259 100644 --- a/main.cpp +++ b/main.cpp @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) { if(ok) { Grid grid(contentCells, backgroundCells, gridOptions, stateRewards, probIntended, faultyProbability); - grid.printToPrism(std::cout, configurations , gridOptions.getModelType()); + // grid.printToPrism(std::cout, configurations , gridOptions.getModelType()); std::stringstream ss; // grid.printToPrism(file, configurations ,prism::ModelType::MDP); grid.printToPrism(ss, configurations , gridOptions.getModelType()); diff --git a/util/ConfigYaml.cpp b/util/ConfigYaml.cpp index 7dc392c..57226d0 100644 --- a/util/ConfigYaml.cpp +++ b/util/ConfigYaml.cpp @@ -103,7 +103,12 @@ bool YAML::convert::decode(const YAML::Node& node, Command& rhs) { rhs.overwrite_ = node["overwrite"].as(); } if (node["index"]) { - rhs.index_ = node["index"].as(); + try { + rhs.index_ = node["index"].as>(); + } + catch(const std::exception& e) { + rhs.index_ = {node["index"].as()}; + } } return true; @@ -251,7 +256,7 @@ YamlConfigParseResult YamlConfigParser::parseConfiguration() { for (auto& constant : constants) { // std::cout << constant.constant_ << std::endl; configuration.push_back({constant.createExpression(), "const " + constant.type_ + " " + constant.constant_, ConfigType::Constant, constant.overwrite_}); - } + } } catch(const std::exception& e) { std::cout << "Exception '" << typeid(e).name() << "' caught:" << std::endl; diff --git a/util/ConfigYaml.h b/util/ConfigYaml.h index ccaa34c..bfdbc44 100644 --- a/util/ConfigYaml.h +++ b/util/ConfigYaml.h @@ -22,7 +22,7 @@ struct Configuration std::string module_ {}; std::string expression_{}; std::string identifier_{}; - int index_{}; + std::vector index_{0}; ConfigType type_ {ConfigType::Label}; bool overwrite_ {false}; @@ -33,7 +33,7 @@ struct Configuration , ConfigType type , bool overwrite = false , std::string module = "" - , int index = 0) : expression_(expression), identifier_(identifier), type_(type), overwrite_(overwrite), module_{module}, index_(index) {} + , std::vector index = {0}) : expression_(expression), identifier_(identifier), type_(type), overwrite_(overwrite), module_{module}, index_(index) {} ~Configuration() = default; Configuration(const Configuration&) = default; @@ -100,7 +100,7 @@ struct Command { std::string action_; std::string guard_; std::string update_; - int index_{0}; + std::vector index_{0}; bool overwrite_ {false}; std::string createExpression() const; diff --git a/util/Grid.cpp b/util/Grid.cpp index 294ddd1..ac22546 100644 --- a/util/Grid.cpp +++ b/util/Grid.cpp @@ -104,29 +104,30 @@ void Grid::applyOverwrites(std::string& str, std::vector& configu if (!config.overwrite_) { continue; } - size_t start_pos; - - if (config.type_ == ConfigType::Formula) { - start_pos = str.find("formula " + config.identifier_); - } else if (config.type_ == ConfigType::Label) { - start_pos = str.find("label " + config.identifier_); - } else if (config.type_ == ConfigType::Module) { - auto iter = boost::find_nth(str, config.identifier_, config.index_); + for (auto& index : config.index_) { + size_t start_pos; + std::string search; + + if (config.type_ == ConfigType::Formula) { + search = "formula " + config.identifier_; + } else if (config.type_ == ConfigType::Label) { + search = "label " + config.identifier_; + } else if (config.type_ == ConfigType::Module) { + search = config.identifier_; + } + else if (config.type_ == ConfigType::Constant) { + search = config.identifier_; + } + + auto iter = boost::find_nth(str, search, index); start_pos = std::distance(str.begin(), iter.begin()); - } - else if (config.type_ == ConfigType::Constant) { - start_pos = str.find(config.identifier_); + size_t end_pos = str.find(';', start_pos) + 1; - if (start_pos == std::string::npos) { - std::cout << "Couldn't find overwrite:" << config.expression_ << std::endl; + if (end_pos != std::string::npos && end_pos != 0) { + std::string expression = config.expression_; + str.replace(start_pos, end_pos - start_pos , expression); } } - - size_t end_pos = str.find(';', start_pos) + 1; - - std::string expression = config.expression_; - - str.replace(start_pos, end_pos - start_pos , expression); } } void Grid::printToPrism(std::ostream& os, std::vector& configuration ,const prism::ModelType& modelType) { -- 2.20.1 From 4141e9f1040df21de6752f957a71bdbb5fbc9c3a Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Thu, 11 Jan 2024 22:01:56 +0100 Subject: [PATCH 7/8] fixed config print of labels --- util/PrismModulesPrinter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/PrismModulesPrinter.cpp b/util/PrismModulesPrinter.cpp index 9912f79..4d63f98 100644 --- a/util/PrismModulesPrinter.cpp +++ b/util/PrismModulesPrinter.cpp @@ -78,6 +78,10 @@ namespace prism { } } + if (!configuration.empty()) { + printConfiguration(configuration); + } + return os; } -- 2.20.1 From acd1a17082bc35fc2a6c744413e2b03dfe4dc38b Mon Sep 17 00:00:00 2001 From: Thomas Knoll Date: Thu, 11 Jan 2024 22:05:55 +0100 Subject: [PATCH 8/8] renamed index --- util/ConfigYaml.cpp | 6 +++--- util/ConfigYaml.h | 6 +++--- util/Grid.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/util/ConfigYaml.cpp b/util/ConfigYaml.cpp index 57226d0..ecb5337 100644 --- a/util/ConfigYaml.cpp +++ b/util/ConfigYaml.cpp @@ -104,10 +104,10 @@ bool YAML::convert::decode(const YAML::Node& node, Command& rhs) { } if (node["index"]) { try { - rhs.index_ = node["index"].as>(); + rhs.indexes_ = node["index"].as>(); } catch(const std::exception& e) { - rhs.index_ = {node["index"].as()}; + rhs.indexes_ = {node["index"].as()}; } } @@ -250,7 +250,7 @@ YamlConfigParseResult YamlConfigParser::parseConfiguration() { } for (auto& module : modules) { for (auto& command : module.commands_) { - configuration.push_back({command.createExpression(), command.action_, ConfigType::Module, command.overwrite_, module.module_, command.index_}); + configuration.push_back({command.createExpression(), command.action_, ConfigType::Module, command.overwrite_, module.module_, command.indexes_}); } } for (auto& constant : constants) { diff --git a/util/ConfigYaml.h b/util/ConfigYaml.h index bfdbc44..16b34b6 100644 --- a/util/ConfigYaml.h +++ b/util/ConfigYaml.h @@ -22,7 +22,7 @@ struct Configuration std::string module_ {}; std::string expression_{}; std::string identifier_{}; - std::vector index_{0}; + std::vector indexes_{0}; ConfigType type_ {ConfigType::Label}; bool overwrite_ {false}; @@ -33,7 +33,7 @@ struct Configuration , ConfigType type , bool overwrite = false , std::string module = "" - , std::vector index = {0}) : expression_(expression), identifier_(identifier), type_(type), overwrite_(overwrite), module_{module}, index_(index) {} + , std::vector indexes = {0}) : expression_(expression), identifier_(identifier), type_(type), overwrite_(overwrite), module_{module}, indexes_(indexes) {} ~Configuration() = default; Configuration(const Configuration&) = default; @@ -100,7 +100,7 @@ struct Command { std::string action_; std::string guard_; std::string update_; - std::vector index_{0}; + std::vector indexes_{0}; bool overwrite_ {false}; std::string createExpression() const; diff --git a/util/Grid.cpp b/util/Grid.cpp index ac22546..6f057cc 100644 --- a/util/Grid.cpp +++ b/util/Grid.cpp @@ -104,7 +104,7 @@ void Grid::applyOverwrites(std::string& str, std::vector& configu if (!config.overwrite_) { continue; } - for (auto& index : config.index_) { + for (auto& index : config.indexes_) { size_t start_pos; std::string search; -- 2.20.1