🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
SweepStudy.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstCore/Command.hpp"
25#include "AstScript/Expr.hpp"
26#include <memory>
27
28AST_NAMESPACE_BEGIN
29
30class Interpreter;
31
38class AST_ANALYZER_API SweepVariable : public ObjectNamed
39{
40public:
41 AST_OBJECT(SweepVariable)
42
43 double startValue() const { return startValue_; }
44 void setStartValue(double value) { startValue_ = value; }
45
46 double endValue() const { return endValue_; }
47 void setEndValue(double value) { endValue_ = value; }
48
49 double stepSize() const { return stepSize_; }
50 void setStepSize(double value) { stepSize_ = value; }
51
52 Expr* expr() const { return expr_.get(); }
53 void setExpr(Expr* expr) { expr_ = expr; }
54
55 errc_t getValue(double& value) const;
56 errc_t setValue(double value);
57
58 std::vector<double>& values() { return values_; }
59 const std::vector<double>& values() const { return values_; }
60private:
61 double startValue_{0.0};
62 double endValue_{0.0};
63 double stepSize_{0.0};
64 SharedPtr<Expr> expr_;
65 std::vector<double> values_;
66};
67
68
69class AST_ANALYZER_API SweepOutput : public ObjectNamed
70{
71public:
72 AST_OBJECT(SweepOutput)
73
74 errc_t getValue(double& value) const;
75
76 Expr* expr() const { return expr_.get(); }
77 void setExpr(Expr* expr) { expr_ = expr; }
78
79 std::vector<double>& values() {return values_;}
80 const std::vector<double>& values() const {return values_;}
81
82private:
83 SharedPtr<Expr> expr_;
84 std::vector<double> values_;
85};
86
87
88
89
91class AST_ANALYZER_API SweepStudy : public Command
92{
93public:
94 AST_OBJECT(SweepStudy)
95public:
96 SweepStudy();
97 ~SweepStudy() override;
98
100 using OutputType = SweepOutput;
101
102 using VariableList = std::vector<SharedPtr<VariableType>>;
103 using OutputList = std::vector<SharedPtr<OutputType>>;
104
105 errc_t execute() override;
106
108 VariableList& variables() { return variables_; }
109 const VariableList& variables() const { return variables_; }
110
112 OutputList& outputs() { return outputs_; }
113 const OutputList& outputs() const { return outputs_; }
114
116 void addVariable(VariableType* variable);
117
119 void removeVariable(VariableType* variable);
120
122 void addOutput(OutputType* output);
123
125 void removeOutput(OutputType* output);
126
128 Command* relatedCommand() const { return relatedCommand_.get(); }
129
131 void setRelatedCommand(Command* command) { relatedCommand_ = command; }
132
134 int totalRuns() const;
135
137 errc_t executeStep(int stepIndex);
138
139private:
141 void generateValueLists();
142
144 void stepIndexToVarIndices(int stepIndex, std::vector<int>& indices) const;
145
146 VariableList variables_;
147 OutputList outputs_;
148 mutable WeakPtr<Command> relatedCommand_;
149};
150
153AST_NAMESPACE_END
154
命令(虚基类),用于定义任务序列中的命令,例如初始状态、轨道机动、轨道预报等
定义 Command.hpp:42
表达式基类
定义 Expr.hpp:40
命名对象
定义 ObjectNamed.hpp:36
共享指针
定义 SharedPtr.hpp:33
定义 SweepStudy.hpp:70
遍历搜索分析器(参数化扫描),对变量进行嵌套循环遍历并执行仿真命令
定义 SweepStudy.hpp:92
void setRelatedCommand(Command *command)
设置关联的执行命令
定义 SweepStudy.hpp:131
VariableList & variables()
获取变量列表
定义 SweepStudy.hpp:108
OutputList & outputs()
获取输出列表
定义 SweepStudy.hpp:112
Command * relatedCommand() const
获取关联的执行命令
定义 SweepStudy.hpp:128
定义 SweepStudy.hpp:39
变量列表
定义 VariableList.hpp:38
弱引用指针
定义 WeakPtr.hpp:35