🛰️航天仿真算法库 SpaceAST 0.3.1
载入中...
搜索中...
未找到
FeasibleRegionStudy.hpp
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstCore/Command.hpp"
25#include "AstScript/Expr.hpp"
26
27AST_NAMESPACE_BEGIN
28
36class AST_ANALYZER_API FeasibleRegionVariable: public ObjectNamed
37{
38public:
39 AST_OBJECT(FeasibleRegionVariable)
40public:
41 FeasibleRegionVariable() = default;
42 ~FeasibleRegionVariable() = default;
43
44 double lower() const { return lower_; }
45 void setLower(double lower) { lower_ = lower; }
46
47 double upper() const { return upper_; }
48 void setUpper(double upper) { upper_ = upper; }
49
50 int steps() const { return steps_; }
51 void setSteps(int steps) { steps_ = steps; }
52
53 Expr* expr() const { return expr_.get(); }
54 void setExpr(Expr* expr) { expr_ = expr; }
55
57 void generateValueList();
58
59 const std::vector<double>& values() const { return values_; }
60 std::vector<double>& values() { return values_; }
61
62 errc_t getValue(double& value) const;
63 errc_t setValue(double value);
64
65private:
66 SharedPtr<Expr> expr_{};
67 double lower_{};
68 double upper_{};
69 int steps_{10};
70 std::vector<double> values_{};
71};
72
73
76class AST_ANALYZER_API FeasibleRegionConstraint: public ObjectNamed
77{
78public:
79 AST_OBJECT(FeasibleRegionConstraint)
80
81public:
82 FeasibleRegionConstraint() = default;
83 ~FeasibleRegionConstraint() = default;
84
85 bool useLower() const { return useLower_; }
86 void setUseLower(bool useLower) { useLower_ = useLower; }
87
88 bool useUpper() const { return useUpper_; }
89 void setUseUpper(bool useUpper) { useUpper_ = useUpper; }
90
91 bool exclude() const { return exclude_; }
92 void setExclude(bool exclude) { exclude_ = exclude; }
93
94 double lower() const { return lower_; }
95 void setLower(double lower) { lower_ = lower; }
96
97 double upper() const { return upper_; }
98 void setUpper(double upper) { upper_ = upper; }
99
100 Expr* expr() const { return expr_.get(); }
101 void setExpr(Expr* expr) { expr_ = expr; }
102
103 errc_t getValue(double& value) const;
104
105private:
106 bool useLower_{};
107 bool useUpper_{};
108 bool exclude_{};
109 double lower_{};
110 double upper_{};
111 SharedPtr<Expr> expr_{};
112};
113
114
116class AST_ANALYZER_API FeasibleRegionStudy: public Command
117{
118public:
119 AST_OBJECT(FeasibleRegionStudy)
122 using VariableList = std::vector<SharedPtr<VariableType>>;
123 using ConstraintList = std::vector<SharedPtr<ConstraintType>>;
124public:
125 FeasibleRegionStudy() = default;
126 ~FeasibleRegionStudy() override = default;
127
128 errc_t execute() override;
129
130 VariableList& variables() { return variables_; }
131 const VariableList& variables() const { return variables_; }
132
133 ConstraintList& constraints() { return constraints_; }
134 const ConstraintList& constraints() const { return constraints_; }
135
137 Command* relatedCommand() const { return relatedCommand_.get(); }
138
140 void setRelatedCommand(Command* command) { relatedCommand_ = command; }
141
143 void addVariable(VariableType* variable);
144
146 void removeVariable(VariableType* variable);
147
149 void addConstraint(ConstraintType* constraint);
150
152 void removeConstraint(ConstraintType* constraint);
153
155 int totalRuns() const;
156
158 void stepIndexToVarIndices(int stepIndex, std::vector<int>& indices) const;
159
161 errc_t executeStep(int stepIndex, bool& isFeasible);
162
163private:
164 VariableList variables_{};
165 ConstraintList constraints_{};
166 mutable WeakPtr<Command> relatedCommand_{};
167};
168
171AST_NAMESPACE_END
172
173
174
命令(虚基类),用于定义任务序列中的命令,例如初始状态、轨道机动、轨道预报等
定义 Command.hpp:42
表达式基类
定义 Expr.hpp:40
可行域约束
定义 FeasibleRegionStudy.hpp:77
可行域研究,用于搜索满足约束的解空间
定义 FeasibleRegionStudy.hpp:117
Command * relatedCommand() const
获取关联的执行命令
定义 FeasibleRegionStudy.hpp:137
void setRelatedCommand(Command *command)
设置关联的执行命令
定义 FeasibleRegionStudy.hpp:140
可行域变量
定义 FeasibleRegionStudy.hpp:37
命名对象
定义 ObjectNamed.hpp:36
共享指针
定义 SharedPtr.hpp:33
变量列表
定义 VariableList.hpp:38