diff --git a/include/core/state_block/has_state_blocks.h b/include/core/state_block/has_state_blocks.h index 0f7d13f99c2af92d8779c11a7e705bb4ef94f99f..ef55d163be4764393c4e1b08ac0003ae67b1d223 100644 --- a/include/core/state_block/has_state_blocks.h +++ b/include/core/state_block/has_state_blocks.h @@ -68,6 +68,10 @@ class HasStateBlocks unsigned int getSize() const; unsigned int getLocalSize() const; + // Perturb state + void perturb(double amplitude = 0.01); + + private: std::string structure_; std::unordered_map<std::string, StateBlockPtr> state_block_map_; @@ -251,6 +255,5 @@ inline unsigned int HasStateBlocks::getLocalSize() const return size; } - } // namespace wolf #endif /* STATE_BLOCK_HAS_STATE_BLOCKS_H_ */ diff --git a/src/state_block/has_state_blocks.cpp b/src/state_block/has_state_blocks.cpp index 8b11f1cb3981206700b4ce54ad5529df54ae6d29..83cf44b26bdfcad7e415633ef6d8fe783564a75c 100644 --- a/src/state_block/has_state_blocks.cpp +++ b/src/state_block/has_state_blocks.cpp @@ -44,5 +44,14 @@ void HasStateBlocks::removeStateBlocks(ProblemPtr _problem) } } +void HasStateBlocks::perturb(double amplitude) +{ + for (const auto& pair_key_sb : state_block_map_) + { + auto& sb = pair_key_sb.second; + if (!sb->isFixed()) + sb->perturb(amplitude); + } +} }