LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
vector_calculus_extrema.hpp
浏览该文件的文档.
1
#pragma once
2
3
#include "
vector_calculus_types.hpp
"
4
5
namespace
LMCAS
{
6
7
enum class
CriticalPointClassification
{
8
LocalMinimum
,
9
LocalMaximum
,
10
Saddle
,
11
Degenerate
,
12
Inconclusive
13
};
14
15
/** @brief 临界点的坐标、分类及成立条件。 */
16
struct
CriticalPoint
{
17
std::map<std::string, std::shared_ptr<SymbolicExpr>>
point
;
18
CriticalPointClassification
classification
=
19
CriticalPointClassification::Inconclusive
;
20
std::vector<std::shared_ptr<SymbolicExpr>>
conditions
;
21
};
22
23
using
ExtremaResult
=
Result<std::vector<CriticalPoint>
>;
24
using
LagrangeResult
=
25
Result<std::vector<std::map<std::string, std::shared_ptr<SymbolicExpr>
>>>;
26
27
/**
28
* @brief 求多元函数的极值点并分类。
29
*
30
* 求解 ∇f = 0,并按海森矩阵的特征值分类:
31
* - 所有特征值为正 → 局部极小值 (minimum)
32
* - 所有特征值为负 → 局部极大值 (maximum)
33
* - 特征值正负混合 → 鞍点 (saddle)
34
* - 海森矩阵奇异 → 退化点 (degenerate)
35
*
36
* @param[in] f 标量函数表达式
37
* @param[in] vars 变量名列表
38
* @return 临界点列表,每个包含坐标和分类
39
*/
40
LMCAS_API
ExtremaResult
find_extrema_checked
(
41
const
std::shared_ptr<SymbolicExpr>& f,
42
const
std::vector<std::string>&
vars
,
43
ComputationContext
&
context
);
44
45
/** @brief 使用默认计算上下文求极值点;无效输入和未覆盖域以错误返回。 */
46
LMCAS_API
ExtremaResult
find_extrema_checked
(
47
const
std::shared_ptr<SymbolicExpr>& f,
48
const
std::vector<std::string>&
vars
);
49
50
LMCAS_API
std::vector<CriticalPoint>
find_extrema
(
51
const
std::shared_ptr<SymbolicExpr>& f,
const
std::vector<std::string>&
vars
);
52
53
/**
54
* @brief 使用拉格朗日乘数法求约束极值。
55
*
56
* 构造系统 ∇f = λ₁∇g₁ + λ₂∇g₂ + ... 并联合约束方程 gᵢ = 0 求解。
57
* 支持单个和多个等式约束。
58
*
59
* @param[in] f 目标函数表达式
60
* @param[in] constraints 约束列表(每个约束表达式等于零)
61
* @param[in] vars 变量名列表
62
* @return 所有临界点的列表,每个为变量名到值的映射(仅包含原始变量,不含乘数)
63
*/
64
LMCAS_API
LagrangeResult
lagrange_multipliers_checked
(
65
const
std::shared_ptr<SymbolicExpr>& f,
66
const
std::vector<std::shared_ptr<SymbolicExpr>>& constraints,
67
const
std::vector<std::string>&
vars
,
68
ComputationContext
&
context
);
69
70
/** @brief 使用默认计算上下文求拉格朗日候选;无效输入和未覆盖域以错误返回。 */
71
LMCAS_API
LagrangeResult
lagrange_multipliers_checked
(
72
const
std::shared_ptr<SymbolicExpr>& f,
73
const
std::vector<std::shared_ptr<SymbolicExpr>>& constraints,
74
const
std::vector<std::string>&
vars
);
75
76
LMCAS_API
std::vector<std::map<std::string, std::shared_ptr<SymbolicExpr>>>
lagrange_multipliers
(
77
const
std::shared_ptr<SymbolicExpr>& f,
78
const
std::vector<std::shared_ptr<SymbolicExpr>>& constraints,
79
const
std::vector<std::string>&
vars
);
80
81
}
LMCAS::ComputationContext
定义
computation_context.hpp:99
LMCAS::Result
定义
result.hpp:39
LMCAS_API
#define LMCAS_API
定义
lmcas_export.hpp:13
LMCAS
定义
assumption.hpp:11
LMCAS::context
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context
定义
exact_factorization.hpp:65
LMCAS::vars
__attribute__((visibility("default"))) VectorCalculusFieldResult gradient_checked(const std __attribute__((visibility("default"))) VectorCalculusFieldResult gradient_checked(const std __attribute__((visibility("default"))) VectorField gradient(const std const std::vector< std::string > & vars
定义
vector_calculus_differential.hpp:36
LMCAS::CasErrc::Inconclusive
@ Inconclusive
定义
result.hpp:24
LMCAS::LagrangeResult
Result< std::vector< std::map< std::string, std::shared_ptr< SymbolicExpr > > > > LagrangeResult
定义
vector_calculus_extrema.hpp:24
LMCAS::lagrange_multipliers_checked
LagrangeResult lagrange_multipliers_checked(const std::shared_ptr< SymbolicExpr > &f, const std::vector< std::shared_ptr< SymbolicExpr > > &constraints, const std::vector< std::string > &vars, ComputationContext &context)
定义
vector_calculus_lagrange.cpp:193
LMCAS::CriticalPointClassification
CriticalPointClassification
定义
vector_calculus_extrema.hpp:7
LMCAS::CriticalPointClassification::Inconclusive
@ Inconclusive
定义
vector_calculus_extrema.hpp:12
LMCAS::CriticalPointClassification::Degenerate
@ Degenerate
定义
vector_calculus_extrema.hpp:11
LMCAS::CriticalPointClassification::LocalMinimum
@ LocalMinimum
定义
vector_calculus_extrema.hpp:8
LMCAS::CriticalPointClassification::LocalMaximum
@ LocalMaximum
定义
vector_calculus_extrema.hpp:9
LMCAS::CriticalPointClassification::Saddle
@ Saddle
定义
vector_calculus_extrema.hpp:10
LMCAS::find_extrema_checked
ExtremaResult find_extrema_checked(const std::shared_ptr< SymbolicExpr > &f, const std::vector< std::string > &vars, ComputationContext &context)
定义
vector_calculus_extrema.cpp:197
LMCAS::ExtremaResult
Result< std::vector< CriticalPoint > > ExtremaResult
定义
vector_calculus_extrema.hpp:23
LMCAS::find_extrema
std::vector< CriticalPoint > find_extrema(const std::shared_ptr< SymbolicExpr > &f, const std::vector< std::string > &vars)
定义
vector_calculus_extrema.cpp:373
LMCAS::lagrange_multipliers
std::vector< std::map< std::string, std::shared_ptr< SymbolicExpr > > > lagrange_multipliers(const std::shared_ptr< SymbolicExpr > &f, const std::vector< std::shared_ptr< SymbolicExpr > > &constraints, const std::vector< std::string > &vars)
定义
vector_calculus_lagrange.cpp:252
LMCAS::CriticalPoint
临界点的坐标、分类及成立条件。
定义
vector_calculus_extrema.hpp:16
LMCAS::CriticalPoint::conditions
std::vector< std::shared_ptr< SymbolicExpr > > conditions
定义
vector_calculus_extrema.hpp:20
LMCAS::CriticalPoint::classification
CriticalPointClassification classification
定义
vector_calculus_extrema.hpp:18
LMCAS::CriticalPoint::point
std::map< std::string, std::shared_ptr< SymbolicExpr > > point
定义
vector_calculus_extrema.hpp:17
vector_calculus_types.hpp
include
vector_calculus_extrema.hpp
生成于
, 为 LMCAS使用
1.18.0