35 KiB
core 模块
AI 自动生成,基于源代码扫描(Doxygen)。最后更新: 2026-09-27
再生成:python tools/api/gen_api_docs.py(examples.md / call-graph.md 人工维护,不覆盖)
职责
求解内核:数值引擎(Newton/SparseLM/DogLeg 信赖域/分解/增量)+ 多起点重启、拖拽会话控制、策略框架、DOF 分析、图分解、诊断、表达式求值、多解分支
依赖
geom、infra
头文件
include/vdcs/core/branch_selector.hinclude/vdcs/core/constraint_graph.hinclude/vdcs/core/decomposed_solver.hinclude/vdcs/core/decomposer.hinclude/vdcs/core/diagnostic.hinclude/vdcs/core/dof_analyzer.hinclude/vdcs/core/dogleg_solver.hinclude/vdcs/core/drag_controller.hinclude/vdcs/core/expression.hinclude/vdcs/core/incremental.hinclude/vdcs/core/multi_start_solver.hinclude/vdcs/core/newton_solver.hinclude/vdcs/core/solve_context.hinclude/vdcs/core/solver_strategy.hinclude/vdcs/core/sparse_lm_solver.h
vdcs::AutoStrategy
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
const char * vdcs::AutoStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
vdcs::BinaryExpr
二元运算('+' '-' '*' '/' '^';'^' 右结合 → 2^3^2 = 512)
头文件: include/vdcs/core/expression.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
lhs |
lhs |
{待补充} |
op |
char op |
{待补充} |
rhs |
rhs |
{待补充} |
vdcs::BranchOptions
分支枚举选项
头文件: include/vdcs/core/branch_selector.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
cluster_tolerance |
double cluster_tolerance |
解聚类阈值:两解 ‖q_i − q_j‖∞ 小于此值视为同一分支 |
num_samples |
int num_samples |
随机起点数(第 1 个为未扰动的当前初值本身) |
perturbation_scale |
double perturbation_scale |
扰动幅度系数:幅度 = scale × (1 + ‖当前参数‖∞),随模型尺度自适应 |
seed |
std::uint64_t seed |
扰动序列种子——确定性枚举:同模型同 seed 必得同分支集 |
vdcs::BranchSelector
头文件: include/vdcs/core/branch_selector.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Apply |
static void vdcs::BranchSelector::Apply(Model &model, const BranchSolution &branch) |
把选定分支写回模型(参数 + 切坐标重基准); 随后常规读取实体参数即得该分支解 |
Enumerate |
static std::vector< BranchSolution > vdcs::BranchSelector::Enumerate(Model &model, const BranchOptions &options=BranchOptions(), const SolveOptions &solve=SolveOptions()) |
多起点枚举分支:当前初值 + num_samples−1 个确定性随机扰动 起点逐个牛顿求解;未收敛起点丢弃,收敛解按无穷范数距离 聚类去重,按首次发现顺序返回。模型参数保持入口值不变 (内部 ScatterParams 注入起点、出口恢复原值) |
SelectNearest |
static std::size_t vdcs::BranchSelector::SelectNearest(const std::vector< BranchSolution > &branches, const Eigen::VectorXd &ref) |
选择与参考参数最近的分支(返回 branches 下标)。 ref 为期望分支的示意参数向量——CollectParams 布局同尺寸, 通常取模型当前参数并把目标实体摆到期望位置后收集 |
vdcs::BranchSolution
一个收敛分支的解
头文件: include/vdcs/core/branch_selector.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
params |
Eigen::VectorXd params |
分支解的全局参数(CollectParams 布局) |
report |
report |
该分支的求解报告 |
vdcs::CallExpr
函数调用(20 数学函数,见 expression.cpp 函数表)
头文件: include/vdcs/core/expression.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
args |
std::vector< args |
{待补充} |
name |
std::string name |
{待补充} |
vdcs::ChangeSet
头文件: include/vdcs/core/incremental.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Empty |
bool vdcs::ChangeSet::Empty() const |
{待补充} |
字段
| 字段 | 类型 | 说明 |
|---|---|---|
changed_constraints |
std::vector< changed_constraints |
{待补充} |
changed_entities |
std::vector< changed_entities |
{待补充} |
structural |
bool structural |
{待补充} |
vdcs::ComponentDofReport
单个连通分量的 DOF 报告
头文件: include/vdcs/core/dof_analyzer.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
constraints |
std::vector< constraints |
{待补充} |
dependent_constraints |
std::vector< dependent_constraints |
完全冗余候选(g72,上游 conflictGroups 行级归因同构): 秩亏分量的雅可比经 J^T 列主元 QR 选出独立行集,rank 外主元 列 = 依赖行 → 经行区映射约束(多行约束任一行依赖即入列; 依赖行集不唯一,语义 = 冗余组内「可移除的约束」——上游 identifyConflictingRedundantConstraints 的 QR 依赖列同源)。 仅 rank_deficient && !rank_partial 且 QR 秩与 SVD 秩一致时 填充(不一致时留空,调用方回落全组件口径) |
entities |
std::vector< entities |
{待补充} |
entity_dof |
int entity_dof |
Σ 实体 DOF |
excluded_dof |
int excluded_dof |
Σ 诊断排除槽(g39,上游 pdrivenlist 语义)——被驱动参数槽 由其他参数决定,非自由度:mobility/residual_dof 口径扣减, 求解侧不受影响(诊断与求解解耦,上游 diagnose 用 pdiagnoselist、solve 用全 plist 同构) |
gauge |
int gauge |
整体刚体自由度(规范自由度):无 Fixed 时 2D 分量 G=3(2 平移+1 旋转)、 3D 分量 G=6(3 平移+3 旋转),上限不超过分量可表达的 DOF;有 Fixed 时 0 |
index |
int index |
分量编号(与 ConstraintGraph 一致) |
mobility |
int mobility |
M = entity_dof − removed_dof − gauge. |
numerical_rank |
int numerical_rank |
当前构型下分量雅可比的数值秩(SVD) |
partial_constraints |
std::vector< partial_constraints |
部分冗余约束(g23,对标 planeGCS QR 细分诊断):秩亏分量内 逐约束秩贡献 0 < rank(J) − rank(J∖其行) < RemovedDof ——多行 约束仅部分行线性独立(如 Coincident 与 DistanceX=0 并存时 Coincident 的 dx 行依赖、dy 行独立)。仅 rank_deficient 且 !rank_partial 分量填充(完备分量必无部分冗余:Σ贡献=秩=行数)。 g27 起为交互级吞吐 best-effort 限流:单行约束贡献 ∈{0,1} 恒 非 partial 直接跳过(数学无损);留一 SVD 工作量超预算的分量 放弃定位(rank_deficient 等粗诊断不受影响) |
rank_deficient |
bool rank_deficient |
rank < removed_dof:约束梯度线性相关 → 存在冗余/冲突 |
rank_partial |
bool rank_partial |
秩校验覆盖不全(g19):分量含外部曲线约束且几何 adapter 未注入 ——这些约束的行未参与 SVD,numerical_rank/rank_deficient/residual_dof 仅覆盖可验证子集(计数分类不受影响)。宿主应 Model::SetGeometryAdapter() 后重跑分析获取完整秩校验 |
removed_dof |
int removed_dof |
Σ 约束消除 DOF |
residual_dof |
int residual_dof |
参数级剩余自由度 = 分量参数数 − 数值秩(含刚体模态;P-09 residualDof) |
status |
status |
{待补充} |
vdcs::ConstraintGraph
头文件: include/vdcs/core/constraint_graph.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Build |
static ConstraintGraph vdcs::ConstraintGraph::Build(const Model &model) |
从模型构建(实体/约束的参与关系来自对象的 Entities() 列表) |
ComponentAt |
const Component & vdcs::ConstraintGraph::ComponentAt(int index) const |
{待补充} |
ComponentCount |
int vdcs::ConstraintGraph::ComponentCount() const |
{待补充} |
ComponentOfConstraint |
int vdcs::ConstraintGraph::ComponentOfConstraint(Uid constraint) const |
约束所属分量编号;未知约束返回 -1 |
ComponentOfEntity |
int vdcs::ConstraintGraph::ComponentOfEntity(Uid entity) const |
实体所属分量编号;未知实体返回 -1 |
ConstraintCount |
int vdcs::ConstraintGraph::ConstraintCount() const |
{待补充} |
Constraints |
const std::vector< Uid > & vdcs::ConstraintGraph::Constraints() const |
{待补充} |
ConstraintsOfEntity |
const std::vector< Uid > & vdcs::ConstraintGraph::ConstraintsOfEntity(Uid entity) const |
引用实体的约束(保持模型声明顺序);未知实体返回空 |
Degree |
int vdcs::ConstraintGraph::Degree(Uid entity) const |
实体度数 = 引用该实体的约束数;未知实体返回 -1 |
Entities |
const std::vector< Uid > & vdcs::ConstraintGraph::Entities() const |
{待补充} |
EntitiesOfConstraint |
const std::vector< Uid > & vdcs::ConstraintGraph::EntitiesOfConstraint(Uid constraint) const |
约束引用的实体(保持约束声明顺序);未知约束返回空 |
EntityCount |
int vdcs::ConstraintGraph::EntityCount() const |
{待补充} |
HasConstraint |
bool vdcs::ConstraintGraph::HasConstraint(Uid constraint) const |
{待补充} |
HasEntity |
bool vdcs::ConstraintGraph::HasEntity(Uid entity) const |
{待补充} |
vdcs::ConstraintGraph::Component
连通分量:分量内的实体与约束(保持模型声明顺序)
头文件: include/vdcs/core/constraint_graph.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
constraints |
std::vector< constraints |
{待补充} |
entities |
std::vector< entities |
{待补充} |
vdcs::DecomposedSolver
头文件: include/vdcs/core/decomposed_solver.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
ComputeLayers |
static std::vector< std::vector< int > > vdcs::DecomposedSolver::ComputeLayers(const DecompositionReport &decomp) |
块 DAG 拓扑分层(P4-S2-01):layers[k] = 第 k 层可并行求解的 块索引集合——层内块互不依赖,层间按依赖方向排序。 层内按块编号稳定排序(确定性);层数 = 块 DAG 关键路径长度。 自愈防御:越界/自环依赖边忽略 |
Solve |
static Result< SolveReport > vdcs::DecomposedSolver::Solve(Model &model, const SolveOptions &options=SolveOptions()) |
对模型分解求解;成功时参数已写回实体(含切坐标重基准) |
SolveBlocks |
static Result< SolveReport > vdcs::DecomposedSolver::SolveBlocks(Model &model, const DecompositionReport &decomp, const std::vector< int > &blocks, const SolveOptions &options=SolveOptions()) |
块子集重解(P3-S1-02 增量求解底层):按给定块逐块稠密 LM, 未列入块(含其上游依赖块)参数作为固定边界不参与重解; 返回时参数已写回,收尾全局残差验证 + 收敛时切坐标重基准 (与 Solve 语义一致——脏块外的约束应已满足,全局验证兜底)。 blocks 需为 decomp 的块索引;内部按 solve_order 依序求解 |
SolveParallel |
static Result< SolveReport > vdcs::DecomposedSolver::SolveParallel(Model &model, const SolveOptions &options=SolveOptions(), int num_threads=0) |
并行分解求解(P4-S2-01,内部 DM 分解): 块 DAG 分层 → 层内独立块多线程并行、层间按依赖序串行推进; 工作线程组持久复用(只派生一次,层间 barrier 唤醒) |
SolveParallel |
static Result< SolveReport > vdcs::DecomposedSolver::SolveParallel(Model &model, const DecompositionReport &decomp, const SolveOptions &options=SolveOptions(), int num_threads=0) |
并行分解求解(复用宿主持有的分解报告,增量场景友好) 并行安全性依据(继承串行拓扑序既有不变式): |
| DM 分解中实体/约束唯一归属块(副本同部定理), 且块 i 的约束只引用块 i ∪ dependencies(i) 的实体 (串行求解「拓扑序保证依赖块已先收敛」所依赖的同一不变式) | ||
| Kahn 分层下同层块互不依赖 → 同层块的参数列切片与方程集合 互不相交;q 原位更新(不重分配)互不冲突,层间屏障保证 前层参数在读取期间不再被写 | ||
| 每线程独立 BlockWorkspace;ctx/模型结构只读共享 数值确定性:同层块相互独立、每块输入(初值 + 前层收敛解)与 串行逐块求解完全一致 → 结果与串行 逐位一致,可复现 退化路径:num_threads <= 1 或所有层宽为 1(深链 DAG)时 主线程串行直解,零线程开销(SolveReport::threads = 1) 回调契约:并行模式下进度事件从工作线程发出,引擎内经互斥锁 串行化转发——宿主回调须可重入/线程安全,事件到达顺序非确定 几何注入契约:并行求解要求 IGeometryAdapter 的 Evaluate/ Derivative 支持并发只读调用(无状态实现天然满足) num_threads = 0 取 hardware_concurrency 并按工作量配额自适应: 每线程至少 512 个块方程,小模型自动回退串行(派生开销 > 并行收益,SolveReport::threads = 1 诚实上报,auto 模式要么 加速要么持平、绝不减速);显式 num_threads > 0 不受配额 约束,实际并行度 = min(num_threads, 最宽层块数) |
vdcs::DecomposedStrategy
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
const char * vdcs::DecomposedStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
vdcs::Decomposer
头文件: include/vdcs/core/decomposer.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Decompose |
static DecompositionReport vdcs::Decomposer::Decompose(const Model &model) |
分解(内部构建约束图) |
Decompose |
static DecompositionReport vdcs::Decomposer::Decompose(const Model &model, const ConstraintGraph &graph) |
分解(复用已构建的约束图) |
vdcs::DecompositionBlock
头文件: include/vdcs/core/decomposer.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
constraints |
std::vector< constraints |
{待补充} |
entities |
std::vector< entities |
{待补充} |
entity_dof |
int entity_dof |
Σ 实体 DOF. |
removed_dof |
int removed_dof |
Σ 约束消除 DOF. |
type |
type |
{待补充} |
vdcs::DecompositionReport
DR-planning 分解报告
头文件: include/vdcs/core/decomposer.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
blocks |
std::vector< blocks |
{待补充} |
dependencies |
std::vector< std::vector< int > > dependencies |
dependencies[i]:块 i 求解前应已完成的块(引用方向在前: 欠约束块挂在 well 块上 → well 块先解) |
matched_dof |
int matched_dof |
最大匹配基数:结构上可被约束消除的参数 DOF (与 total_removed_dof 的差 = 结构冗余量候选) |
solve_order |
std::vector< int > solve_order |
块拓扑求解序(依赖在前,同层按块编号稳定排序) |
total_entity_dof |
int total_entity_dof |
Σ 全部实体 DOF. |
total_removed_dof |
int total_removed_dof |
Σ 全部约束消除 DOF |
vdcs::Diagnostic
单条诊断:引用 UID 可定位到具体实体/约束(P-08 稳定标识)
头文件: include/vdcs/core/diagnostic.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
block |
int block |
DM 分解块索引(P2-S4-02 结构诊断定位;-1 = 无块信息) |
code |
code |
{待补充} |
component |
int component |
约束图连通分量索引(可选) |
constraint |
constraint |
关联约束(可选) |
entity |
entity |
关联实体(可选) |
level |
level |
{待补充} |
message |
std::string message |
{待补充} |
vdcs::DirectNewtonStrategy
稠密 Newton(小模型:免 DOF 表/LDLT 符号分析固定开销)
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
const char * vdcs::DirectNewtonStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
vdcs::DirtyPropagator
头文件: include/vdcs/core/incremental.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Propagate |
static DirtySet vdcs::DirtyPropagator::Propagate(const Model &model, const ChangeSet &changes, const DecompositionReport *decomp=nullptr) |
计算脏闭包。decomp 可为 nullptr(跳过块级闭包); 调用方负责 DecompositionReport 与模型的版本一致性 (structural 变更后的旧分解传入是未定义行为,应置 full_rebuild) |
vdcs::DirtySet
头文件: include/vdcs/core/incremental.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
IsClean |
bool vdcs::DirtySet::IsClean() const |
{待补充} |
字段
| 字段 | 类型 | 说明 |
|---|---|---|
blocks |
std::vector< int > blocks |
脏块闭包(需提供 DecompositionReport;按 solve_order 排列, 增量求解直接依序重解;未提供分解时为空) |
components |
std::vector< int > components |
受影响连通分量编号(升序) |
constraints |
std::vector< constraints |
受影响约束(模型声明序) |
entities |
std::vector< entities |
受影响实体(含变更源,模型声明序) |
full_rebuild |
bool full_rebuild |
结构性变更:块结构失效 → 全量重解 |
vdcs::DofAnalyzer
头文件: include/vdcs/core/dof_analyzer.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Analyze |
static DofReport vdcs::DofAnalyzer::Analyze(const Model &model) |
分析(内部构建约束图) |
Analyze |
static DofReport vdcs::DofAnalyzer::Analyze(const Model &model, const ConstraintGraph &graph) |
分析(复用已构建的约束图) |
Analyze |
static DofReport vdcs::DofAnalyzer::Analyze(const Model &model, std::vector< ParamSlot > excluded) |
分析(带诊断参数排除集,g39——上游 pdrivenlist 同构)。 排除槽不占 DOF(mobility/residual_dof 扣减)、不进秩校验 雅可比列;求解行为不受影响。上游语义:被驱动参数由其他 参数决定(driven Equal 族 param2),诊断时从 pdiagnoselist 排除防 DOF 虚报;全参数被排除的分量 mobility 归 0(上游 plist − pdrivenlist == 0 → dofs = 0 同口径) |
vdcs::DofReport
全模型 DOF 分析报告
头文件: include/vdcs/core/dof_analyzer.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
FullyConstrained |
bool vdcs::DofReport::FullyConstrained() const |
所有分量名义完整且无秩亏损 |
HasRedundancy |
bool vdcs::DofReport::HasRedundancy() const |
任一分量存在雅可比秩亏损(冗余/冲突) |
TotalMobility |
int vdcs::DofReport::TotalMobility() const |
Σ 分量 mobility(各分量独立携带刚体模态) |
字段
| 字段 | 类型 | 说明 |
|---|---|---|
components |
std::vector< components |
{待补充} |
vdcs::DogLegSolver
头文件: include/vdcs/core/dogleg_solver.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Solve |
static Result< SolveReport > vdcs::DogLegSolver::Solve(Model &model, const SolveOptions &options) |
对模型求解;成功时参数已写回实体。 需要模型无 NaN/Inf 参数;空模型返回 kEmptyModel。 |
vdcs::DogLegStrategy
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
const char * vdcs::DogLegStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
vdcs::DragController
头文件: include/vdcs/core/drag_controller.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Active |
bool vdcs::DragController::Active() const |
{待补充} |
Begin |
Result< void > vdcs::DragController::Begin(Model &model, Uid entity) |
开始拖拽。未激活时调用;entity 须为已存在的中心寻址实体 (Point2D 或圆/弧/椭圆族——拖拽语义 = 拖中心/顶点);g123 扩 3D 位置优先实体(Point3D/Sphere3D——前三维即位置/球心, Move3D 全维跟手;Line3D/Plane3D/Cylinder3D 方向优先与 RigidBody 位姿切坐标拒绝,同无限线 (φ,d) 理由) |
Cancel |
Result< void > vdcs::DragController::Cancel() |
异常路径:移除钉扎 + 回滚 Begin 快照(不求解) |
DragController |
vdcs::DragController::DragController()=default |
{待补充} |
DragController |
vdcs::DragController::DragController(const DragController &)=delete |
{待补充} |
DraggedEntity |
Uid vdcs::DragController::DraggedEntity() const |
被拖实体 UID(注意:不可命名 Entity()——会遮蔽类型名 vdcs::Entity) |
End |
Result< SolveReport > vdcs::DragController::End(const SolveOptions &options=SolveOptions()) |
结束拖拽:移除钉扎 + 分解式终解(子树外块不动)。返回终解报告 |
Move |
Result< SolveReport > vdcs::DragController::Move(double x, double y, const SolveOptions &options=SolveOptions()) |
拖拽至目标点:钉扎参考更新 + 脏块增量重解。返回求解报告; 未激活 / 目标非有限值 → 错误 |
Move3D |
Result< SolveReport > vdcs::DragController::Move3D(double x, double y, double z, const SolveOptions &options=SolveOptions()) |
g123:3D 拖拽至目标点(Point3D/Sphere3D 等前三维为位置的实体)。 与 Move 同款钉扎/直写/增量路径,前三维跟手、其余维 hold;对 2D 实体(Dof < 3)拒绝。Move(x,y) 对 3D 实体 = 平面拖拽语义 (z 钉 Begin 值),与 Move3D 全维跟手互补 |
PinConstraint |
Uid vdcs::DragController::PinConstraint() const |
临时钉扎约束 UID(会话期间有效;宿主诊断/过滤用) |
SubtreeEntities |
const std::vector< Uid > & vdcs::DragController::SubtreeEntities() const |
拖拽优先级子树(P5-S4-02):被拖实体所在块 + 依赖它的下游块 实体全集(Begin 时计算)——拖拽波及范围,宿主渲染高亮/预览用; 子树外的实体在 Move 中保持不动 |
vdcs::ExprNode
头文件: include/vdcs/core/expression.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
node |
std::variant< node |
{待补充} |
vdcs::Expression
头文件: include/vdcs/core/expression.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Evaluate |
Result< double > vdcs::Expression::Evaluate(const std::unordered_map< std::string, double > &vars) const |
求值。vars 为变量名 → 值快照,本函数只读。 |
Expression |
vdcs::Expression::Expression()=default |
{待补充} |
Expression |
vdcs::Expression::Expression(Expression &&)=default |
{待补充} |
Expression |
vdcs::Expression::Expression(const Expression &)=delete |
{待补充} |
Parse |
static Result< Expression > vdcs::Expression::Parse(std::string_view text) |
解析表达式文本(move-only 类型,Result 按值搬运) |
References |
const std::vector< std::string > & vdcs::Expression::References() const |
引用的变量名(出现序去重;用于依赖拓扑与环检测) |
ToText |
std::string vdcs::Expression::ToText() const |
规范文本形式(优先级感知打印,AST 不保留源码文本——序列化用)。 与 Parse 语义 roundtrip 等价:Parse(ToText(e)) 重建结构相同的 AST (浮点求值顺序不变,结果 bit 级一致),且 ToText 幂等。 数字采用 to_chars 最短往返表示。 |
vdcs::IncrementalSolver
头文件: include/vdcs/core/incremental.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Solve |
static Result< SolveReport > vdcs::IncrementalSolver::Solve(Model &model, const DecompositionReport &decomp, const ChangeSet &changes, const SolveOptions &options=SolveOptions()) |
{待补充} |
vdcs::IncrementalStrategy
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
IncrementalStrategy |
vdcs::IncrementalStrategy::IncrementalStrategy(const DecompositionReport &decomp, ChangeSet changes) |
{待补充} |
Name |
const char * vdcs::IncrementalStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
vdcs::MultiStartSolver
头文件: include/vdcs/core/multi_start_solver.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
InnerSolve |
using vdcs::MultiStartSolver::InnerSolve = Result<SolveReport> (*)(Model&, const SolveOptions&) |
被包装求解器的静态入口签名 |
Solve |
static Result< SolveReport > vdcs::MultiStartSolver::Solve(Model &model, const SolveOptions &options, const Options &ms) |
对模型求解;成功时参数已写回实体。 SolveReport.restarts_used 指示成功前重启次数(0 = 首解即收敛; 全败时 = restarts)。iterations 为成功(或最后一次)尝试的迭代数。 |
vdcs::MultiStartSolver::Options
头文件: include/vdcs/core/multi_start_solver.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
inner |
inner |
被包装求解器(必填,null → kInvalidInput) |
restarts |
int restarts |
首解失败后的额外重启次数(0 = 等价单次调用) |
seed |
unsigned int seed |
重启扰动 RNG 种子(固定 → 可复现) |
sigma |
double sigma |
扰动尺度:v += |v|·N(0,sigma) + sigma·N(0,sigma) (与 vdcs_bench perturb 口径一致:相对+绝对混合噪声) |
vdcs::NewtonSolver
头文件: include/vdcs/core/newton_solver.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Solve |
static Result< SolveReport > vdcs::NewtonSolver::Solve(Model &model, const SolveOptions &options) |
对模型求解;成功时参数已写回实体 |
vdcs::NumberExpr
头文件: include/vdcs/core/expression.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
value |
double value |
{待补充} |
vdcs::ParallelDecomposedStrategy
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
const char * vdcs::ParallelDecomposedStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
ParallelDecomposedStrategy |
vdcs::ParallelDecomposedStrategy::ParallelDecomposedStrategy(int num_threads=0) |
{待补充} |
vdcs::ParamSlot
参数槽标识(entity 的第 slot 个参数,slot ∈ [0, 实体 Dof))
头文件: include/vdcs/core/dof_analyzer.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
entity |
entity |
{待补充} |
slot |
int slot |
{待补充} |
vdcs::SolveContext
头文件: include/vdcs/core/solve_context.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
DofOf |
int vdcs::SolveContext::DofOf(Uid entity) const |
实体 DOF;未携带 DOF 表时返回 -1(局部雅可比不可用) |
Geometry |
const IGeometryAdapter * vdcs::SolveContext::Geometry() const |
外部几何适配器(宿主曲线求值);未注入返回 nullptr |
HasDofTable |
bool vdcs::SolveContext::HasDofTable() const |
{待补充} |
OffsetOf |
int vdcs::SolveContext::OffsetOf(Uid entity) const |
{待补充} |
Offsets |
const std::unordered_map< Uid, int > & vdcs::SolveContext::Offsets() const |
{待补充} |
ParamsOf |
const double * vdcs::SolveContext::ParamsOf(Uid entity) const |
返回实体参数区起点指针(长度 = 实体 Dof())。 实体不在偏移表 = 调用方装配错误(如测试上下文缺实体), at() 抛出可诊断异常而非解引用 end() 迭代器(UB/崩溃) |
SolveContext |
vdcs::SolveContext::SolveContext()=default |
{待补充} |
SolveContext |
vdcs::SolveContext::SolveContext(const double *params, int total_params, const std::unordered_map< Uid, int > &offsets, const std::unordered_map< Uid, int > *dofs=nullptr, const IGeometryAdapter *geometry=nullptr) |
{待补充} |
TotalParams |
int vdcs::SolveContext::TotalParams() const |
{待补充} |
WithLocalColumns |
SolveContext vdcs::SolveContext::WithLocalColumns(const std::unordered_map< Uid, int > & col_offsets, int local_cols) const |
构造局部列映射视图:col_offsets 为实体 → 局部列号(非拥有引用,g231——映射表生命周期由调用方保证), local_cols 为局部列总数;参数/DOF 表共享自本上下文 |
vdcs::SolveDiagnostics
头文件: include/vdcs/core/diagnostic.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Build |
static SolveResult vdcs::SolveDiagnostics::Build(const SolveReport &report, const DofReport &dof) |
融合生成结构化诊断(纯函数,不求解不修改模型): |
| 过约束分量 → Error(kOverConstrained) + 逐约束候选冗余 | ||
| 秩亏分量(含隐藏冗余)→ Warning(kRedundantConstraint) 逐约束候选 | ||
| 欠约束分量 → Warning(kUnderConstrained) | ||
| 未收敛 → Error(kNotConverged);残差停滞 → Error(kStalled) | ||
| status:秩亏/过约束 → kInconsistent;未收敛 → kNotConverged; 否则 kSolved(欠约束但仍收敛视为 Solved + 提示) | ||
Build |
static SolveResult vdcs::SolveDiagnostics::Build(const SolveReport &report, const DofReport &dof, const DecompositionReport &decomp) |
结构诊断融合(P2-S4-02):以 DM 分解报告为结构定位源—— |
| 过约束块 → Error(kOverConstrained) 块级摘要 + 逐约束精确定位: 收敛(一致冗余,无害)→ Warning(kRedundantConstraint); 未收敛(矛盾,不可满足)→ Error(kConflictingConstraint) | ||
| 欠约束块 → Warning(kUnderConstrained) 块级摘要 + 逐实体精确定位 (块内实体即携带结构自由度的实体) | ||
| 数值秩亏(隐藏冗余)仍由 DofReport 检测,逐约束候选与结构 诊断按 UID 去重(同一约束不重复报告) | ||
| structural_redundancy = total_removed_dof − matched_dof | ||
FromJson |
static Result< SolveResult > vdcs::SolveDiagnostics::FromJson(const std::string &json) |
反序列化;JSON 不合法或结构不符返回 kInvalidInput |
ToJson |
static std::string vdcs::SolveDiagnostics::ToJson(const SolveResult &result) |
JSON 序列化(供宿主 UI/日志消费) |
ToString |
static const char * vdcs::SolveDiagnostics::ToString(DiagnosticLevel level) |
枚举 ↔ 稳定字符串(序列化格式,蛇形命名) |
ToString |
static const char * vdcs::SolveDiagnostics::ToString(DiagnosticCode code) |
{待补充} |
ToString |
static const char * vdcs::SolveDiagnostics::ToString(SolveStatus status) |
{待补充} |
vdcs::SolveOptions
求解选项
头文件: include/vdcs/core/newton_solver.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
initial_damping |
double initial_damping |
LM 起始阻尼 λ |
max_iterations |
int max_iterations |
最大迭代次数 |
progress |
progress |
进度回调(可选,09-API §8:进度显示与诊断;空 = 无开销) |
tolerance |
double tolerance |
残差无穷范数收敛阈值 |
vdcs::SolveProgress
头文件: include/vdcs/core/newton_solver.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
block_count |
int block_count |
分解路径:子块总数 |
block_index |
int block_index |
分解路径:当前子块序号 |
converged |
bool converged |
当前状态是否已收敛 |
iteration |
int iteration |
已完成迭代数(0 = 初始状态) |
lm_mode |
bool lm_mode |
是否处于 LM 阻尼模式 |
residual_norm |
double residual_norm |
当前残差无穷范数 |
stalled |
bool stalled |
是否以停滞终止 |
vdcs::SolveReport
求解报告
头文件: include/vdcs/core/newton_solver.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
converged |
bool converged |
是否收敛 |
iterations |
int iterations |
实际迭代次数 |
jacobian_nnz |
int jacobian_nnz |
雅可比非零元数(稀疏求解器填充) |
mobility |
int mobility |
Grübler 可动自由度 M. |
removed_dof |
int removed_dof |
Σ约束消除DOF. |
residual_norm |
double residual_norm |
最终残差无穷范数 |
restarts_used |
int restarts_used |
多起点重启次数(g8:0 = 单次求解 即收敛/未启用;MultiStartSolver 填充) |
sparse |
bool sparse |
是否走了稀疏路径 |
stalled |
bool stalled |
以停滞终止(λ 饱和/步长耗尽仍未收敛) |
threads |
int threads |
参与求解的线程数(P4-S2-01 并行分解 路径 >1,串行路径恒 1;auto 模式按 工作量配额自适应,显式请求 = min(请求线程数, 最宽层块数)) |
total_dof |
int total_dof |
Σ实体DOF. |
used_lm |
bool used_lm |
是否触发了 LM 回退 |
vdcs::SolveResult
求解结果:P-05 数值报告 + P-03/P-09 DOF 摘要 + 诊断列表
头文件: include/vdcs/core/diagnostic.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
diagnostics |
std::vector< diagnostics |
{待补充} |
fully_constrained |
bool fully_constrained |
所有分量完整约束且无秩亏 |
has_redundancy |
bool has_redundancy |
任一分量雅可比秩亏 |
mobility |
int mobility |
Σ 分量 mobility(Grübler 计数) |
report |
report |
数值报告(迭代/残差/稀疏信息) |
residual_dof |
int residual_dof |
Σ 分量 residual_dof(含刚体模态) |
status |
status |
{待补充} |
structural_redundancy |
int structural_redundancy |
结构冗余量(P2-S4-02):total_removed_dof − matched_dof (DM 最大匹配口径的不可消解方程数;0 = 结构无冗余或未提供分解) |
vdcs::SolverStrategy
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
virtual const char * vdcs::SolverStrategy::Name() const =0 |
策略名(诊断/日志标识,静态字符串) |
SolveModel |
Result< SolveReport > vdcs::SolverStrategy::SolveModel(Model &model, const SolveOptions &options=SolveOptions()) |
统一求解入口(模板方法,见类注释) |
vdcs::SparseLmSolver
头文件: include/vdcs/core/sparse_lm_solver.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Solve |
static Result< SolveReport > vdcs::SparseLmSolver::Solve(Model &model, const SolveOptions &options) |
对模型求解;成功时参数已写回实体。 需要模型无 NaN/Inf 参数;空模型返回 kEmptyModel。 |
vdcs::SparseLmStrategy
稀疏 LM(大模型:三元组稀疏雅可比 + SimplicialLDLT)
头文件: include/vdcs/core/solver_strategy.h
方法
| 方法 | 签名 | 说明 |
|---|---|---|
Name |
const char * vdcs::SparseLmStrategy::Name() const override |
策略名(诊断/日志标识,静态字符串) |
vdcs::UnaryExpr
一元运算('+' / '-';优先级低于幂 → -2^2 = -(2^2) = -4)
头文件: include/vdcs/core/expression.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
op |
char op |
{待补充} |
operand |
operand |
{待补充} |
vdcs::VariableExpr
头文件: include/vdcs/core/expression.h
字段
| 字段 | 类型 | 说明 |
|---|---|---|
name |
std::string name |
{待补充} |