lingshu-solver 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +101 -206
- package/README.md +7 -1
- package/index.html +49 -2
- package/package.json +3 -3
- package/LICENSE.md +0 -53
package/LICENSE
CHANGED
|
@@ -1,206 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works.
|
|
111
|
-
|
|
112
|
-
You may add Your own copyright statement to Your modifications and
|
|
113
|
-
may provide additional or different license terms and conditions
|
|
114
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
115
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
116
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
117
|
-
the conditions stated in this License.
|
|
118
|
-
|
|
119
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
120
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
121
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
122
|
-
this License, without any additional terms or conditions.
|
|
123
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
124
|
-
the terms of any separate license agreement you may have executed
|
|
125
|
-
with Licensor regarding such Contributions.
|
|
126
|
-
|
|
127
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
128
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
129
|
-
except as required for reasonable and customary use in describing the
|
|
130
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
131
|
-
|
|
132
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
133
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
134
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
135
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
136
|
-
implied, including, without limitation, any warranties or conditions
|
|
137
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
138
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
139
|
-
appropriateness of using or redistributing the Work and assume any
|
|
140
|
-
risks associated with Your exercise of permissions under this License.
|
|
141
|
-
|
|
142
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
143
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
144
|
-
unless required by applicable law (such as deliberate and grossly
|
|
145
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
146
|
-
liable to You for damages, including any direct, indirect, special,
|
|
147
|
-
incidental, or consequential damages of any character arising as a
|
|
148
|
-
result of this License or out of the use or inability to use the
|
|
149
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
150
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
151
|
-
other commercial damages or losses), even if such Contributor
|
|
152
|
-
has been advised of the possibility of such damages.
|
|
153
|
-
|
|
154
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
155
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
156
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
157
|
-
or other liability obligations and/or rights consistent with this
|
|
158
|
-
License. However, in accepting such obligations, You may act only
|
|
159
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
160
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
161
|
-
defend, and hold each Contributor harmless for any liability
|
|
162
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
163
|
-
of your accepting any such warranty or additional liability.
|
|
164
|
-
|
|
165
|
-
END OF TERMS AND CONDITIONS
|
|
166
|
-
|
|
167
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
168
|
-
|
|
169
|
-
To apply the Apache License to your work, attach the following
|
|
170
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
171
|
-
replaced with your own identifying information. (Don't include
|
|
172
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
173
|
-
comment syntax for the file format. We also recommend that a
|
|
174
|
-
file or class name and description of purpose be included on the
|
|
175
|
-
same "printed page" as the copyright notice for easier
|
|
176
|
-
identification within third-party archives.
|
|
177
|
-
|
|
178
|
-
Copyright [yyyy] [name of copyright owner]
|
|
179
|
-
|
|
180
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
-
you may not use this file except in compliance with the License.
|
|
182
|
-
You may obtain a copy of the License at
|
|
183
|
-
|
|
184
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
-
|
|
186
|
-
Unless required by applicable law or agreed to in writing, software
|
|
187
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
-
See the License for the specific language governing permissions and
|
|
190
|
-
limitations under the License.
|
|
191
|
-
|
|
192
|
-
----------------------------------------------------------------------------
|
|
193
|
-
|
|
194
|
-
Copyright 2026 广州OPC(红尘灵境)
|
|
195
|
-
|
|
196
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
197
|
-
you may not use this file except in compliance with the License.
|
|
198
|
-
You may obtain a copy of the License at
|
|
199
|
-
|
|
200
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
201
|
-
|
|
202
|
-
Unless required by applicable law or agreed to in writing, software
|
|
203
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
204
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
205
|
-
See the License for the specific language governing permissions and
|
|
206
|
-
limitations under the License.
|
|
1
|
+
灵数求解器 (LingShu Solver) 商业授权许可协议
|
|
2
|
+
LingShu Solver Commercial License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2026 红尘灵境数字科技有限公司 / 太白(邓其聪).
|
|
5
|
+
版权所有,保留一切权利。All rights reserved.
|
|
6
|
+
|
|
7
|
+
--------------------------------------------------------------------------------
|
|
8
|
+
一、著作权与权利保留
|
|
9
|
+
--------------------------------------------------------------------------------
|
|
10
|
+
本软件(包括但不限于源代码、目标代码、二进制文件、文档及随附资料,以下简称
|
|
11
|
+
"本软件")的著作权及相关知识产权均归上述版权方(以下简称"版权方")所有。
|
|
12
|
+
除本协议明确授予的有限许可外,任何权利(包括但不限于复制、修改、分发、再许可、
|
|
13
|
+
出租、出借、商业使用、制作衍生作品之权利)均由版权方保留。
|
|
14
|
+
|
|
15
|
+
--------------------------------------------------------------------------------
|
|
16
|
+
二、非商业性使用(免费)
|
|
17
|
+
--------------------------------------------------------------------------------
|
|
18
|
+
在同时满足下列全部条件的"非商业性使用"范围内,版权方免费授予您一项非独占、
|
|
19
|
+
不可转让、可随时撤销的使用许可:
|
|
20
|
+
1. 个人学习、研究、教学或技术评测;
|
|
21
|
+
2. 非营利组织、开源社区或教育机构的内部非营利用途;
|
|
22
|
+
3. 年营业收入不超过人民币 100 万元的团队,将本软件仅用于内部评估,且同时
|
|
23
|
+
运行的实例数不超过 3 个。
|
|
24
|
+
上述许可的前提条件:
|
|
25
|
+
(a) 您须在每一份副本或任何实质性部分中完整保留本版权声明与许可声明;
|
|
26
|
+
(b) 未经版权方书面同意,不得移除、遮挡或篡改本软件中的任何版权、商标或
|
|
27
|
+
许可标识;
|
|
28
|
+
(c) 为互操作性所必须的法定反向工程情形除外,您不得对本软件进行反向工程、
|
|
29
|
+
反编译或反汇编。
|
|
30
|
+
|
|
31
|
+
--------------------------------------------------------------------------------
|
|
32
|
+
三、商业使用(须事先取得书面授权)
|
|
33
|
+
--------------------------------------------------------------------------------
|
|
34
|
+
任何"商业使用"均须事先取得版权方签署的书面《商业授权协议》(Commercial
|
|
35
|
+
License),未获书面授权一律禁止。商业使用包括但不限于:
|
|
36
|
+
- 将本软件用于任何以营利为目的的产品、服务或业务;
|
|
37
|
+
- 通过 SaaS、云部署、API 或任何其他方式,向第三方提供基于本软件的能力
|
|
38
|
+
(无论是否收费);
|
|
39
|
+
- 将本软件集成、嵌入或捆绑进任何商业发行物、设备或解决方案;
|
|
40
|
+
- 对本软件进行再分发、转授权或对外提供托管;
|
|
41
|
+
- 任何超出第二条"非商业性使用"范围的使用。
|
|
42
|
+
未经书面授权的任何商业使用均构成对版权的侵权,版权方保留依法追究全部法律
|
|
43
|
+
责任(包括但不限于停止侵权、损害赔偿及诉讼费用)的权利。
|
|
44
|
+
|
|
45
|
+
--------------------------------------------------------------------------------
|
|
46
|
+
四、获取商业授权
|
|
47
|
+
--------------------------------------------------------------------------------
|
|
48
|
+
商业授权申请与商务合作,请通过以下渠道联系版权方:
|
|
49
|
+
联系人:红尘灵境数字科技有限公司 / 太白(邓其聪)
|
|
50
|
+
邮箱:553420544@qq.com
|
|
51
|
+
仓库:https://github.com/genesis-plan/lingshu-solver(Issues 亦可用于商务咨询)
|
|
52
|
+
授权范围、地域、期限与费用以双方签署的书面协议为准。
|
|
53
|
+
|
|
54
|
+
--------------------------------------------------------------------------------
|
|
55
|
+
五、商标与品牌
|
|
56
|
+
--------------------------------------------------------------------------------
|
|
57
|
+
"灵数 / 灵数求解器 / LingShu Solver" 及相关名称、标识为版权方的商标或商号。
|
|
58
|
+
本协议不授予任何商标使用权。未经书面许可,您不得使用上述名称、标识进行任何
|
|
59
|
+
宣传或背书。
|
|
60
|
+
|
|
61
|
+
--------------------------------------------------------------------------------
|
|
62
|
+
六、无担保与责任限制
|
|
63
|
+
--------------------------------------------------------------------------------
|
|
64
|
+
本软件按"现状"提供,不提供任何明示或默示担保(包括但不限于对适销性、
|
|
65
|
+
特定用途适用性及不侵权的担保)。在任何情况下,无论基于合同、侵权或其他法
|
|
66
|
+
理,版权方均不对因使用或无法使用本软件所产生的任何直接、间接、附带、特殊
|
|
67
|
+
或后果性损害承担责任。
|
|
68
|
+
|
|
69
|
+
--------------------------------------------------------------------------------
|
|
70
|
+
七、终止
|
|
71
|
+
--------------------------------------------------------------------------------
|
|
72
|
+
若您违反本协议任何条款,本许可自动终止。终止后您须立即停止使用本软件,并
|
|
73
|
+
销毁所持有的全部副本(包括任何备份与衍生作品)。
|
|
74
|
+
|
|
75
|
+
--------------------------------------------------------------------------------
|
|
76
|
+
八、适用法律
|
|
77
|
+
--------------------------------------------------------------------------------
|
|
78
|
+
本协议受中华人民共和国法律管辖,并按其解释。因本协议产生的争议,提交版权
|
|
79
|
+
方所在地有管辖权的人民法院诉讼解决。
|
|
80
|
+
|
|
81
|
+
--------------------------------------------------------------------------------
|
|
82
|
+
九、版本适用范围(重要)
|
|
83
|
+
--------------------------------------------------------------------------------
|
|
84
|
+
自 lingshu-solver@1.0.4 起的版本适用本协议。更早版本(含 1.0.3 及此前)曾
|
|
85
|
+
以 Apache License 2.0 发布,该等已发布版本继续按其发布时随附的 Apache
|
|
86
|
+
License 2.0 条款提供,此为历史事实且不可撤回;但其不延伸适用于本协议生效
|
|
87
|
+
后的任何新版本。
|
|
88
|
+
|
|
89
|
+
--------------------------------------------------------------------------------
|
|
90
|
+
英文摘要 / English Summary
|
|
91
|
+
--------------------------------------------------------------------------------
|
|
92
|
+
Copyright (c) 2026 红尘灵境数字科技有限公司 / 太白(邓其聪). All rights reserved.
|
|
93
|
+
This software is NOT open source and NOT free for commercial use. Non-commercial
|
|
94
|
+
use (personal study, research, non-profit / educational internal use, or limited
|
|
95
|
+
internal evaluation within a small low-revenue team) is permitted free of charge
|
|
96
|
+
subject to retaining this notice. ANY commercial use requires a prior written
|
|
97
|
+
Commercial License from the copyright holder. Unauthorized commercial use is
|
|
98
|
+
prohibited and constitutes copyright infringement. This license applies to
|
|
99
|
+
lingshu-solver@1.0.4 and later; earlier versions remain under the Apache License
|
|
100
|
+
2.0 as originally distributed. Provided "AS IS" without warranty; liability is
|
|
101
|
+
excluded to the maximum extent permitted by law.
|
package/README.md
CHANGED
|
@@ -229,4 +229,10 @@ node test/verify_compliance.js # 输入门禁专项(20 例)
|
|
|
229
229
|
|
|
230
230
|
## 许可
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
**非商业免费 + 商业须书面授权**(自有《灵数求解器商业授权许可协议》,非开源协议):
|
|
233
|
+
|
|
234
|
+
- **非商业用途免费**:个人学习/研究/教学/评测,非营利组织与教育机构内部使用,小团队(年营收 ≤100 万元)内部评估(≤3 实例)。
|
|
235
|
+
- **商业用途须事先取得书面授权**:任何以营利为目的的产品/服务/业务、SaaS/云/API 转售、集成嵌入、再分发托管,均须联系版权方(553420544@qq.com)取得《商业授权协议》。
|
|
236
|
+
- **版本适用**:1.0.4 起适用本协议;1.0.3 及更早版本按其发布时的 Apache License 2.0 提供(历史事实,不可撤回,但不延伸至新版本)。
|
|
237
|
+
|
|
238
|
+
完整条款见 [LICENSE](./LICENSE)。
|
package/index.html
CHANGED
|
@@ -5833,6 +5833,9 @@ function suan22(state) {
|
|
|
5833
5833
|
_walk1(_eq);
|
|
5834
5834
|
})();
|
|
5835
5835
|
if (_lo < _hi) {
|
|
5836
|
+
var _dense = false; // 修3:根稠密/超时提前终止扫描(防宽域周期方程穷举挂起)
|
|
5837
|
+
var _denseByCount = false; // 修3:仅由"根数超阈值"触发的稠密标记(用于无限/截断判定,区别于超时触发)
|
|
5838
|
+
var _denseNonPeriodic = false; // 修3:非周期稠密截断标记(与 periodic→无限 分支互补)
|
|
5836
5839
|
// ---- 周期感知步长(issue A 修复 2026-09-01):高频/多周期方程用 < 周期/2 的网格,
|
|
5837
5840
|
// 确保不漏根;非周期方程回退到 4096 点默认细网格。点数上限 _NMAX 护栏防宽域爆炸。 ----
|
|
5838
5841
|
var _P = _detectPeriod1D(_eq, _vn);
|
|
@@ -5902,8 +5905,11 @@ function suan22(state) {
|
|
|
5902
5905
|
_recScanInterval(_eq, _vn, _gxP, _gx, state, allSolutions, resultVarNames, 0);
|
|
5903
5906
|
}
|
|
5904
5907
|
}
|
|
5908
|
+
if (allSolutions.length > 200) { _dense = true; _denseByCount = true; break; }
|
|
5909
|
+
if ((performance.now() - state.startTime) > 1500) { _dense = true; break; }
|
|
5905
5910
|
_gxP = _gx; _gfP = _gf;
|
|
5906
5911
|
}
|
|
5912
|
+
if (_dense) break;
|
|
5907
5913
|
// 终止端点若有根也记录
|
|
5908
5914
|
if (_gfP !== null && Math.abs(_gfP) < 1e-7) {
|
|
5909
5915
|
var _fbV = reconstructSolution(state, [_B]).map(roundToGrid);
|
|
@@ -5951,6 +5957,31 @@ function suan22(state) {
|
|
|
5951
5957
|
if (_dedupMap[_mi]) mergedSolutions.push(_dedupMap[_mi]);
|
|
5952
5958
|
}
|
|
5953
5959
|
|
|
5960
|
+
// 修3(2026-09-04):稠密根防护——单变量周期方程在宽域内根稠密,
|
|
5961
|
+
// 继续穷举既耗时(曾致 solve 挂起 >110s)又产出无用的海量解集。
|
|
5962
|
+
// 含周期函数且根数超阈值 ⇒ 解集实际为无限(周期平移),如实标 rt=3 无限解集(代表解);
|
|
5963
|
+
// 非周期但稠密(如高次多项式)⇒ 不谎称无限,置 truncated 并后续告警,诚实返回部分代表根。
|
|
5964
|
+
if (_denseByCount) {
|
|
5965
|
+
if (_P !== null) {
|
|
5966
|
+
state.done = true;
|
|
5967
|
+
state.result = {
|
|
5968
|
+
solutions: mergedSolutions,
|
|
5969
|
+
error: null,
|
|
5970
|
+
message: "单变量周期方程在声明域内出现大量(>" + 200 + ")孤立根,呈周期性稠密分布,解集实际为无限(如 x = x₀ + k·" + _P.toFixed(4) + ")。已给出 " + mergedSolutions.length + " 个代表根;如需有限个解请收窄变量定义域。",
|
|
5971
|
+
executionPath: "单变量稠密周期根判定(无限解集)",
|
|
5972
|
+
timeMs: performance.now() - state.startTime,
|
|
5973
|
+
confidence: "high",
|
|
5974
|
+
varNames: resultVarNames,
|
|
5975
|
+
resultType: 3,
|
|
5976
|
+
resultTypeName: "无限解集(代表解)",
|
|
5977
|
+
resultTypeDesc: "周期方程在宽域内根稠密,解集为周期平移的无穷集合,已给出代表根"
|
|
5978
|
+
};
|
|
5979
|
+
return;
|
|
5980
|
+
}
|
|
5981
|
+
state.truncated = true; // 非周期稠密:诚实截断(避免海量/不完整解集),下方 domainFiltered 产出部分代表根
|
|
5982
|
+
_denseNonPeriodic = true;
|
|
5983
|
+
}
|
|
5984
|
+
|
|
5954
5985
|
// 2) 原始方程回代验证:对每组候选解,代入全部原始方程重新计算残差
|
|
5955
5986
|
// 二分查找得到的解(_bisect=true)跳过残差验证(区间收敛保证精度)
|
|
5956
5987
|
var _origEqs = state.originalEquations || state.equations;
|
|
@@ -6082,6 +6113,12 @@ function suan22(state) {
|
|
|
6082
6113
|
}
|
|
6083
6114
|
}
|
|
6084
6115
|
}
|
|
6116
|
+
// 修3:非周期稠密截断告警(与上方 periodic→无限 分支互补)
|
|
6117
|
+
if (_denseNonPeriodic && state.result) {
|
|
6118
|
+
state.result.warnings = (state.result.warnings || []).concat([
|
|
6119
|
+
"方程在声明域内根数量过多(>" + 200 + "),已截断扫描;结果不完整,缩小变量范围或确认方程规模可获完整解集。"
|
|
6120
|
+
]);
|
|
6121
|
+
}
|
|
6085
6122
|
}
|
|
6086
6123
|
}
|
|
6087
6124
|
|
|
@@ -6624,7 +6661,13 @@ function _affineEval(ast, env) {
|
|
|
6624
6661
|
// 超越函数降级:仿射自变量 → 保守区间函数包围(复用 _rangeEval,无递归环)
|
|
6625
6662
|
var tmp = { type: 'func', name: ast.name, arg: { type: 'var', name: '__a' } };
|
|
6626
6663
|
var rv = _rangeEval(tmp, { __a: iv });
|
|
6627
|
-
|
|
6664
|
+
if (!rv || !isFinite(rv.min) || !isFinite(rv.max)) return null; // 含 ±Inf:交还 _rangeEval 直接给出保守区间
|
|
6665
|
+
// 关键修复(P0-2):旧实现 return _Aff((rv.min+rv.max)/2, {}) 把合法区间宽度丢成 0,
|
|
6666
|
+
// 致 intervalEval(sin x)@[-2,2] 塌成 [0,0](unsound:真值须含 [-1,1])。
|
|
6667
|
+
// 正确做法:用半径 (rv.max-rv.min)/2 的噪声符号把 rv 完整编码为仿射,
|
|
6668
|
+
// 使 _affToInterval 还原为 [rv.min, rv.max](sound 且紧致),Krawczyk 雅可比随之可信。
|
|
6669
|
+
var e = {}; e[_affSym++] = (rv.max - rv.min) / 2;
|
|
6670
|
+
return _Aff((rv.min + rv.max) / 2, e);
|
|
6628
6671
|
}
|
|
6629
6672
|
if (ast.type === 'unary') {
|
|
6630
6673
|
var u = _affineEval(ast.operand, env);
|
|
@@ -11378,7 +11421,11 @@ function _newtonRefine(eqs, vns, x0, box) {
|
|
|
11378
11421
|
var F = []; for (var e = 0; e < n; e++) { var fe = evalAST(eqs[e], vmap); if (!isFinite(fe)) return null; F.push(fe); }
|
|
11379
11422
|
var rms = 0; for (var i2 = 0; i2 < n; i2++) rms += F[i2] * F[i2]; rms = Math.sqrt(rms / n);
|
|
11380
11423
|
if (rms < 1e-11) return x;
|
|
11381
|
-
|
|
11424
|
+
// 雅可比区间求导:必须喂退化的点区间 {min:x,max:x}(而非裸点值)。
|
|
11425
|
+
// 旧实现 intervalEval(d, vmap) 把裸数当 iv,iv.min/iv.max 为 undefined → _buildAffEnv 算出 NaN 噪声
|
|
11426
|
+
// → 雅可比整行 NaN → realMatInv 失败 → 本函数对一切良置问题恒返 null(P0-1)。
|
|
11427
|
+
var pmap = {}; for (var i3 = 0; i3 < n; i3++) pmap[vns[i3]] = { min: x[i3], max: x[i3] };
|
|
11428
|
+
var J = []; for (var a = 0; a < n; a++) { J.push([]); for (var b = 0; b < n; b++) { var d = _diffAST(eqs[a], vns[b]); var dv = intervalEval(d, pmap); if (!dv) return null; J[a].push((dv.min + dv.max) / 2); } }
|
|
11382
11429
|
var Y = realMatInv(J); if (!Y) return null;
|
|
11383
11430
|
var dX = rMatVec(Y, F);
|
|
11384
11431
|
for (var j = 0; j < n; j++) x[j] = x[j] - dX[j];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lingshu-solver",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "灵数求解器 · 确定性实数方程组求解 MCP 工具(≤6变量):区间收缩 + Krawczyk 认证,离线零依赖零数据,诚实标记 truncated。",
|
|
5
5
|
"homepage": "https://genesis-plan.github.io/lingshu-solver/",
|
|
6
6
|
"repository": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/genesis-plan/lingshu-solver/issues"
|
|
12
12
|
},
|
|
13
|
-
"license": "
|
|
13
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
14
14
|
"keywords": [
|
|
15
15
|
"mcp",
|
|
16
16
|
"math",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"start": "node mcp-server.js",
|
|
53
|
-
"test": "node test/
|
|
53
|
+
"test": "node test/p0_fix_regression.js"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/LICENSE.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# 灵数求解器 软件许可协议(草稿 / DRAFT)
|
|
2
|
-
|
|
3
|
-
> ⚠️ **本文件为法律文件草稿,须经执业律师复核并定稿后方可采用。** 以下是文本模板与条款框架,不代表已生效的法律意见。
|
|
4
|
-
|
|
5
|
-
**软件名称**:灵数求解器(Lingshu Solver)
|
|
6
|
-
**著作权人**:红尘灵境数字科技有限公司(以下简称"权利人")
|
|
7
|
-
**版本**:本仓库当前版本
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 1. 许可授予
|
|
12
|
-
权利人在遵守本协议的条件下,授予使用者一项**有限的、非独占的、不可转让的、可撤销的**使用权,允许使用者:
|
|
13
|
-
1. 在自有设备上安装、运行本软件(包括但不限于单文件 HTML 形态);
|
|
14
|
-
2. 为内部研究、教学、工程计算目的使用本软件的输出结果;
|
|
15
|
-
3. 在保留本协议全部内容的前提下,复制并分发本软件的原始未修改副本。
|
|
16
|
-
|
|
17
|
-
## 2. 使用限制
|
|
18
|
-
未经权利人书面许可,使用者**不得**:
|
|
19
|
-
1. 对本软件进行反向工程、反编译或试图提取源代码(为互操作目的的法律例外除外);
|
|
20
|
-
2. 移除或遮盖本软件中的著作权、商标或许可声明;
|
|
21
|
-
3. 将本软件用于再许可、出租、托管为对外服务(SaaS)而未另行签约;
|
|
22
|
-
4. 将本软件或其输出用于**安全攸关(safety-critical)场景**(定义见第 6 条)。
|
|
23
|
-
|
|
24
|
-
## 3. 知识产权
|
|
25
|
-
本软件及其全部源代码、算法、文档、界面设计的著作权及相关知识产权均归权利人所有。本协议不授予任何明示或暗示的专利权许可。
|
|
26
|
-
|
|
27
|
-
## 4. 无担保(AS IS)
|
|
28
|
-
本软件按"现状"提供,**不附任何明示或暗示担保**,包括但不限于对**适销性、特定用途适用性、不侵权、结果准确性、结果完备性**的担保。权利人明确声明:
|
|
29
|
-
- 在给定计算预算内,本软件采用保守区间算术以尽量确保所有真解被包含于输出集合;
|
|
30
|
-
- 当计算资源(盒子数、分支预算、迭代次数)耗尽时,结果可能不完整,并将以 `truncated` / `UNKNOWN` 等状态字段显式标记;
|
|
31
|
-
- 使用者须自行验证输出是否满足其应用场景的精度与完备性要求。
|
|
32
|
-
|
|
33
|
-
## 5. 责任限制
|
|
34
|
-
在任何情况下,权利人对因使用或无法使用本软件所导致的**间接、偶然、特殊、后果性损害**(包括利润损失、数据损失、业务中断)不承担责任。权利人的累计赔偿责任不超过使用者为获取本软件所支付的对价(若免费获取,则上限为零)。
|
|
35
|
-
|
|
36
|
-
## 6. 禁止安全攸关用途
|
|
37
|
-
本软件**不得**用于任何安全攸关、生命健康、重大财产或公共利益攸关的场景,包括但不限于:
|
|
38
|
-
- 交通工具(汽车、航空、轨道交通)的控制或认证;
|
|
39
|
-
- 医疗器械、诊断或治疗决策;
|
|
40
|
-
- 工业控制系统、 nuclear/能源关键设施;
|
|
41
|
-
- 任何若结果错误可能导致人身伤害或重大损失的用途。
|
|
42
|
-
|
|
43
|
-
在上述场景中使用本软件,须改用经独立功能安全认证(如 ISO 26262 / IEC 61508)的专用版本,并取得权利人书面授权。在本协议签署时,**安全版本尚未通过前述认证**,故本条禁止具有现实约束力。
|
|
44
|
-
|
|
45
|
-
## 7. 终止
|
|
46
|
-
违反本协议任何条款,本许可自动终止,使用者须删除所有副本。
|
|
47
|
-
|
|
48
|
-
## 8. 适用法律与争议解决
|
|
49
|
-
本协议受中华人民共和国法律管辖。因本协议产生的争议,提交权利人所在地有管辖权的人民法院诉讼解决。
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
*草稿版本 v0.1 — 待执业律师复核。*
|