mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Stick to constraint parsing convention and refactor fuzzer harness.
This commit is contained in:
@@ -33,7 +33,7 @@ string ConstraintGenerator::generate()
|
||||
constraint += to_string(zeroOrOne());
|
||||
for (int j = 0; j < numFactors(); j++)
|
||||
if (bernoulliDist(s_piecewiseConstantProb))
|
||||
constraint += "," + to_string(randomMinusOneToOne());
|
||||
constraint += ",0";
|
||||
else
|
||||
constraint += "," + to_string(randomInteger());
|
||||
constraint += "\n";
|
||||
|
||||
@@ -90,7 +90,7 @@ struct ConstraintGenerator
|
||||
/// Largest value of a factor in linear constraint
|
||||
static constexpr int s_maxFactor = 100;
|
||||
/// Probability that a factor in the range of [-1, 1] is chosen
|
||||
static constexpr double s_piecewiseConstantProb = 0.25;
|
||||
static constexpr double s_piecewiseConstantProb = 0.75;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -32,11 +32,7 @@ LinearExpression FuzzerSolverInterface::linearExpression(vector<int> _factors)
|
||||
LinearExpression lexp;
|
||||
lexp.resize(_factors.size());
|
||||
for (auto&& [index, value]: _factors | ranges::views::enumerate)
|
||||
// Move constant term to RHS.
|
||||
if (index == 0)
|
||||
lexp[index] = -rational{value};
|
||||
else
|
||||
lexp[index] = rational{value};
|
||||
lexp[index] = rational{value};
|
||||
return lexp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user