WSF
WsfCoverageCoverageTime.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 WSFCOVERAGECOVERAGETIME_HPP
13#define WSFCOVERAGECOVERAGETIME_HPP
14
15#include "wsf_coverage_export.h"
16
17#include <map>
18#include <vector>
19
21#include "WsfCoverageAsset.hpp"
23
24namespace wsf
25{
26namespace coverage
27{
28
30class WSF_COVERAGE_EXPORT CoverageTime : public Measure
31{
32public:
33 explicit CoverageTime(const WsfScenario& aScenario)
34 : Measure{aScenario}
35 {
37 }
38 CoverageTime(const CoverageTime& aOther) = default;
39 ~CoverageTime() override = default;
40
41 // Measure overrides
42 CoverageTime* Clone() const override { return new CoverageTime{*this}; }
43
44 double GetDefaultValue() const override;
45
46 bool ProcessInput(UtInput& aInput) override;
47
48 double GetMeasuredValue(const GridAsset& aGridAsset) const override;
49
50 void CollectionStarting(Coverage& aCoverage, double aSimTime) override;
51
52 std::string GetValueHeader() const override;
53
54 constexpr static const char* cTYPE{"WSF_COVERAGE_TIME_MOE"};
55
57 enum class SubType
58 {
59 cUNKNOWN,
60 cTOTAL,
61 cPERCENT,
62 cTOTAL_TIME_ABOVE,
63 cPERCENT_TIME_ABOVE,
64 cMAX_PER_TIME,
65 cMAX_PERCENT_PER_TIME,
66 cMIN_PER_TIME,
67 cMIN_PERCENT_PER_TIME,
68 cMEAN_PER_TIME,
69 cMEAN_PERCENT_PER_TIME,
70 cSTD_DEV_PER_TIME,
71 cSTD_DEV_PERCENT_PER_TIME
72 };
73
75 SubType GetSubType() const { return mSubType; }
76
78 double GetSampleSpan() const { return mSampleSpan; }
79
83 double GetParameter() const { return mParameter; }
84
85private:
86 enum class ParamType
87 {
88 cPER_TIME,
89 cPER_TIME_LIMITED,
90 cTIME_AFTER,
91 cNONE
92 };
93
94 // GridData contains all data required for calculating the value for a single GridAsset.
95 struct GridData
96 {
97 // We need to know, for two of the sub-types, how much coverage time happened when there
98 // is coverage from at least 'n' free assets, where 'n' is a positive integer.
99 // free asset 1: #######
100 // free asset 2: #######
101 // free asset 3: #######
102 // free asset 4: #######
103 // Suppose the '#' in the above graph represent access intervals. There are 4 assets with intervals that have some
104 // overlap. layer 4 : layer 3 : # # layer 2 : ########## layer 1 : ################ What
105 // we have done here is 'collapsed' them such that each layer has the total acces intervals with at least that
106 // many accesses. This way, in order to know the total/percent time above a certain number of accesses, we can
107 // just find the total time of the respective layer. There can be multiple days represented per layer.
108 // mIntervals[layer][sample][interval]
109 std::vector<std::vector<std::vector<AccessInterval>>> mIntervals;
110
111 // mData is the calculated value.
112 double mData{};
113 };
114
115 bool InitializeP(Coverage& aCoverage) override;
116
117 void CollectionCompletingP(Coverage& aCoverage, double aSimTime) override;
118
119 double ComputeValue(std::vector<std::vector<AccessInterval>>& aIntervals) const;
120
121 double ComputeTotal(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
122
123 double ComputePercent(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
124
125 double ComputeMaxPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
126
127 double ComputeMaxPercentPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
128
129 double ComputeMinPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
130
131 double ComputeMinPercentPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
132
133 double ComputeMeanPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
134
135 double ComputeMeanPercentPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
136
137 double ComputeStdDevPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
138
139 double ComputeStdDevPercentPerTime(const std::vector<std::vector<AccessInterval>>& aIntervals) const;
140
141 double GetMidnightForSample(int aSample) const;
142
143 void OnAccessIntervalComplete(const GridAsset& aGridAsset, const FreeAsset& aFreeAsset, const AccessInterval& aInterval);
144
145 void Collapse(const GridAsset& aGridAsset, const AccessInterval& aInterval, int aLevel);
146
147 static SubType GetSubtypeFromIdentifier(const std::string& aIdentifier);
148
149 static ParamType SubtypeHasParameter(SubType aSubType);
150
151 // The coverage intervals.
152 std::map<GridAsset, GridData> mData{};
153
154 // The dUTC calendar date and time when mCoverageInterval starts.
155 UtCalendar mStartEpoch{};
156
157 // The coverage interval.
158 AccessInterval mCoverageInterval{};
159
160 // The selected sub-type.
161 SubType mSubType{SubType::cUNKNOWN};
162
163 // The duration of samples for per-time subtypes.
164 double mSampleSpan{UtCalendar::cSEC_IN_DAY};
165
166 // The parameter value for those sub-types needing one.
167 int mParameter{1};
168};
169
170} // namespace coverage
171} // namespace wsf
172
173#endif // WSFCOVERAGECOVERAGETIME_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
double GetParameter() const
Definition WsfCoverageCoverageTime.hpp:83
static constexpr const char * cTYPE
Definition WsfCoverageCoverageTime.hpp:54
double GetSampleSpan() const
Get the duration of samples for per-time subtypes.
Definition WsfCoverageCoverageTime.hpp:78
CoverageTime * Clone() const override
Definition WsfCoverageCoverageTime.hpp:42
~CoverageTime() override=default
CoverageTime(const CoverageTime &aOther)=default
SubType GetSubType() const
Get the sub-type enumeration that describes this CoverageTime instance.
Definition WsfCoverageCoverageTime.hpp:75
CoverageTime(const WsfScenario &aScenario)
Definition WsfCoverageCoverageTime.hpp:33
SubType
The available sub-types for this MOE.
Definition WsfCoverageCoverageTime.hpp:58
Definition WsfCoverage.hpp:57
Definition WsfCoverageAsset.hpp:37
Measure(const WsfScenario &aScenario)
Definition WsfCoverageMeasure.hpp:45
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