WSF
P6DofTunerGASpecimen.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 2017 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 P6DOFTUNERGASPECIMEN_HPP
13#define P6DOFTUNERGASPECIMEN_HPP
14
15#include "p6dof_export.h"
16
17#include <vector>
18
19#include "P6DofVehicleData.hpp"
20#include "UtRandom.hpp"
21
22class P6DOF_EXPORT P6DofTunerGASpecimen
23{
24public:
30
32
33 void GenerateSpecimen();
34 double AssessObjective(std::vector<PidLogElement>& aSimData);
35 double GetObjectiveValue() const { return mObjectiveValue; }
36 void GenerateChromosome();
37 std::string GetChromosome() const { return mChromosome; }
38 void Mutate(double aMutationProbability);
39 void CrossOver(P6DofTunerGASpecimen& aSpecimen);
40
41 // Set weight factor for error portion of objective calculation
42 void SetErrorWeight(double aErrorWeight) { mErrorWeight = aErrorWeight; }
43 double GetErrorWeight() const { return mErrorWeight; }
44
45 // Set weight factor for overshoot portion of objective calculation
46 void SetOvershootWeight(double aOvershootWeight) { mOvershootWeight = aOvershootWeight; }
47 double GetOvershootWeight() const { return mOvershootWeight; }
48
49 // Sets the Kp range
50 void SetKpRange(double aLowerBound, double aUpperBound);
51
52 // Sets the Ki range
53 void SetKiRange(double aLowerBound, double aUpperBound);
54
55 // Sets the Kd range
56 void SetKdRange(double aLowerBound, double aUpperBound);
57
58 // Sets the pointer to the RNG
59 void SetRandomPtr(ut::Random* aRandom);
60
61 // Returns PID Kp
62 double GetKp() const { return std::pow(10.0, mLogKp); }
63
64 // Returns PID Ki
65 double GetKi() const { return std::pow(10.0, mLogKi); }
66
67 // Returns PID Kd
68 double GetKd() const { return std::pow(10.0, mLogKd); }
69
70private:
71 void DetermineChromosomeLengths();
72 std::string IntToBinString(size_t aInt, size_t aLength);
73 unsigned int BinStringToInt(const std::string& aBinString);
74 void UpdateBasedOnChromosome();
75
76 static const double cDefaultLogKpRange[2];
77 static const double cDefaultLogKiRange[2];
78 static const double cDefaultLogKdRange[2];
79
80 double mObjectiveValue;
81 double mLogKp, mLogKi, mLogKd;
82 double mLogKpRange[2];
83 double mLogKiRange[2];
84 double mLogKdRange[2];
85 std::string mChromosome;
86 size_t mChromosomeLengths[3];
87
88 double mErrorWeight;
89 double mOvershootWeight;
90 ut::Random* mRandomPtr = nullptr;
91};
92
93#endif
Definition P6DofTunerGASpecimen.hpp:23
double GetObjectiveValue() const
Definition P6DofTunerGASpecimen.hpp:35
double GetErrorWeight() const
Definition P6DofTunerGASpecimen.hpp:43
void GenerateSpecimen()
Definition P6DofTunerGASpecimen.cpp:47
void SetOvershootWeight(double aOvershootWeight)
Definition P6DofTunerGASpecimen.hpp:46
double GetKd() const
Definition P6DofTunerGASpecimen.hpp:68
double AssessObjective(std::vector< PidLogElement > &aSimData)
Definition P6DofTunerGASpecimen.cpp:84
void SetErrorWeight(double aErrorWeight)
Definition P6DofTunerGASpecimen.hpp:42
double GetKi() const
Definition P6DofTunerGASpecimen.hpp:65
std::string GetChromosome() const
Definition P6DofTunerGASpecimen.hpp:37
double GetKp() const
Definition P6DofTunerGASpecimen.hpp:62
double GetOvershootWeight() const
Definition P6DofTunerGASpecimen.hpp:47
P6DofTunerGASpecimen()
Definition P6DofTunerGASpecimen.cpp:24
Definition P6DofVehicleData.hpp:152
Definition P6DofTunerGASpecimen.hpp:26
P6DOF::SinglePidValueData pidValues
Definition P6DofTunerGASpecimen.hpp:27
double timeStamp
Definition P6DofTunerGASpecimen.hpp:28
Copyrights Multiple, All Rights Reserved