MRPT
2.0.4
|
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 {0} |
size_t | coins7 {0} |
size_t | coins8 {0} |
size_t | coins19 {0} |
|
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 {0} |
Definition at line 38 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins2 {0} |
Definition at line 35 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins7 {0} |
Definition at line 36 of file vision_stereo_rectify/test.cpp.
size_t CCoinDistribution::coins8 {0} |
Definition at line 37 of file vision_stereo_rectify/test.cpp.
Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020 |