|
|
@ -183,27 +183,27 @@ private: |
|
|
|
*/ |
|
|
|
void generateInitialStates() { |
|
|
|
// Create a fresh state which can hold as many boolean and integer variables as there are. |
|
|
|
std::vector<StateType*> states; |
|
|
|
states.emplace_back(); |
|
|
|
states.back()->first.resize(this->booleanVariables.size()); |
|
|
|
states.back()->second.resize(this->integerVariables.size()); |
|
|
|
this->allStates.clear(); |
|
|
|
this->allStates.push_back(new StateType()); |
|
|
|
this->allStates[0]->first.resize(this->booleanVariables.size()); |
|
|
|
this->allStates[0]->second.resize(this->integerVariables.size()); |
|
|
|
|
|
|
|
// Start with boolean variables. |
|
|
|
for (uint_fast64_t i = 0; i < this->booleanVariables.size(); ++i) { |
|
|
|
// Check if an initial value is given |
|
|
|
if (this->booleanVariables[i].getInitialValue().get() == nullptr) { |
|
|
|
// No initial value was given. |
|
|
|
uint_fast64_t size = states.size(); |
|
|
|
uint_fast64_t size = this->allStates.size(); |
|
|
|
for (uint_fast64_t pos = 0; pos < size; pos++) { |
|
|
|
// Duplicate each state, one with true and one with false. |
|
|
|
states.emplace_back(states[pos]); |
|
|
|
std::get<0>(*states[pos])[i] = false; |
|
|
|
std::get<0>(*states[size + pos])[i] = true; |
|
|
|
this->allStates.push_back(new StateType(*this->allStates[pos])); |
|
|
|
std::get<0>(*this->allStates[pos])[i] = false; |
|
|
|
std::get<0>(*this->allStates[size + pos])[i] = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
// Initial value was given. |
|
|
|
bool initialValue = this->booleanVariables[i].getInitialValue()->getValueAsBool(states[0]); |
|
|
|
for (auto it : states) { |
|
|
|
bool initialValue = this->booleanVariables[i].getInitialValue()->getValueAsBool(this->allStates[0]); |
|
|
|
for (auto it : this->allStates) { |
|
|
|
std::get<0>(*it)[i] = initialValue; |
|
|
|
} |
|
|
|
} |
|
|
@ -213,28 +213,27 @@ private: |
|
|
|
// Check if an initial value was given. |
|
|
|
if (this->integerVariables[i].getInitialValue().get() == nullptr) { |
|
|
|
// No initial value was given. |
|
|
|
uint_fast64_t size = states.size(); |
|
|
|
int_fast64_t lower = this->integerVariables[i].getLowerBound()->getValueAsInt(states[0]); |
|
|
|
int_fast64_t upper = this->integerVariables[i].getUpperBound()->getValueAsInt(states[0]); |
|
|
|
uint_fast64_t size = this->allStates.size(); |
|
|
|
int_fast64_t lower = this->integerVariables[i].getLowerBound()->getValueAsInt(this->allStates[0]); |
|
|
|
int_fast64_t upper = this->integerVariables[i].getUpperBound()->getValueAsInt(this->allStates[0]); |
|
|
|
|
|
|
|
// Duplicate all states for all values in variable interval. |
|
|
|
for (int_fast64_t value = lower; value <= upper; value++) { |
|
|
|
for (uint_fast64_t pos = 0; pos < size; pos++) { |
|
|
|
// If value is lower bound, we reuse the existing state, otherwise we create a new one. |
|
|
|
if (value > lower) states.emplace_back(states[pos]); |
|
|
|
if (value > lower) this->allStates.push_back(new StateType(*this->allStates[pos])); |
|
|
|
// Set value to current state. |
|
|
|
std::get<1>(*states[(value - lower) * size + pos])[i] = value; |
|
|
|
std::get<1>(*this->allStates[(value - lower) * size + pos])[i] = value; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// Initial value was given. |
|
|
|
int_fast64_t initialValue = this->integerVariables[i].getInitialValue()->getValueAsInt(states[0]); |
|
|
|
for (auto it : states) { |
|
|
|
int_fast64_t initialValue = this->integerVariables[i].getInitialValue()->getValueAsInt(this->allStates[0]); |
|
|
|
for (auto it : this->allStates) { |
|
|
|
std::get<1>(*it)[i] = initialValue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*! |
|
|
|
xxxxxxxxxx