WSF
WsfSA_GroupManager.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI//REL TO USA ONLY
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2020 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFSA_GROUPMANAGER_HPP
13#define WSFSA_GROUPMANAGER_HPP
14
15#include "wsf_air_combat_export.h"
16
18#include "WsfScenario.hpp"
19
21class WsfSA_Group;
22
23class WSF_AIR_COMBAT_EXPORT WsfSA_GroupManager
24{
25public:
26 virtual ~WsfSA_GroupManager() = default;
27
28 void InitializeData(WsfPlatform* aPlatform,
29 double aMaxGroupingDistanceCentroid,
30 double aMaxGroupingDistanceNeighbor,
31 double aMaxGroupingHeadingDifference,
32 double aMaxGroupingSpeedDifference,
33 double aMaxGroupingAngle,
34 double aMinGroupRadius,
35 bool aUseCentroidGrouping,
36 bool aUseNeighborGrouping,
37 bool aUseHeadingGrouping,
38 bool aUseSpeedGrouping,
39 bool aUseTypeGrouping);
40
41 void UpdateAndAssessGroups(double aSimtime,
42 const WsfPlatform* aPlatform,
43 std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups,
44 const std::vector<WsfSA_EntityPerception*>& aPerceivedBogies,
45 const std::vector<WsfSA_EntityPerception*>& aPerceivedBandits,
46 bool aIgnoreBogies);
47
49 {
50 SIMPLE_POSITIONAL = 0, //<! Simple, very simple positional clustering
51 SIMPLE_ANGULAR = 1, //<! Simple, very simple angular clustering
52 K_MEANS = 2, //<! K-Means, very simple clustering
53 HIERARCHICAL_TREE_AVERAGE = 3, //<! H-Tree average-linkage, cluster distance is mean location distance
54 HIERARCHICAL_TREE_COMPLETE = 4, //<! H-Tree complete-linkage, cluster distance is max between any two members (default)
55 HIERARCHICAL_TREE_SINGLE = 5 //<! H-Tree single-linkage, cluster distance is min between any two members
56 };
57
59 {
60 SCORE_2D = 0, //<! Clustered by horizontal/lateral distance apart
61 SCORE_3D = 1, //<! Clustered by slant distance apart (default)
62 SCORE_VEL = 2, //<! Clustered by heading
63 SCORE_ANG = 3 //<! Clustered by angle from viewing platform
64 };
65
72
73 void SetGroupingAlgorithms(GroupingAlgorithm aGroupingAlgorithm, ScoringAlgorithm aScoringAlgorithm);
74
78 std::string GenerateNewGroupName();
79
86 bool AttemptToJoinBestGroup(WsfSA_EntityPerception* aEntity, const std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups);
87
93 void FormDegenerateGroups(std::list<WsfSA_EntityPerception*>& aAvailableList,
94 std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups);
95
101 void FormDegenerateGroup(WsfSA_EntityPerception* aEntity, std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups);
102
103private:
104 void PositionalAlgorithm(double aSimtime,
105 const WsfPlatform* aPlatform,
106 std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups,
107 const std::vector<WsfSA_EntityPerception*>& aPerceivedBogies,
108 const std::vector<WsfSA_EntityPerception*>& aPerceivedBandits,
109 bool aIgnoreBogies);
110
111 void FormAvailableList(const std::vector<WsfSA_EntityPerception*>& aPerceivedBogies,
112 const std::vector<WsfSA_EntityPerception*>& aPerceivedBandits,
113 std::list<WsfSA_EntityPerception*>& aAvailableList,
114 bool aIgnoreBogies);
115
116 // Returns true if groups is still viable, false if group should be removed
117 bool VerifyGroupEntitiesAreValid(WsfSA_Group* aGroup,
118 std::list<WsfSA_EntityPerception*>& aAvailableList,
119 bool aTestForAvailable);
120
121 // Returns true if the entity would be a valid member of the specified group
122 bool VerifyEntityIsValidForGroup(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup);
123
124 // Returns true if the entity is able to join the specified group
125 bool VerifyEntityIsValidForJoiningGroup(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup);
126
127 void AttemptToFormGroup(WsfSA_EntityPerception* aEntity,
128 std::list<WsfSA_EntityPerception*>& aConsiderationList,
129 std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups);
130
131 void UpdateGroupEntityData(std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups,
132 const std::list<WsfSA_EntityPerception*>& aAvailableList);
133
134 // This returns false if the entity is not in the availableList
135 static bool EntityDataAvailable(WsfSA_EntityPerception* aEntity,
136 const std::list<WsfSA_EntityPerception*>& aAvailableList);
137
138 void UpdateCurrentGroups(const std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups);
139
140 void RemoveOldGroups(std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups, double aSimtime);
141
142 void MergeGroups(std::list<WsfSA_Group*>& aCurrentlyPerceivedGroups);
143
144 bool EntityIsInList(const WsfSA_EntityPerception* aEntity, const std::list<WsfSA_EntityPerception*>& aAvailableList) const;
145
146 bool EntityIsInList(const WsfSA_EntityPerception* aEntity, const std::list<WsfSA_EntityPerception>& aAvailableList) const;
147
148 void RemoveEntityFromList(const WsfSA_EntityPerception* aEntity, std::list<WsfSA_EntityPerception*>& aAvailableList);
149
150 bool ItemMayBeAddedToGroup(const WsfSA_EntityPerception* aEntity) const;
151
152 // Returns true if the entity is contained in mInSomeGroup map
153 bool EntityHasBeenAddedToSomeGroup(const WsfSA_EntityPerception* aEntity) const;
154
155 // Returns true if the entity is contained in the asset group of the specified platform's SA Processor
156 bool EntityIsInAssetGroup(const WsfSA_EntityPerception* aEntity, const WsfPlatform* aPlatform) const;
157
158 // Returns true if the entity meets top-level qualifiers for being in a group:
159 // It will be invalid (and return false) if any of the following are true:
160 // 1) Entity has the same platform index as the mPlatform of the group manager
161 // 2) Entity is in the assets group of the mPlatform of the group manager
162 // 3) Entity identification is FRIENDLY
163 // 4) Entity identification is NEUTRAL
164 // 5) Entity is an angle-only track (this may change in the future)
165 bool MeetsTopLevelValidityGroupQualifiers(const WsfSA_EntityPerception* aEntity) const;
166
167 // Returns true if there is only a single entity in the element list of the group and it is has
168 // identification of FRIENDLY or NEUTRAL.
169 bool IsLastItemFriendlyOrNeutral(const WsfSA_Group* aGroup) const;
170
171 // Returns VALID if the entity is close enough to the centroid of the group.
172 // If centroid grouping is not being used, it returns INCONCLUSIVE.
173 // Else, return INVALID.
174 GroupingValidity CloseEnoughToCentroid(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup) const;
175
176 // Returns VALID if the entity is close enough to any neighbor in the group.
177 // If neighbor grouping is not being used or there are no neighbors, it returns INCONCLUSIVE.
178 // Else, return INVALID.
179 GroupingValidity CloseEnoughToNeighbor(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup) const;
180
181 // Returns VALID if the entity is close enough to the overall heading of the group.
182 // If heading grouping is not being used or either the entity or group have invalid headings, it returns
183 // INCONCLUSIVE. Else, return INVALID.
184 GroupingValidity CloseEnoughToHeading(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup) const;
185
186 // Returns VALID if the entity is close enough to the overall speed of the group.
187 // If heading grouping is not being used or either the entity or group have invalid speeds, it returns INCONCLUSIVE.
188 // Else, return INVALID.
189 GroupingValidity CloseEnoughToSpeed(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup) const;
190
191 // Returns VALID if the entity is the same type as the entities in the group.
192 // If heading grouping is not being used or there are no other entities, it returns INCONCLUSIVE.
193 // Else, return INVALID.
194 GroupingValidity MatchesType(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup) const;
195
196 // Returns true if aEntity is close enough in all relevant parameters to those of the group to remain in it, else false.
197 bool CloseEnoughToStay(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup);
198
199 // Returns true if aEntity is close enough in all relevant parameters to those of the group to join it, else false.
200 bool CloseEnoughToJoin(const WsfSA_EntityPerception* aEntity, const WsfSA_Group* aGroup);
201
202 const WsfPlatform* mPlatform = nullptr;
203 GroupingAlgorithm mGroupingAlgorithm = SIMPLE_POSITIONAL;
204 ScoringAlgorithm mScoringAlgorithm = SCORE_2D;
205 double mMaxGroupingDistanceCentroid = 8.0 * UtMath::cM_PER_NM; // Meters - Default is 8 nm
206 double mMaxGroupingDistanceNeighbor = 4.0 * UtMath::cM_PER_NM; // Meters - Default is 4 nm
207 double mMaxGroupingHeadingDifference = 10.0 * UtMath::cRAD_PER_DEG; // Radians
208 double mMaxGroupingSpeedDifference = 100.0; // Knots
209 double mMinGroupRadius_nm = 1.0; // Meters - Default minimum radius is 1 nm
210
211 bool mUseCentroidGrouping = true; // Utilize centroid distance grouping constraints
212 bool mUseNeighborGrouping = true; // Utilize neighbor distance grouping constraints
213 bool mUseHeadingGrouping = true; // Utilize heading grouping constraints
214 bool mUseSpeedGrouping = true; // Utilize speed grouping constraints
215 bool mUseTypeGrouping = false; // Utilize type grouping constraints
216
217 int mGroupNumber = 0; // Used to auto-gen group names
218
219 double mLastSimtime = 0.0; // Seconds
220};
221
222#endif
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Definition WsfSA_EntityPerception.hpp:37
Definition WsfSA_GroupManager.hpp:24
GroupingValidity
Definition WsfSA_GroupManager.hpp:67
@ INCONCLUSIVE
Definition WsfSA_GroupManager.hpp:70
@ INVALID
Definition WsfSA_GroupManager.hpp:69
@ VALID
Definition WsfSA_GroupManager.hpp:68
virtual ~WsfSA_GroupManager()=default
void UpdateAndAssessGroups(double aSimtime, const WsfPlatform *aPlatform, std::list< WsfSA_Group * > &aCurrentlyPerceivedGroups, const std::vector< WsfSA_EntityPerception * > &aPerceivedBogies, const std::vector< WsfSA_EntityPerception * > &aPerceivedBandits, bool aIgnoreBogies)
Definition WsfSA_GroupManager.cpp:44
GroupingAlgorithm
Definition WsfSA_GroupManager.hpp:49
@ HIERARCHICAL_TREE_SINGLE
Definition WsfSA_GroupManager.hpp:55
@ K_MEANS
Definition WsfSA_GroupManager.hpp:52
@ HIERARCHICAL_TREE_AVERAGE
Definition WsfSA_GroupManager.hpp:53
@ HIERARCHICAL_TREE_COMPLETE
Definition WsfSA_GroupManager.hpp:54
@ SIMPLE_ANGULAR
Definition WsfSA_GroupManager.hpp:51
@ SIMPLE_POSITIONAL
Definition WsfSA_GroupManager.hpp:50
void InitializeData(WsfPlatform *aPlatform, double aMaxGroupingDistanceCentroid, double aMaxGroupingDistanceNeighbor, double aMaxGroupingHeadingDifference, double aMaxGroupingSpeedDifference, double aMaxGroupingAngle, double aMinGroupRadius, bool aUseCentroidGrouping, bool aUseNeighborGrouping, bool aUseHeadingGrouping, bool aUseSpeedGrouping, bool aUseTypeGrouping)
Definition WsfSA_GroupManager.cpp:18
ScoringAlgorithm
Definition WsfSA_GroupManager.hpp:59
@ SCORE_VEL
Definition WsfSA_GroupManager.hpp:62
@ SCORE_ANG
Definition WsfSA_GroupManager.hpp:63
@ SCORE_3D
Definition WsfSA_GroupManager.hpp:61
@ SCORE_2D
Definition WsfSA_GroupManager.hpp:60
Definition WsfSA_Group.hpp:24
Copyrights Multiple, All Rights Reserved