WSF
WsfCoverageN_AssetCoverage.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 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 WSFCOVERAGENASSETCOVERAGE_HPP
13#define WSFCOVERAGENASSETCOVERAGE_HPP
14
15#include "wsf_coverage_export.h"
16
17#include <map>
18#include <set>
19#include <vector>
20
22#include "WsfCoverageAsset.hpp"
24
25namespace wsf
26{
27namespace coverage
28{
29
31class WSF_COVERAGE_EXPORT N_AssetCoverage : public Measure
32{
33public:
34 explicit N_AssetCoverage(const WsfScenario& aScenario)
35 : Measure{aScenario}
36 {
38 }
39 N_AssetCoverage(const N_AssetCoverage& aOther) = default;
40 ~N_AssetCoverage() override = default;
41
42 // Measure overrides
43 N_AssetCoverage* Clone() const override { return new N_AssetCoverage{*this}; }
44 bool ProcessInput(UtInput& aInput) override;
45 double GetDefaultValue() const override;
46 double GetMeasuredValue(const GridAsset& aGridAsset) const override;
47 void CollectionStarting(Coverage& aCoverage, double aSimTime) override;
48 std::string GetValueHeader() const override;
49
50 constexpr static const char* cTYPE{"WSF_N_ASSET_COVERAGE_MOE"};
51
53 enum class SubType
54 {
55 cMEAN,
56 cMAX,
57 cMIN,
58 cPERCENT_ABOVE,
59 cUNIQUE,
60 cUNKNOWN
61 };
62
64 SubType GetSubType() const { return mSubType; }
65
67 double GetParameter() const { return mParameter * 100.0; }
68
69private:
70 struct GridData
71 {
72 // The set of all free assets that this grid point has accessed.
73 std::set<FreeAsset> mAssetCount;
74
75 // The ordered map of times at which the number of accesses increases or decreases.
76 // When iterated over, the number of accesses and the times between changes can be accumulated.
77 std::map<double, int> mCountFrames;
78
79 // The grid point's output.
80 double mData;
81 };
82 bool InitializeP(Coverage& aCoverage) override;
83 void CollectionCompletingP(Coverage& aCoverage, double aSimTime) override;
84 double ComputeValue(const GridData& aIntervals) const;
85 double ComputeMean(const std::map<double, int>& aFrames) const;
86 double ComputeMax(const std::map<double, int>& aFrames) const;
87 double ComputeMin(const std::map<double, int>& aFrames) const;
88 double ComputePercentAbove(const std::map<double, int>& aFrames) const;
89 double ComputeUnique(const std::set<FreeAsset>& aAssets) const;
90
91 void OnAccessIntervalComplete(const GridAsset& aGridAsset, const FreeAsset& aFreeAsset, const AccessInterval& aInterval);
92
93 static SubType GetSubtypeFromIdentifier(const std::string& aIdentifier);
94 static bool SubtypeHasParameter(SubType aSubType);
95
97 std::map<GridAsset, GridData> mData{};
98
100 AccessInterval mCoverageInterval{};
101
103 SubType mSubType{SubType::cUNKNOWN};
104
106 double mParameter{-1.0};
107};
108
109} // namespace coverage
110} // namespace wsf
111
112#endif // WSFCOVERAGEN_ASSET_COVERAGE_HPP
void SetType(WsfStringId aType)
Definition WsfObject.cpp:172
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfCoverage.hpp:57
Definition WsfCoverageAsset.hpp:37
Measure(const WsfScenario &aScenario)
Definition WsfCoverageMeasure.hpp:45
SubType
The available sub-types for this MOE.
Definition WsfCoverageN_AssetCoverage.hpp:54
~N_AssetCoverage() override=default
N_AssetCoverage(const N_AssetCoverage &aOther)=default
N_AssetCoverage * Clone() const override
Definition WsfCoverageN_AssetCoverage.hpp:43
N_AssetCoverage(const WsfScenario &aScenario)
Definition WsfCoverageN_AssetCoverage.hpp:34
double GetParameter() const
Returns the parameter passed to percent_above, or -100.0 if a different subtype was used.
Definition WsfCoverageN_AssetCoverage.hpp:67
static constexpr const char * cTYPE
Definition WsfCoverageN_AssetCoverage.hpp:50
SubType GetSubType() const
Returns the MoE's subtype.
Definition WsfCoverageN_AssetCoverage.hpp:64
Definition WsfCoverage.cpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved