LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
solve_strategies.hpp
浏览该文件的文档.
1
/**
2
* @file solve_strategies.hpp
3
* @brief 方程求解策略调度器 solve_dispatch 及相关选项结构体.
4
*/
5
#pragma once
6
7
#include "
symbolic.hpp
"
8
#include "
computation_context.hpp
"
9
#include "
conditional_result.hpp
"
10
#include <vector>
11
#include <memory>
12
#include <string>
13
14
namespace
LMCAS
{
15
16
/** @brief 方程求解选项,控制数值求解行为和结果形式. */
17
struct
SolveOptions
{
18
bool
allow_numeric
=
false
;
///< 是否允许数值求解
19
int
max_newton_iterations
= 100;
///< Newton 迭代最大次数
20
lmmc_real_t
tolerance
= 1
e
-12;
///< 收敛容差
21
int
max_roots
= -1;
/**< 数值候选数量预算;精确解集和整数解族保持完整。 */
22
bool
return_rootof
=
true
;
/**< 为 false 时,任何不可表示的根使整个求解返回 Inconclusive。 */
23
lmmc_real_t
initial_guess
= 0.0;
///< 数值迭代初始猜测值
24
bool
has_initial_guess
=
false
;
///< 是否指定了初始猜测值
25
26
lmmc_real_t
search_lo
= -10.0;
///< 搜索区间下界(默认 -10)
27
lmmc_real_t
search_hi
= 10.0;
///< 搜索区间上界(默认 10)
28
bool
has_search_interval
=
false
;
///< 是否指定了搜索区间
29
};
30
31
/** @brief 数值根结果,包含根值,残差和迭代次数. */
32
struct
NumericRoot
{
33
lmmc_real_t
value
;
///< 根的数值
34
lmmc_real_t
residual
;
///< 残差(将根代入方程后的绝对值)
35
int
iterations
;
///< 收敛所用迭代次数
36
};
37
38
/** @brief 求解策略枚举,标识所使用的求解方法. */
39
enum class
SolveStrategy
{
40
ClosedForm
,
///< 闭式公式求解
41
Preprocessing
,
///< 预处理(化简,换元等)
42
Transcendental
,
///< 超越方程求解
43
Numerical
,
///< 数值迭代求解
44
RootOf
///< 以 RootOf 表达式表示
45
};
46
47
48
49
50
/**
51
* @brief 在已验证支持域内求方程的完整解集。
52
* 精确有理多项式保留全部复根及重数,以精确根式或 RootOf 表示,保持系数精确。
53
* 实超越反演保留原操作数定义域、整数参数和未决条件;系数退化未知时,
54
* 返回完整的 ConditionalSolutions,并以条件限定通用根。
55
* 数值搜索可辅助求解;候选残差全部通过仍不足以证明完备性。
56
* 完备性未证或完整定义域无法表示时返回 CasErrc::Inconclusive。
57
* 成功表示在上下文假设及所有返回条件下,得到操作定义域内的完整解集。
58
* UniversalSolutions 仅在该域内普遍成立,原式极点始终排除。
59
* 候选残差恒等式仅证明公共定义域上的正确性;可定义性、根的互异性及覆盖性须另证。
60
* 未决逐点条件须保留为条件或 Inconclusive,形式非恒等式不足以消除这些条件。
61
* 资源耗尽与取消仍作为外层错误返回。
62
*/
63
LMCAS_API
SolveResult
solve_equation
(
64
const
std::shared_ptr<SymbolicExpr>& expr,
65
const
std::string& var,
66
ComputationContext&
context
,
67
const
SolveOptions& opts = {});
68
69
/**
70
* @brief Solves an equation using a default computation context.
71
*/
72
LMCAS_API
SolveResult
solve_equation
(
73
const
std::shared_ptr<SymbolicExpr>& expr,
74
const
std::string& var,
75
const
SolveOptions
& opts = {});
76
77
78
using
FiniteSolveResult
=
79
Result<std::vector<std::shared_ptr<SymbolicExpr>
>>;
80
81
/**
82
* @brief 投影完整、无条件的有限解集,并保留重数。
83
* 空集投影为空向量;无限解集或条件解集返回 Inconclusive。
84
*/
85
LMCAS_API
FiniteSolveResult
solve_finite_checked
(
86
const
std::shared_ptr<SymbolicExpr>& expression,
87
const
std::string&
variable
,
88
ComputationContext
&
context
,
89
const
SolveOptions
&
options
= {});
90
91
LMCAS_API
FiniteSolveResult
solve_finite_checked
(
92
const
std::shared_ptr<SymbolicExpr>& expression,
93
const
std::string&
variable
,
94
const
SolveOptions&
options
= {});
95
}
LMCAS::ComputationContext
定义
computation_context.hpp:99
LMCAS::Result
定义
result.hpp:39
computation_context.hpp
conditional_result.hpp
LMCAS_API
#define LMCAS_API
定义
lmcas_export.hpp:13
LMCAS
定义
assumption.hpp:11
LMCAS::variable
const std::string & variable
定义
expr.hpp:286
LMCAS::SolveOptions::has_initial_guess
bool has_initial_guess
是否指定了初始猜测值
定义
solve_strategies.hpp:24
LMCAS::SolveOptions::allow_numeric
bool allow_numeric
是否允许数值求解
定义
solve_strategies.hpp:18
LMCAS::e
ExprResult e()
定义
expr_values.cpp:112
LMCAS::SolveStrategy
SolveStrategy
求解策略枚举,标识所使用的求解方法.
定义
solve_strategies.hpp:39
LMCAS::SolveStrategy::RootOf
@ RootOf
以 RootOf 表达式表示
定义
solve_strategies.hpp:44
LMCAS::SolveStrategy::Numerical
@ Numerical
数值迭代求解
定义
solve_strategies.hpp:43
LMCAS::SolveStrategy::ClosedForm
@ ClosedForm
闭式公式求解
定义
solve_strategies.hpp:40
LMCAS::SolveStrategy::Preprocessing
@ Preprocessing
预处理(化简,换元等)
定义
solve_strategies.hpp:41
LMCAS::context
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
定义
exact_factorization.hpp:65
LMCAS::SolveResult
Result< SolutionSet > SolveResult
定义
conditional_result.hpp:77
LMCAS::SolveOptions::has_search_interval
bool has_search_interval
是否指定了搜索区间
定义
solve_strategies.hpp:28
LMCAS::options
const std::string ComputationContext const SolveOptions & options
定义
expr.hpp:355
LMCAS::NumericRoot::iterations
int iterations
收敛所用迭代次数
定义
solve_strategies.hpp:35
LMCAS::SolveOptions::return_rootof
bool return_rootof
为 false 时,任何不可表示的根使整个求解返回 Inconclusive。
定义
solve_strategies.hpp:22
LMCAS::solve_equation
LMCAS::SolveResult solve_equation(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, ComputationContext &context, const SolveOptions &opts)
定义
solve_visitor.cpp:456
LMCAS::SolveOptions::tolerance
lmmc_real_t tolerance
收敛容差
定义
solve_strategies.hpp:20
LMCAS::SolveOptions::search_lo
lmmc_real_t search_lo
搜索区间下界(默认 -10)
定义
solve_strategies.hpp:26
LMCAS::SolveOptions::initial_guess
lmmc_real_t initial_guess
数值迭代初始猜测值
定义
solve_strategies.hpp:23
LMCAS::solve_finite_checked
LMCAS::FiniteSolveResult solve_finite_checked(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, ComputationContext &context, const SolveOptions &opts)
定义
solve_visitor.cpp:622
LMCAS::FiniteSolveResult
Result< std::vector< std::shared_ptr< SymbolicExpr > > > FiniteSolveResult
定义
solve_strategies.hpp:78
LMCAS::SolveOptions::search_hi
lmmc_real_t search_hi
搜索区间上界(默认 10)
定义
solve_strategies.hpp:27
LMCAS::SolveOptions::max_roots
int max_roots
数值候选数量预算;精确解集和整数解族保持完整。
定义
solve_strategies.hpp:21
LMCAS::NumericRoot::value
lmmc_real_t value
根的数值
定义
solve_strategies.hpp:33
LMCAS::NumericRoot::residual
lmmc_real_t residual
残差(将根代入方程后的绝对值)
定义
solve_strategies.hpp:34
LMCAS::PropType::Transcendental
@ Transcendental
定义
query_interface.hpp:42
LMCAS::SolveOptions::max_newton_iterations
int max_newton_iterations
Newton 迭代最大次数
定义
solve_strategies.hpp:19
LMCAS::SolveOptions
方程求解选项,控制数值求解行为和结果形式.
定义
solve_strategies.hpp:17
LMCAS::NumericRoot
数值根结果,包含根值,残差和迭代次数.
定义
solve_strategies.hpp:32
symbolic.hpp
符号表达式主类 SymbolicExpr 及其工厂方法,运算接口.
include
solve_strategies.hpp
生成于
, 为 LMCAS使用
1.18.0