KiCad PCB EDA Suite
|
Helper class that collects solutions and keeps one with the best deviation. More...
Public Member Functions | |
SolutionCollector (double aTarget) | |
void | Add2RLookupResults (std::pair< RESISTANCE &, RESISTANCE & > aResults, std::function< double(double)> aValueFunc, std::function< RESISTANCE(RESISTANCE &)> aResultFunc) |
Add two solutions, based on single 2R buffer lookup, to the collector. | |
RESISTANCE | GetBest () |
Return the best collected combination. | |
Private Member Functions | |
void | considerSolution (double aValue, RESISTANCE &aFound, std::function< RESISTANCE(RESISTANCE &)> &aResultFunc) |
Static Private Member Functions | |
static int | uniqueCount (const RESISTANCE &aRes) |
static bool | betterCandidate (const RESISTANCE &aCand, const RESISTANCE &aBest) |
Private Attributes | |
double | m_target |
double | m_best_deviation = INFINITY |
std::optional< RESISTANCE > | m_best_solution |
Helper class that collects solutions and keeps one with the best deviation.
In order to avoid performing costly string operations too frequently, they are postponed until the very end, when we know the best combination.
Definition at line 46 of file resistor_substitution_utils.cpp.
|
inline |
Definition at line 54 of file resistor_substitution_utils.cpp.
|
inline |
Add two solutions, based on single 2R buffer lookup, to the collector.
aResults | are the resistances found in 2R buffer |
aValueFunc | transforms value from aResults into final value of the combination |
aResultFunc | transforms RESISTANCE instance from aResults into final instance |
Definition at line 66 of file resistor_substitution_utils.cpp.
References considerSolution().
Referenced by RES_EQUIV_CALC::calculate2RSolution(), RES_EQUIV_CALC::calculate3RSolution(), and RES_EQUIV_CALC::calculate4RSolution().
|
inlinestaticprivate |
Definition at line 125 of file resistor_substitution_utils.cpp.
References RESISTANCE::name, RESISTANCE::parts, and uniqueCount().
Referenced by considerSolution().
|
inlineprivate |
Definition at line 85 of file resistor_substitution_utils.cpp.
References std::abs(), betterCandidate(), epsilon, m_best_deviation, m_best_solution, and m_target.
Referenced by Add2RLookupResults().
|
inline |
Return the best collected combination.
Definition at line 76 of file resistor_substitution_utils.cpp.
References m_best_solution.
Referenced by RES_EQUIV_CALC::calculate2RSolution(), RES_EQUIV_CALC::calculate3RSolution(), and RES_EQUIV_CALC::calculate4RSolution().
|
inlinestaticprivate |
Definition at line 103 of file resistor_substitution_utils.cpp.
References std::abs(), epsilon, and RESISTANCE::parts.
Referenced by betterCandidate().
|
private |
Definition at line 140 of file resistor_substitution_utils.cpp.
Referenced by considerSolution().
|
private |
Definition at line 141 of file resistor_substitution_utils.cpp.
Referenced by considerSolution(), and GetBest().
|
private |
Definition at line 139 of file resistor_substitution_utils.cpp.
Referenced by considerSolution().