WSF
WsfMobilityAndFirepowerLethality.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing 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 WSFMOBILITYANDFIREPOWERLETHALITY_HPP
13#define WSFMOBILITYANDFIREPOWERLETHALITY_HPP
14
15#include "wsf_mil_export.h"
16
17#include <memory>
18#include <vector>
19
20#include "UtCallbackHolder.hpp"
21#include "WsfEvent.hpp"
23#include "WsfNamed.hpp"
24
27/*
28From Ref, Chapter 3.1 - "Kills Come in Four Flavors". Military simulations sometimes represent
29four different types of kills often found in real-world combat. The first flavor is a mobility
30kill in which the target is no longer able to move, but remains alive enough to fire its weapon
31or communicate with other vehicles. The second is a firepower kill in which the weapon is
32damaged and cannot be fired, but the vehicle or person is still able to move and communicate.
33The third is a mobility and firepower kill in which the vehicle or person is still alive, and may
34observe, communicate, consume supplies, and may motivate a rescue mission, but cannot move or use
35its weapon. The final kill type is the catastrophic kill, essentially eliminating the platform.
36
37Here, the lethality type is configurable by target type, and furthermore, each target type (or
38his friends) may deploy countermeasures in the hopes of reducing or completely defeating the
39incoming weapon. All Weapon-Target lethality pairing Tables are kept in shared memory, to be
40consulted during the flyout to determine the particular lethality values applicable to this
41engagement. Consult user documentation for configuration instructions. Note that unlike most
42engagements, this one will consume CPU periodically during the engagement to do timeline and
43geometry updates, as the countermeasure effect is permitted to accumulate, gaining effectiveness
44(decreasing the weapon lethality over time).
45
46Synopsis: 1. A fired Weapon Platform has a Lethality (this). 2. The Lethality is against a
47threat target type. 3. The threat target type _may_ have a specific defined lethality to be
48used during the engagement, but if one is not specified, a default lethality is selected anyway.
494. Once a lethality is chosen for this engagement, there _may_ be mitigating countermeasures
50types that are effective at reducing the previously expected lethality, but only after some
51time, geometry, or proximity requirements are satisfied.
52
53SPECIAL CAVEAT: Model has been developed to be more easily exportable, to provide a notional
54effect in an unclassified environment. No sensor/signature or EM/EP techniques are modeled.
55It is assumed here that <for example> the mere existence of FLARE platform(s) near the target
56that satisfy constraints is sufficient to have a desired decoy effect.
57
58ALSO NOTE: The "vulnerability" tests are CPU expensive, and will not be made unless needed.
59*/
60
62{
63public:
72
77
78 WsfWeaponEffects* Clone() const override;
79 bool Initialize(double aSimTime, const WsfWeaponEngagement* aEngagementPtr) override;
80 bool ProcessInput(UtInput& aInput) override;
81 void CalcInterceptPk(double aSimTime, WsfPlatform* aTargetPtr) override;
82 // Callback signatures:
83 void Update(double aSimTime);
84 void WeaponFired(double aSimTime, const WsfWeaponEngagement* aEngagementPtr, const WsfTrack* aTrackPtr);
85 void PlatformDeleted(double aSimTime, WsfPlatform* aPlatformPtr);
86
87 std::string KillTypeName(KillType aType) const;
88 std::string MyFullName() const;
89 double UpdateInterval() const { return mUpdateInterval; }
90
91protected:
92 static const double cSLIGHT_DAMAGE;
93 static const double cMODERATE_DAMAGE;
94
95 class UpdateEvent : public WsfEvent
96 {
97 public:
98 UpdateEvent(double aSimTime, WsfMobilityAndFirepowerLethality* aLethalityPtr);
99 EventDisposition Execute() override;
100
101 private:
102 size_t mPlatIndex;
104 };
105
106 // MFK_Tables are shared by all instances of this class,
107 // and an individual instance of this lethality will reference
108 // the table type by nameId only.
109 class MFK_Table : public WsfNamed
110 {
111 public:
112 MFK_Table(WsfStringId aTypeNameId);
113 static bool LoadInstance(UtInput& aInput, MFK_Table*& aTablePtr);
114 bool ProcessInput(UtInput& aInput);
115 bool Initialize(double aSimTime, WsfMobilityAndFirepowerLethality* aLethality);
116 KillType KillTypeGivenUniformDraw(double aUniformDrawValue, double aPkFactor = 1.0) const;
117 double PdGivenProximity() const { return mPdGivenProximity; }
118 double P_MK_GivenDamage() const { return mP_MK_GivenDamage; }
119 double P_FK_GivenDamage() const { return mP_FK_GivenDamage; }
120 double P_KK_GivenDamage() const { return mP_KK_GivenDamage; }
121
122 private:
123 bool mIsInitialized;
124 double mPdGivenProximity;
125 double mP_MK_GivenDamage;
126 double mP_FK_GivenDamage;
127 double mP_KK_GivenDamage;
128 };
129
130 // Vulnerabilities are selected from a list, based FIRST upon the target type engaged
131 // by this weapon, and SECOND, upon countermeasures types found in proximity to the
132 // target of interest. If countermeasures of the right type are present either close
133 // enough, or within a tight enough half-cone of the target view, AND are present for
134 // a long enough duration to be effective, then they will "re-route" the default
135 // MFK_Table to one of lower probability (mAlternateTablePtr) of effectiveness.
136 // (To prevent confusion, we should not use GetName(), GetNameId() on this class,
137 // but GetCM_TypeId() instead.)
138 class Vulnerability : public WsfNamed // Name is CM _TYPE_ !!!
139 {
140 public:
147
148 Vulnerability(WsfStringId aCM_TypeNameId);
149 static bool LoadInstance(UtInput& aInput, Vulnerability*& aCM_EffectPtr);
150 bool ProcessInput(UtInput& aInput);
151 bool Initialize(double aSimTime, WsfMobilityAndFirepowerLethality* aLethality);
152 DistValue GetDistEnum() const { return mDistValue; }
153 double GetMinDuration() const { return mMinimumDuration; }
154 double GetMaxHalfCone() const { return mMaximumHalfCone; }
155 double GetMaxDist() const { return mMaximumDistance; }
156 double GetMinDist() const { return mMinimumDistance; }
157 double GetPkFactor() const { return mPkFactor; }
158 double GetProbabilityOfDefeat() const { return mProbWpnDefeat; }
159 WsfStringId GetCM_TypeId() const { return GetNameId(); } // syntactical convenience
160 const MFK_Table* GetAlternateTablePtr() const { return mAlternateTablePtr; }
161
162 private:
163 bool mIsInitialized;
164 WsfStringId mAlternateTableId; // Table or PkFactor are mutually exclusive.
165 const MFK_Table* mAlternateTablePtr; // Table or PkFactor are mutually exclusive.
166 double mPkFactor; // Table or PkFactor are mutually exclusive.
167 double mProbWpnDefeat; // Probability this CM defeats a weapon intercept.
168 double mMinimumDuration;
169 double mMaximumHalfCone;
170 double mMinimumDistance;
171 double mMaximumDistance;
172 DistValue mDistValue;
173 };
174
175 // (To prevent confusion, we should not use GetName(), GetNameId() on this class,
176 // but GetTargetTypeId() instead.)
177 class TargetType : public WsfNamed
178 {
179 public:
180 static bool LoadInstance(UtInput& aInput, TargetType*& aTargetTypePtr);
181
182 TargetType(WsfStringId aTypeNameId);
183
184 bool ProcessInput(UtInput& aInput);
185
186 bool Initialize(double aSimTime, WsfMobilityAndFirepowerLethality* aLethality);
187
188 bool Add(const Vulnerability& aCM_Effect);
189
190 bool FindVulnerabilityTo(WsfStringId aCM_TypeId, Vulnerability*& aVulnerabilityPtr);
191
192 // bool FindCM_Type(WsfStringId aCM_TypeId,
193 // Vulnerability*& aVulnerabilityPtr);
194 size_t CM_EffectCount() { return mVulnerabilities.size(); }
195 Vulnerability* CM_EffectEntry(size_t aIndex) { return &mVulnerabilities[aIndex]; }
196
197 // KillType KillTypeGivenUniformDraw(double aUniformDrawValue);
198 MFK_Table* GetTable() { return mCMsNotUsedTablePtr; }
199
200 WsfStringId GetTargetTypeId() const { return GetNameId(); } // syntactical convenience
201
202 bool ContainsVulnerabilities() const { return !mVulnerabilities.empty(); }
203
204 private:
205 bool mIsInitialized;
206 WsfStringId mCMsNotUsedTableNameId;
207 MFK_Table* mCMsNotUsedTablePtr;
208 std::vector<Vulnerability> mVulnerabilities;
209 };
210
211 class CM_State;
212 using CM_StatePtrCollection = std::vector<CM_State*>;
213
215 {
216 public:
217 CM_State(double aSimTime,
218 WsfStringId aCM_TypeId,
219 WsfPlatform* aCM_PlatPtr,
220 WsfPlatform* aMissilePtr,
221 WsfPlatform* aTargetPtr,
222 const Vulnerability* aEffectPtr,
223 WsfSimulation* aSimulationPtr);
224
225 // Return - true = Detonate;
226 bool Update(double aSimTime);
227 void Null();
228 size_t PlatIndex() const { return mCM_Index; }
229 WsfStringId CM_TypeId() const { return mCM_TypeId; }
230 WsfPlatform* CM_Ptr() { return mCM_Ptr; }
231 WsfPlatform* TgtPtr() { return mTargetPtr; }
232 bool IsEffective() const { return mIsEffective; }
233 const Vulnerability* GetVulnerability() const { return mEffectPtr; }
234
235 private:
236 // Return - true = Munition should Detonate.
237 bool Finalize();
238
239 size_t mCM_Index;
240 WsfStringId mCM_TypeId;
241 WsfPlatform* mCM_Ptr;
242 WsfPlatform* mTargetPtr;
243 WsfPlatform* mMissilePtr;
244 const Vulnerability* mEffectPtr;
245 WsfSimulation* mSimulationPtr;
246 bool mIsEffective;
247 bool mIsFinalized;
248 double mCumEffectiveTime;
249 double mLastUpdate;
250 // CM_StatePtrCollection mOtherStatePtrs;
251 };
252
253 bool FindTargetType(WsfStringId aTargetTypeId, TargetType*& aTargetTypePtr);
254
255 // bool FindVulnerabilityTo(WsfStringId aCM_TypeId,
256 // Vulnerability*& aVulnerabilityPtr);
257
258 void AddInitialCM_States(double aSimTime);
259
260 bool AddCM_State(double aSimTime,
261 WsfStringId aCM_TypeId,
262 WsfPlatform* aCM_PlatPtr,
263 WsfPlatform* aMissilePtr,
264 WsfPlatform* aTargetPtr,
265 Vulnerability* aEffectPtr);
266
267 void GetTableAndScalarFor(WsfPlatform* aTargetPtr, const MFK_Table*& aTablePtr, double& aPkFactor);
268
269 void Detonate(double aSimTime);
270
271 using TableCollection = std::vector<MFK_Table>;
272 using TargetTypeCollection = std::vector<TargetType>;
273
274 bool Add(const MFK_Table& aTable);
275 bool Add(const TargetType& aTargetType);
276
277 bool IsTypeMatch(const std::vector<WsfStringId>& aPlatTypes, WsfStringId aCM_Type);
278
279 MFK_Table* GetTable(WsfStringId aTableNameId);
280 TargetType* GetTargetType(WsfStringId aTargetTypeId);
281
282 void ApplyEffectTo(double aSimTime, WsfPlatform* aOtherPlatformPtr) override;
283
284private:
285 // void AddCM_State_P(CM_State* aCM_StatePtr);
286
287 // ==== Class attributes: ====
288 std::shared_ptr<TableCollection> mSharedMFK_TablesPtr;
289 std::shared_ptr<TargetTypeCollection> mSharedTargetTypesPtr; // This a a listing of target types which I have a
290 // lethality effect upon
291
292 double mUpdateInterval;
293 TargetType* mTargetTypeInUsePtr;
294 CM_StatePtrCollection mCM_StatePtrs; // Unlike other _shared_ pointers, this is truly memory "owned" by 'this'.
295 UtCallbackHolder mCallbacks;
296};
297
298#endif
aObjectPtr Update(simTime)
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfEvent()=default
EventDisposition
Definition WsfEvent.hpp:37
void CalcInterceptPk(double aSimTime, WsfPlatform *aTargetPtr) override
Definition WsfExplicitWeaponEffects.cpp:90
bool ProcessInput(UtInput &aInput) override
Definition WsfExplicitWeaponEffects.cpp:65
WsfExplicitWeaponEffects(WsfScenario &aScenario)
Definition WsfExplicitWeaponEffects.cpp:29
WsfWeaponEffects * Clone() const override
Definition WsfExplicitWeaponEffects.cpp:39
void Null()
Definition WsfMobilityAndFirepowerLethality.cpp:1327
WsfPlatform * CM_Ptr()
Definition WsfMobilityAndFirepowerLethality.hpp:230
size_t PlatIndex() const
Definition WsfMobilityAndFirepowerLethality.hpp:228
WsfStringId CM_TypeId() const
Definition WsfMobilityAndFirepowerLethality.hpp:229
const Vulnerability * GetVulnerability() const
Definition WsfMobilityAndFirepowerLethality.hpp:233
WsfPlatform * TgtPtr()
Definition WsfMobilityAndFirepowerLethality.hpp:231
CM_State(double aSimTime, WsfStringId aCM_TypeId, WsfPlatform *aCM_PlatPtr, WsfPlatform *aMissilePtr, WsfPlatform *aTargetPtr, const Vulnerability *aEffectPtr, WsfSimulation *aSimulationPtr)
Definition WsfMobilityAndFirepowerLethality.cpp:1192
bool IsEffective() const
Definition WsfMobilityAndFirepowerLethality.hpp:232
Definition WsfMobilityAndFirepowerLethality.hpp:110
double PdGivenProximity() const
Definition WsfMobilityAndFirepowerLethality.hpp:117
KillType KillTypeGivenUniformDraw(double aUniformDrawValue, double aPkFactor=1.0) const
Definition WsfMobilityAndFirepowerLethality.cpp:853
MFK_Table(WsfStringId aTypeNameId)
Definition WsfMobilityAndFirepowerLethality.cpp:788
bool Initialize(double aSimTime, WsfMobilityAndFirepowerLethality *aLethality)
Definition WsfMobilityAndFirepowerLethality.cpp:799
bool ProcessInput(UtInput &aInput)
Definition WsfMobilityAndFirepowerLethality.cpp:817
double P_FK_GivenDamage() const
Definition WsfMobilityAndFirepowerLethality.hpp:119
double P_KK_GivenDamage() const
Definition WsfMobilityAndFirepowerLethality.hpp:120
double P_MK_GivenDamage() const
Definition WsfMobilityAndFirepowerLethality.hpp:118
static bool LoadInstance(UtInput &aInput, MFK_Table *&aTablePtr)
Definition WsfMobilityAndFirepowerLethality.cpp:762
Definition WsfMobilityAndFirepowerLethality.hpp:178
TargetType(WsfStringId aTypeNameId)
Definition WsfMobilityAndFirepowerLethality.cpp:1084
static bool LoadInstance(UtInput &aInput, TargetType *&aTargetTypePtr)
Definition WsfMobilityAndFirepowerLethality.cpp:1058
MFK_Table * GetTable()
Definition WsfMobilityAndFirepowerLethality.hpp:198
bool Add(const Vulnerability &aCM_Effect)
Definition WsfMobilityAndFirepowerLethality.cpp:1126
bool ProcessInput(UtInput &aInput)
Definition WsfMobilityAndFirepowerLethality.cpp:1158
Vulnerability * CM_EffectEntry(size_t aIndex)
Definition WsfMobilityAndFirepowerLethality.hpp:195
WsfStringId GetTargetTypeId() const
Definition WsfMobilityAndFirepowerLethality.hpp:200
bool FindVulnerabilityTo(WsfStringId aCM_TypeId, Vulnerability *&aVulnerabilityPtr)
Definition WsfMobilityAndFirepowerLethality.cpp:1140
bool Initialize(double aSimTime, WsfMobilityAndFirepowerLethality *aLethality)
Definition WsfMobilityAndFirepowerLethality.cpp:1094
size_t CM_EffectCount()
Definition WsfMobilityAndFirepowerLethality.hpp:194
bool ContainsVulnerabilities() const
Definition WsfMobilityAndFirepowerLethality.hpp:202
UpdateEvent(double aSimTime, WsfMobilityAndFirepowerLethality *aLethalityPtr)
Definition WsfMobilityAndFirepowerLethality.cpp:1336
EventDisposition Execute() override
Definition WsfMobilityAndFirepowerLethality.cpp:1345
Definition WsfMobilityAndFirepowerLethality.hpp:139
double GetProbabilityOfDefeat() const
Definition WsfMobilityAndFirepowerLethality.hpp:158
double GetMaxHalfCone() const
Definition WsfMobilityAndFirepowerLethality.hpp:154
Vulnerability(WsfStringId aCM_TypeNameId)
Definition WsfMobilityAndFirepowerLethality.cpp:922
double GetMaxDist() const
Definition WsfMobilityAndFirepowerLethality.hpp:155
WsfStringId GetCM_TypeId() const
Definition WsfMobilityAndFirepowerLethality.hpp:159
double GetPkFactor() const
Definition WsfMobilityAndFirepowerLethality.hpp:157
double GetMinDist() const
Definition WsfMobilityAndFirepowerLethality.hpp:156
const MFK_Table * GetAlternateTablePtr() const
Definition WsfMobilityAndFirepowerLethality.hpp:160
DistValue GetDistEnum() const
Definition WsfMobilityAndFirepowerLethality.hpp:152
double GetMinDuration() const
Definition WsfMobilityAndFirepowerLethality.hpp:153
DistValue
Definition WsfMobilityAndFirepowerLethality.hpp:142
@ cMSL_TO_CM
Definition WsfMobilityAndFirepowerLethality.hpp:145
@ cMSL_TO_TGT
Definition WsfMobilityAndFirepowerLethality.hpp:143
@ cCM_TO_TGT
Definition WsfMobilityAndFirepowerLethality.hpp:144
Definition WsfMobilityAndFirepowerLethality.hpp:62
TargetType * GetTargetType(WsfStringId aTargetTypeId)
Definition WsfMobilityAndFirepowerLethality.cpp:448
void PlatformDeleted(double aSimTime, WsfPlatform *aPlatformPtr)
Definition WsfMobilityAndFirepowerLethality.cpp:548
WsfMobilityAndFirepowerLethality(WsfScenario &aScenario)
Default constructor.
Definition WsfMobilityAndFirepowerLethality.cpp:55
WsfMobilityAndFirepowerLethality & operator=(const WsfMobilityAndFirepowerLethality &)=delete
bool IsTypeMatch(const std::vector< WsfStringId > &aPlatTypes, WsfStringId aCM_Type)
Definition WsfMobilityAndFirepowerLethality.cpp:264
bool ProcessInput(UtInput &aInput) override
Definition WsfMobilityAndFirepowerLethality.cpp:347
bool Add(const MFK_Table &aTable)
Definition WsfMobilityAndFirepowerLethality.cpp:398
std::string MyFullName() const
Definition WsfMobilityAndFirepowerLethality.cpp:106
std::vector< MFK_Table > TableCollection
Definition WsfMobilityAndFirepowerLethality.hpp:271
void WeaponFired(double aSimTime, const WsfWeaponEngagement *aEngagementPtr, const WsfTrack *aTrackPtr)
Definition WsfMobilityAndFirepowerLethality.cpp:510
bool Initialize(double aSimTime, const WsfWeaponEngagement *aEngagementPtr) override
Definition WsfMobilityAndFirepowerLethality.cpp:119
static const double cSLIGHT_DAMAGE
Definition WsfMobilityAndFirepowerLethality.hpp:92
std::vector< TargetType > TargetTypeCollection
Definition WsfMobilityAndFirepowerLethality.hpp:272
MFK_Table * GetTable(WsfStringId aTableNameId)
Definition WsfMobilityAndFirepowerLethality.cpp:470
static const double cMODERATE_DAMAGE
Definition WsfMobilityAndFirepowerLethality.hpp:93
double UpdateInterval() const
Definition WsfMobilityAndFirepowerLethality.hpp:89
KillType
Definition WsfMobilityAndFirepowerLethality.hpp:65
@ cNO_KILL
Definition WsfMobilityAndFirepowerLethality.hpp:66
@ cMOBILITY
Definition WsfMobilityAndFirepowerLethality.hpp:68
@ cCATASTROPHIC_KILL
Definition WsfMobilityAndFirepowerLethality.hpp:70
@ cFIREPOWER
Definition WsfMobilityAndFirepowerLethality.hpp:67
@ cFIREPOWER_AND_MOBILITY
Definition WsfMobilityAndFirepowerLethality.hpp:69
std::vector< CM_State * > CM_StatePtrCollection
Definition WsfMobilityAndFirepowerLethality.hpp:212
std::string KillTypeName(KillType aType) const
Definition WsfMobilityAndFirepowerLethality.cpp:326
WsfStringId GetNameId() const
Definition WsfNamed.hpp:36
WsfNamed()
Definition WsfNamed.cpp:17
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
The main controller for a simulation.
Definition WsfSimulation.hpp:109
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
virtual void ApplyEffectTo(double aSimTime, WsfPlatform *aOtherPlatformPtr)
Definition WsfWeaponEffects.cpp:549
virtual bool Initialize(double aSimTime, const WsfWeaponEngagement *aEngagementPtr)
Definition WsfWeaponEffects.cpp:150
WsfWeaponEffects(WsfScenario &aScenario)
Definition WsfWeaponEffects.cpp:51
Definition WsfWeaponEngagement.hpp:43
Copyrights Multiple, All Rights Reserved