@@ -81,7 +81,8 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync | |||||
81 | return; |
|
81 | return; | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 |
// Unregisters variable from sync group: if there is no more variable in the group, resets the |
|
84 | // Unregisters variable from sync group: if there is no more variable in the group, resets the | |
|
85 | // range | |||
85 | auto &syncGroup = m_SyncGroupsPool.at(syncGroupId); |
|
86 | auto &syncGroup = m_SyncGroupsPool.at(syncGroupId); | |
86 | syncGroup.m_Variables.erase(variableId); |
|
87 | syncGroup.m_Variables.erase(variableId); | |
87 | if (syncGroup.m_Variables.empty()) { |
|
88 | if (syncGroup.m_Variables.empty()) { | |
@@ -89,3 +90,18 void FuzzingState::desynchronizeVariable(VariableId variableId, SyncGroupId sync | |||||
89 | } |
|
90 | } | |
90 | } |
|
91 | } | |
91 |
|
92 | |||
|
93 | void FuzzingState::updateRanges(VariableId variableId, const SqpRange &newRange) | |||
|
94 | { | |||
|
95 | auto syncGroupId = this->syncGroupId(variableId); | |||
|
96 | ||||
|
97 | // Retrieves the variables to update: | |||
|
98 | // - if the variable is synchronized to others, updates all synchronized variables | |||
|
99 | // - otherwise, updates only the variable | |||
|
100 | auto variablesToUpdate = syncGroupId.isNull() ? std::set<VariableId>{variableId} | |||
|
101 | : m_SyncGroupsPool.at(syncGroupId).m_Variables; | |||
|
102 | ||||
|
103 | // Sets new range | |||
|
104 | for (const auto &variableId : variablesToUpdate) { | |||
|
105 | m_VariablesPool.at(variableId).m_Range = newRange; | |||
|
106 | } | |||
|
107 | } |
@@ -110,6 +110,10 struct FuzzingState { | |||||
110 | /// @param syncGroupId the synchronization group from which to remove the variable |
|
110 | /// @param syncGroupId the synchronization group from which to remove the variable | |
111 | void desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId); |
|
111 | void desynchronizeVariable(VariableId variableId, SyncGroupId syncGroupId); | |
112 |
|
112 | |||
|
113 | /// Updates the range of a variable and all variables to which it is synchronized | |||
|
114 | /// @param the variable for which to affect the range | |||
|
115 | /// @param the range to affect | |||
|
116 | void updateRanges(VariableId variableId, const SqpRange &newRange); | |||
113 |
|
117 | |||
114 | VariablesPool m_VariablesPool; |
|
118 | VariablesPool m_VariablesPool; | |
115 | SyncGroupsPool m_SyncGroupsPool; |
|
119 | SyncGroupsPool m_SyncGroupsPool; |
@@ -136,15 +136,16 struct MoveOperation : public IFuzzingOperation { | |||||
136 | auto delta = RandomGenerator::instance().generateDouble(0, deltaMax); |
|
136 | auto delta = RandomGenerator::instance().generateDouble(0, deltaMax); | |
137 |
|
137 | |||
138 | // Moves variable to its new range |
|
138 | // Moves variable to its new range | |
|
139 | auto isSynchronized = !fuzzingState.syncGroupId(variableId).isNull(); | |||
139 | auto newVariableRange = SqpRange{m_RangeStartMoveFun(variableRange.m_TStart, delta), |
|
140 | auto newVariableRange = SqpRange{m_RangeStartMoveFun(variableRange.m_TStart, delta), | |
140 | m_RangeEndMoveFun(variableRange.m_TEnd, delta)}; |
|
141 | m_RangeEndMoveFun(variableRange.m_TEnd, delta)}; | |
141 | qCInfo(LOG_FuzzingOperations()).noquote() |
|
142 | qCInfo(LOG_FuzzingOperations()).noquote() | |
142 | << "Performing" << m_Label << "on" << variable->name() << "(from" << variableRange |
|
143 | << "Performing" << m_Label << "on" << variable->name() << "(from" << variableRange | |
143 | << "to" << newVariableRange << ")..."; |
|
144 | << "to" << newVariableRange << ")..."; | |
144 |
variableController.onRequestDataLoading({variable}, newVariableRange, |
|
145 | variableController.onRequestDataLoading({variable}, newVariableRange, isSynchronized); | |
145 |
|
146 | |||
146 |
// Updates |
|
147 | // Updates state | |
147 |
|
|
148 | fuzzingState.updateRanges(variableId, newVariableRange); | |
148 | } |
|
149 | } | |
149 |
|
150 | |||
150 | MoveFunction m_RangeStartMoveFun; |
|
151 | MoveFunction m_RangeStartMoveFun; |
General Comments 0
You need to be logged in to leave comments.
Login now