Browse Source

Variables were counted in two places (VariableState and ExplicitAdapter).

Now, they got mixed up... this is fixed now.
main
gereon 12 years ago
parent
commit
b7a1e90579
  1. 14
      src/adapters/ExplicitModelAdapter.cpp
  2. 2
      src/ir/BooleanVariable.cpp
  3. 3
      src/ir/IntegerVariable.cpp
  4. 4
      src/ir/Variable.cpp
  5. 2
      src/ir/Variable.h

14
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();
}
}
}

2
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<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& ints)
: Variable(var, newName, renaming, bools, ints) {
: Variable(var, newName, bools.at(newName), renaming, bools, ints) {
}
// Build a string representation of the variable.

3
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<storm::ir::expressions::BaseExpression> lowerBound, std::shared_ptr<storm::ir::expressions::BaseExpression> upperBound, std::shared_ptr<storm::ir::expressions::BaseExpression> 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<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& 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.

4
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<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& ints) {
this->index = var.index;
Variable::Variable(const Variable& var, const std::string& newName, const uint_fast64_t newIndex, const std::map<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& ints) {
this->index = newIndex;
this->variableName = newName;
if (var.initialValue != nullptr) {
this->initialValue = var.initialValue->clone(renaming, bools, ints);

2
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<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& ints);
Variable(const Variable& var, const std::string& newName, const uint_fast64_t newIndex, const std::map<std::string, std::string>& renaming, const std::map<std::string,uint_fast64_t>& bools, const std::map<std::string,uint_fast64_t>& ints);
/*!
* Retrieves the name of the variable.

Loading…
Cancel
Save