##// 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 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 56 #endif // SCIQLOP_FUZZINGOPERATIONS_H
@@ -49,10 +49,17 using IntPair = std::pair<int, int>;
49 49 using Weight = double;
50 50 using Weights = std::vector<Weight>;
51 51
52 struct OperationProperty {
53 Weight m_Weight{1.};
54 bool m_WaitAcquisition{false};
55 };
56
52 57 using VariableOperation = std::pair<VariableId, std::shared_ptr<IFuzzingOperation> >;
53 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 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 99 /// Goes through the variables pool and operations pool to determine the set of {variable/operation}
93 100 /// pairs that are valid (i.e. operation that can be executed on variable)
94 std::pair<VariablesOperations, Weights>
95 availableOperations(const FuzzingState &fuzzingState, const WeightedOperationsPool &operationsPool)
101 std::pair<VariablesOperations, Weights> availableOperations(const FuzzingState &fuzzingState,
102 const OperationsPool &operationsPool)
96 103 {
97 104 VariablesOperations result{};
98 105 Weights weights{};
@@ -102,12 +109,12 availableOperations(const FuzzingState &fuzzingState, const WeightedOperationsPo
102 109
103 110 for (const auto &operationsPoolEntry : operationsPool) {
104 111 auto operation = operationsPoolEntry.first;
105 auto weight = operationsPoolEntry.second;
112 auto operationProperty = operationsPoolEntry.second;
106 113
107 114 // A pair is valid if the current operation can be executed on the current variable
108 115 if (operation->canExecute(variableId, fuzzingState)) {
109 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 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 129 std::transform(
123 130 types.cbegin(), types.cend(), std::inserter(result, result.end()), [](const auto &type) {
@@ -252,12 +259,11 public:
252 259 }
253 260
254 261 private:
255
256 WeightedOperationsPool operationsPool() const
262 OperationsPool operationsPool() const
257 263 {
258 264 static auto result = createOperationsPool(
259 265 m_Properties.value(AVAILABLE_OPERATIONS_PROPERTY, AVAILABLE_OPERATIONS_DEFAULT_VALUE)
260 .value<WeightedOperationsTypes>());
266 .value<OperationsTypes>());
261 267 return result;
262 268 }
263 269
@@ -283,6 +289,8 private:
283 289
284 290 } // namespace
285 291
292 Q_DECLARE_METATYPE(OperationsTypes)
293
286 294 class TestAmdaFuzzing : public QObject {
287 295 Q_OBJECT
288 296
General Comments 0
You need to be logged in to leave comments. Login now