WSF
WsfSixDOF_TunerGASpecimen.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 WSFSIXDOFTUNERGASPECIMEN_HPP
13#define WSFSIXDOFTUNERGASPECIMEN_HPP
14
15#include "wsf_six_dof_export.h"
16
17#include <vector>
18
19#include "UtRandom.hpp"
21
22namespace wsf
23{
24namespace six_dof
25{
26class WSF_SIX_DOF_EXPORT TunerGASpecimen
27{
28public:
34
35 TunerGASpecimen() = default;
36
37 void GenerateSpecimen();
38 double AssessObjective(std::vector<PidLogElement>& aSimData);
39 double GetObjectiveValue() const { return mObjectiveValue; }
40 void GenerateChromosome();
41 std::string GetChromosome() const { return mChromosome; }
42 void Mutate(double aMutationProbability);
43 void CrossOver(const TunerGASpecimen& aSpecimen);
44
45 // Set weight factor for error portion of objective calculation
46 void SetErrorWeight(double aErrorWeight) { mErrorWeight = aErrorWeight; }
47 double GetErrorWeight() const { return mErrorWeight; }
48
49 // Set weight factor for overshoot portion of objective calculation
50 void SetOvershootWeight(double aOvershootWeight) { mOvershootWeight = aOvershootWeight; }
51 double GetOvershootWeight() const { return mOvershootWeight; }
52
53 // Sets the Kp range
54 void SetKpRange(double aLowerBound, double aUpperBound);
55
56 // Sets the Ki range
57 void SetKiRange(double aLowerBound, double aUpperBound);
58
59 // Sets the Kd range
60 void SetKdRange(double aLowerBound, double aUpperBound);
61
62 // Sets the pointer to the RNG
63 void SetRandomPtr(ut::Random* aRandom);
64
65 // Returns PID Kp
66 double GetKp() const { return std::pow(10.0, mLogKp); }
67
68 // Returns PID Ki
69 double GetKi() const { return std::pow(10.0, mLogKi); }
70
71 // Returns PID Kd
72 double GetKd() const { return std::pow(10.0, mLogKd); }
73
74 // Returns PID low-pass alpha
75 double GetLowPassAlpha() const { return mLowPassAlpha; }
76
77private:
78 void DetermineChromosomeLengths();
79 std::string IntToBinString(size_t aInt, size_t aLength);
80 unsigned int BinStringToInt(const std::string& aBinString);
81 void UpdateBasedOnChromosome();
82
83 double mObjectiveValue = -1.0;
84 double mLogKp = 0.0;
85 double mLogKi = 0.0;
86 double mLogKd = 0.0;
87 double mLowPassAlpha = 0.0;
88 double mLogKpRange[2]{-9.0, 2.0};
89 double mLogKiRange[2]{-9.0, 2.0};
90 double mLogKdRange[2]{-9.0, 2.0};
91 double mLowPassAlphaRange[2] = {0.0, 1.0};
92 std::string mChromosome;
93 size_t mChromosomeLengths[4]{0, 0, 0, 0};
94
95 double mErrorWeight = 1.0;
96 double mOvershootWeight = 1.0;
97 ut::Random* mRandomPtr = nullptr;
98};
99} // namespace six_dof
100} // namespace wsf
101
102#endif
Definition WsfSixDOF_TunerGASpecimen.hpp:27
double GetKd() const
Definition WsfSixDOF_TunerGASpecimen.hpp:72
double GetErrorWeight() const
Definition WsfSixDOF_TunerGASpecimen.hpp:47
double GetObjectiveValue() const
Definition WsfSixDOF_TunerGASpecimen.hpp:39
double GetKp() const
Definition WsfSixDOF_TunerGASpecimen.hpp:66
void SetOvershootWeight(double aOvershootWeight)
Definition WsfSixDOF_TunerGASpecimen.hpp:50
double GetKi() const
Definition WsfSixDOF_TunerGASpecimen.hpp:69
std::string GetChromosome() const
Definition WsfSixDOF_TunerGASpecimen.hpp:41
void SetErrorWeight(double aErrorWeight)
Definition WsfSixDOF_TunerGASpecimen.hpp:46
double GetLowPassAlpha() const
Definition WsfSixDOF_TunerGASpecimen.hpp:75
double GetOvershootWeight() const
Definition WsfSixDOF_TunerGASpecimen.hpp:51
double AssessObjective(std::vector< PidLogElement > &aSimData)
Definition WsfSixDOF_TunerGASpecimen.cpp:66
void GenerateSpecimen()
Definition WsfSixDOF_TunerGASpecimen.cpp:20
Definition WsfSA_Processor.hpp:35
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Definition WsfSixDOF_VehicleData.hpp:96
Definition WsfSixDOF_TunerGASpecimen.hpp:30
SinglePidValueData pidValues
Definition WsfSixDOF_TunerGASpecimen.hpp:31
double timeStamp
Definition WsfSixDOF_TunerGASpecimen.hpp:32
Copyrights Multiple, All Rights Reserved