LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
solve_strategies.hpp
浏览该文件的文档.
1/**
2 * @file solve_strategies.hpp
3 * @brief 方程求解策略调度器 solve_dispatch 及相关选项结构体.
4 */
5#pragma once
6
7#include "symbolic.hpp"
10#include <vector>
11#include <memory>
12#include <string>
13
14namespace LMCAS {
15
16/** @brief 方程求解选项,控制数值求解行为和结果形式. */
18 bool allow_numeric = false; ///< 是否允许数值求解
19 int max_newton_iterations = 100; ///< Newton 迭代最大次数
20 lmmc_real_t tolerance = 1e-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 数值根结果,包含根值,残差和迭代次数. */
33 lmmc_real_t value; ///< 根的数值
34 lmmc_real_t residual; ///< 残差(将根代入方程后的绝对值)
35 int iterations; ///< 收敛所用迭代次数
36};
37
38/** @brief 求解策略枚举,标识所使用的求解方法. */
39enum 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 */
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 */
73 const std::shared_ptr<SymbolicExpr>& expr,
74 const std::string& var,
75 const SolveOptions& opts = {});
76
77
80
81/**
82 * @brief 投影完整、无条件的有限解集,并保留重数。
83 * 空集投影为空向量;无限解集或条件解集返回 Inconclusive。
84 */
86 const std::shared_ptr<SymbolicExpr>& expression,
87 const std::string& variable,
89 const SolveOptions& options = {});
90
92 const std::shared_ptr<SymbolicExpr>& expression,
93 const std::string& variable,
94 const SolveOptions& options = {});
95}
#define LMCAS_API
const std::string & variable
bool has_initial_guess
是否指定了初始猜测值
bool allow_numeric
是否允许数值求解
ExprResult e()
SolveStrategy
求解策略枚举,标识所使用的求解方法.
@ RootOf
以 RootOf 表达式表示
@ Numerical
数值迭代求解
@ ClosedForm
闭式公式求解
@ Preprocessing
预处理(化简,换元等)
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
Result< SolutionSet > SolveResult
bool has_search_interval
是否指定了搜索区间
const std::string ComputationContext const SolveOptions & options
int iterations
收敛所用迭代次数
bool return_rootof
为 false 时,任何不可表示的根使整个求解返回 Inconclusive。
LMCAS::SolveResult solve_equation(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, ComputationContext &context, const SolveOptions &opts)
lmmc_real_t tolerance
收敛容差
lmmc_real_t search_lo
搜索区间下界(默认 -10)
lmmc_real_t initial_guess
数值迭代初始猜测值
LMCAS::FiniteSolveResult solve_finite_checked(const std::shared_ptr< SymbolicExpr > &expr, const std::string &var, ComputationContext &context, const SolveOptions &opts)
Result< std::vector< std::shared_ptr< SymbolicExpr > > > FiniteSolveResult
lmmc_real_t search_hi
搜索区间上界(默认 10)
int max_roots
数值候选数量预算;精确解集和整数解族保持完整。
lmmc_real_t value
根的数值
lmmc_real_t residual
残差(将根代入方程后的绝对值)
int max_newton_iterations
Newton 迭代最大次数
方程求解选项,控制数值求解行为和结果形式.
数值根结果,包含根值,残差和迭代次数.
符号表达式主类 SymbolicExpr 及其工厂方法,运算接口.