##// END OF EJS Templates
Adds the ability to force an acquisition pending for an operation (1)...
Alexandre Leroux -
r1249:b9a47ff1b9cc
parent child
Show More
@@ -53,7 +53,4 struct FuzzingOperationFactory {
53 static std::unique_ptr<IFuzzingOperation> create(FuzzingOperationType type);
53 static std::unique_ptr<IFuzzingOperation> create(FuzzingOperationType type);
54 };
54 };
55
55
56 using WeightedOperationsTypes = std::map<FuzzingOperationType, double>;
57 Q_DECLARE_METATYPE(WeightedOperationsTypes)
58
59 #endif // SCIQLOP_FUZZINGOPERATIONS_H
56 #endif // SCIQLOP_FUZZINGOPERATIONS_H
@@ -49,10 +49,17 using IntPair = std::pair<int, int>;
49 using Weight = double;
49 using Weight = double;
50 using Weights = std::vector<Weight>;
50 using Weights = std::vector<Weight>;
51
51
52 struct OperationProperty {
53 Weight m_Weight{1.};
54 bool m_WaitAcquisition{false};
55 };
56
52 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
57 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
53 using VariablesOperations = std::vector<VariableOperation>;
58 using VariablesOperations = std::vector<VariableOperation>;
54
59
55 using WeightedOperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, Weight>;
60 using OperationsTypes = std::map<FuzzingOperationType, OperationProperty>;
61 using OperationsPool = std::map<std::shared_ptr<IFuzzingOperation>, OperationProperty>;
62
56 using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >;
63 using Validators = std::vector<std::shared_ptr<IFuzzingValidator> >;
57
64
58 // ///////// //
65 // ///////// //
@@ -91,8 +98,8 const auto VALIDATION_FREQUENCY_BOUNDS_DEFAULT_VALUE = QVariant::fromValue(std::
91
98
92 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
99 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
93 /// pairs that are valid (i.e. operation that can be executed on variable)
100 /// pairs that are valid (i.e. operation that can be executed on variable)
94 std::pair<VariablesOperations, Weights>
101 std::pair<VariablesOperations, Weights> availableOperations(const FuzzingState &fuzzingState,
95 availableOperations(const FuzzingState &fuzzingState, const WeightedOperationsPool &operationsPool)
102 const OperationsPool &operationsPool)
96 {
103 {
97 VariablesOperations result{};
104 VariablesOperations result{};
98 Weights weights{};
105 Weights weights{};
@@ -102,12 +109,12 availableOperations(const FuzzingState &fuzzingState, const WeightedOperationsPo
102
109
103 for (const auto &operationsPoolEntry : operationsPool) {
110 for (const auto &operationsPoolEntry : operationsPool) {
104 auto operation = operationsPoolEntry.first;
111 auto operation = operationsPoolEntry.first;
105 auto weight = operationsPoolEntry.second;
112 auto operationProperty = operationsPoolEntry.second;
106
113
107 // A pair is valid if the current operation can be executed on the current variable
114 // A pair is valid if the current operation can be executed on the current variable
108 if (operation->canExecute(variableId, fuzzingState)) {
115 if (operation->canExecute(variableId, fuzzingState)) {
109 result.push_back({variableId, operation});
116 result.push_back({variableId, operation});
110 weights.push_back(weight);
117 weights.push_back(operationProperty.m_Weight);
111 }
118 }
112 }
119 }
113 }
120 }
@@ -115,9 +122,9 availableOperations(const FuzzingState &fuzzingState, const WeightedOperationsPo
115 return {result, weights};
122 return {result, weights};
116 }
123 }
117
124
118 WeightedOperationsPool createOperationsPool(const WeightedOperationsTypes &types)
125 OperationsPool createOperationsPool(const OperationsTypes &types)
119 {
126 {
120 WeightedOperationsPool result{};
127 OperationsPool result{};
121
128
122 std::transform(
129 std::transform(
123 types.cbegin(), types.cend(), std::inserter(result, result.end()), [](const auto &type) {
130 types.cbegin(), types.cend(), std::inserter(result, result.end()), [](const auto &type) {
@@ -252,12 +259,11 public:
252 }
259 }
253
260
254 private:
261 private:
255
262 OperationsPool operationsPool() const
256 WeightedOperationsPool operationsPool() const
257 {
263 {
258 static auto result = createOperationsPool(
264 static auto result = createOperationsPool(
259 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
265 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
260 .value<WeightedOperationsTypes>());
266 .value<OperationsTypes>());
261 return result;
267 return result;
262 }
268 }
263
269
@@ -283,6 +289,8 private:
283
289
284 } // namespace
290 } // namespace
285
291
292 Q_DECLARE_METATYPE(OperationsTypes)
293
286 class TestAmdaFuzzing : public QObject {
294 class TestAmdaFuzzing : public QObject {
287 Q_OBJECT
295 Q_OBJECT
288
296
General Comments 0
You need to be logged in to leave comments. Login now