diff --git a/src/adapters/ExplicitModelAdapter.cpp b/src/adapters/ExplicitModelAdapter.cpp index be8a24e3e..03a274567 100644 --- a/src/adapters/ExplicitModelAdapter.cpp +++ b/src/adapters/ExplicitModelAdapter.cpp @@ -131,20 +131,18 @@ ExplicitModelAdapter::~ExplicitModelAdapter() { this->booleanVariables.resize(numberOfBooleanVariables); this->integerVariables.resize(numberOfIntegerVariables); - uint_fast64_t nextBooleanVariableIndex = 0; - uint_fast64_t nextIntegerVariableIndex = 0; for (uint_fast64_t i = 0; i < program.getNumberOfModules(); ++i) { storm::ir::Module const& module = program.getModule(i); for (uint_fast64_t j = 0; j < module.getNumberOfBooleanVariables(); ++j) { - this->booleanVariables[nextBooleanVariableIndex] = module.getBooleanVariable(j); - this->booleanVariableToIndexMap[module.getBooleanVariable(j).getName()] = nextBooleanVariableIndex; - ++nextBooleanVariableIndex; + storm::ir::BooleanVariable var = module.getBooleanVariable(j); + this->booleanVariables[var.getIndex()] = var; + this->booleanVariableToIndexMap[var.getName()] = var.getIndex(); } for (uint_fast64_t j = 0; j < module.getNumberOfIntegerVariables(); ++j) { - this->integerVariables[nextIntegerVariableIndex] = module.getIntegerVariable(j); - this->integerVariableToIndexMap[module.getIntegerVariable(j).getName()] = nextIntegerVariableIndex; - ++nextIntegerVariableIndex; + storm::ir::IntegerVariable var = module.getIntegerVariable(j); + this->integerVariables[var.getIndex()] = var; + this->integerVariableToIndexMap[var.getName()] = var.getIndex(); } } } diff --git a/src/ir/BooleanVariable.cpp b/src/ir/BooleanVariable.cpp index f233100cd..2c03e1c44 100644 --- a/src/ir/BooleanVariable.cpp +++ b/src/ir/BooleanVariable.cpp @@ -26,7 +26,7 @@ BooleanVariable::BooleanVariable(uint_fast64_t index, std::string variableName, } BooleanVariable::BooleanVariable(const BooleanVariable& var, const std::string& newName, const std::map& renaming, const std::map& bools, const std::map& ints) - : Variable(var, newName, renaming, bools, ints) { + : Variable(var, newName, bools.at(newName), renaming, bools, ints) { } // Build a string representation of the variable. diff --git a/src/ir/IntegerVariable.cpp b/src/ir/IntegerVariable.cpp index 0e6e2a4fe..a8926b046 100644 --- a/src/ir/IntegerVariable.cpp +++ b/src/ir/IntegerVariable.cpp @@ -23,13 +23,14 @@ IntegerVariable::IntegerVariable() : lowerBound(), upperBound() { // Initializes all members according to the given values. IntegerVariable::IntegerVariable(uint_fast64_t index, std::string variableName, std::shared_ptr lowerBound, std::shared_ptr upperBound, std::shared_ptr initialValue) : Variable(index, variableName, initialValue), lowerBound(lowerBound), upperBound(upperBound) { + // TODO: This behaves like prism... if (this->getInitialValue() == nullptr) { this->setInitialValue(lowerBound); } } IntegerVariable::IntegerVariable(const IntegerVariable& var, const std::string& newName, const std::map& renaming, const std::map& bools, const std::map& ints) - : Variable(var, newName, renaming, bools, ints), lowerBound(var.lowerBound->clone(renaming, bools, ints)), upperBound(var.upperBound->clone(renaming, bools, ints)) { + : Variable(var, newName, ints.at(newName), renaming, bools, ints), lowerBound(var.lowerBound->clone(renaming, bools, ints)), upperBound(var.upperBound->clone(renaming, bools, ints)) { } // Return lower bound for variable. diff --git a/src/ir/Variable.cpp b/src/ir/Variable.cpp index 082011655..421603f4f 100644 --- a/src/ir/Variable.cpp +++ b/src/ir/Variable.cpp @@ -25,8 +25,8 @@ Variable::Variable(uint_fast64_t index, std::string variableName, std::shared_pt // Nothing to do here. } -Variable::Variable(const Variable& var, const std::string& newName, const std::map& renaming, const std::map& bools, const std::map& ints) { - this->index = var.index; +Variable::Variable(const Variable& var, const std::string& newName, const uint_fast64_t newIndex, const std::map& renaming, const std::map& bools, const std::map& ints) { + this->index = newIndex; this->variableName = newName; if (var.initialValue != nullptr) { this->initialValue = var.initialValue->clone(renaming, bools, ints); diff --git a/src/ir/Variable.h b/src/ir/Variable.h index e144d06aa..610ef903a 100644 --- a/src/ir/Variable.h +++ b/src/ir/Variable.h @@ -40,7 +40,7 @@ public: * @param var Variable to copy. * @param newName New name of this variable. */ - Variable(const Variable& var, const std::string& newName, const std::map& renaming, const std::map& bools, const std::map& ints); + Variable(const Variable& var, const std::string& newName, const uint_fast64_t newIndex, const std::map& renaming, const std::map& bools, const std::map& ints); /*! * Retrieves the name of the variable.