This is a example of problem resolution using the CAStarAlgorithm template.
Although this problem is better solved with dynamic programming, it illustrates perfectly how to inherit from that template in order to solve a problem.
Let's assume a currency composed of coins whose values are 2, 7, 8 and 19. The problem consists of finding a minimal set of these coins whose total value equals a given amount.
Definition at line 32 of file vision_stereo_rectify/test.cpp.
Public Member Functions | |
CCoinDistribution () | |
size_t | money () const |
Auxiliary function to calculate the amount of money. More... | |
bool | operator== (const CCoinDistribution &mon) const |
Implementing the == operator is mandatory, because it allows the A* algorithm to reject repeated solutions. More... | |
Public Attributes | |
size_t | coins2 |
size_t | coins7 |
size_t | coins8 |
size_t | coins19 |
|
inline |
Definition at line 39 of file vision_stereo_rectify/test.cpp.
|
inline |
Auxiliary function to calculate the amount of money.
Not strictly necessary, but handy.
Definition at line 44 of file vision_stereo_rectify/test.cpp.
|
inline |
Implementing the == operator is mandatory, because it allows the A* algorithm to reject repeated solutions.
Actually, the template should not compile if this operator is not present.
Definition at line 54 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins19 |
Definition at line 38 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins2 |
Definition at line 35 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins7 |
Definition at line 36 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins8 |
Definition at line 37 of file vision_stereo_rectify/test.cpp.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST |