Ocean
Loading...
Searching...
No Matches
TestAssignmentSolver.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
11
13
15
16namespace Ocean
17{
18
19namespace Test
20{
21
22namespace TestCV
23{
24
25namespace TestDetector
26{
27
28namespace TestBullseyes
29{
30
31/**
32 * This class implements tests for the AssignmentSolver class
33 * @ingroup testcvdetectorbullseyes
34 */
35class OCEAN_TEST_CV_DETECTOR_BULLSEYES_EXPORT TestAssignmentSolver : protected CV::Detector::Bullseyes::AssignmentSolver
36{
37 public:
38
39 /**
40 * Tests the AssignmentSolver functions.
41 * @param testDuration Number of seconds for each test, with range (0, infinity)
42 * @return True, if succeeded
43 */
44 static bool test(const double testDuration);
45
46 /**
47 * Test for AssignmentSolver::solve()
48 * @param testDuration The duration in seconds for which this test will be run, must be > 0.0
49 * @return True, if succeeded
50 */
51 static bool testSolve(const double testDuration);
52
53 protected:
54
55 /**
56 * Validates the result of solve() by checking:
57 * - All assignment pairs are within bounds
58 * - No duplicate row or column assignments
59 * - Number of assignments equals min(rows, columns)
60 * - All assigned costs are non-negative
61 * @param costMatrix The original cost matrix used for solving
62 * @param assignments The resulting assignments from solve()
63 * @return True if validation succeeds, False otherwise
64 */
65 static bool validateSolve(const CostMatrix& costMatrix, const Assignments& assignments);
66
67 /**
68 * Creates a random valid cost matrix with specified dimensions and cost range.
69 * All generated costs will be non-negative values within the specified range.
70 * @param randomGenerator A random generator to use for generating random values
71 * @param rows The number of rows in the cost matrix, must be > 0
72 * @param columns The number of columns in the cost matrix, must be > 0
73 * @param minimumCost The minimum cost value, must be >= 0
74 * @param maximumCost The maximum cost value, must be >= minimumCost
75 * @param costMatrix The resulting cost matrix, will be resized and filled with random values
76 * @return True if the cost matrix was created successfully, False otherwise
77 */
78 static bool createRandomValidCostMatrix(RandomGenerator& randomGenerator, const size_t rows, const size_t columns, const Scalar minimumCost, const Scalar maximumCost, CostMatrix& costMatrix);
79 };
80
81} // namespace TestBullseyes
82
83} // namespace TestDetector
84
85} // namespace TestCV
86
87} // namespace Test
88
89} // namespace Ocean
This class solves assignment problems using the Hungarian/Kuhn-Munkres algorithm.
Definition AssignmentSolver.h:50
IndexPairs32 Assignments
An alias for a vector of index pairs.
Definition AssignmentSolver.h:60
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
This class implements tests for the AssignmentSolver class.
Definition TestAssignmentSolver.h:36
static bool testSolve(const double testDuration)
Test for AssignmentSolver::solve()
static bool validateSolve(const CostMatrix &costMatrix, const Assignments &assignments)
Validates the result of solve() by checking:
static bool createRandomValidCostMatrix(RandomGenerator &randomGenerator, const size_t rows, const size_t columns, const Scalar minimumCost, const Scalar maximumCost, CostMatrix &costMatrix)
Creates a random valid cost matrix with specified dimensions and cost range.
static bool test(const double testDuration)
Tests the AssignmentSolver functions.
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15