##// END OF EJS Templates
Implements move operations (2)...
Alexandre Leroux -
r1185:4e9317891e93
parent child
Show More
@@ -83,6 +83,30 struct MoveOperation : public IFuzzingOperation {
83 void execute(std::shared_ptr<Variable> &variable, VariableController &variableController,
83 void execute(std::shared_ptr<Variable> &variable, VariableController &variableController,
84 const Properties &properties) const override
84 const Properties &properties) const override
85 {
85 {
86 // Gets the max range defined
87 auto maxRange = properties.value(MAX_RANGE_PROPERTY, QVariant::fromValue(INVALID_RANGE))
88 .value<SqpRange>();
89 auto variableRange = variable->range();
90
91 if (maxRange == INVALID_RANGE || variableRange.m_TStart < maxRange.m_TStart
92 || variableRange.m_TEnd > maxRange.m_TEnd) {
93 qCWarning(LOG_FuzzingOperations()) << "Can't execute operation: invalid max range";
94 return;
95 }
96
97 // Computes the max delta at which the variable can move, up to the limits of the max range
98 auto deltaMax = m_MaxMoveFun(variable->range(), maxRange);
99
100 // Generates random delta that will be used to move variable
101 auto delta = RandomGenerator::instance().generateDouble(0, deltaMax);
102
103 // Moves variable to its new range
104 auto newVariableRange = SqpRange{m_RangeStartMoveFun(variableRange.m_TStart, delta),
105 m_RangeEndMoveFun(variableRange.m_TEnd, delta)};
106 qCInfo(LOG_FuzzingOperations())
107 << "Performing" << m_Label << "on" << variable->name() << "(from" << variableRange
108 << "to" << newVariableRange << ")...";
109 variableController.onRequestDataLoading({variable}, newVariableRange, false);
86 }
110 }
87
111
88 MoveFunction m_RangeStartMoveFun;
112 MoveFunction m_RangeStartMoveFun;
General Comments 0
You need to be logged in to leave comments. Login now