第210章 Attribute Vector|属性向量
从动态属性进入线性代数
第209章已经确定:
Dynamic Attribute
动态属性
↓
Method Parameter
方法参数
第210章进一步解决:
当一个 Object Instance 同时拥有多个动态属性时,如何把这些属性组织成一个可以进行数学计算的整体?
这里正式进入:
Dynamic Attributes
↓
Attribute Vector
↓
State Vector
↓
Mathematical Calculation
这一步非常关键,因为机器的行为不应该依赖:
if distance ...
if force ...
if pressure ...
if velocity ...
不断增加针对场景的固定判断。
而应该把当前对象的多个动态属性形成一个状态空间中的数学表示。
210.1 Attribute Vector|属性向量
假设一个 Object Instance 当前具有:
Position
位置
Velocity
速度
Force
力度
Pressure
压力
Stability
稳定度
Distance
距离
Orientation
方向
那么可以定义:
X(t)=[Position(t)Velocity(t)Force(t)Pressure(t)Stability(t)Distance(t)Orientation(t)]X(t)= \begin{bmatrix} Position(t)\\ Velocity(t)\\ Force(t)\\ Pressure(t)\\ Stability(t)\\ Distance(t)\\ Orientation(t) \end{bmatrix}
这个 X(t) 就是:
Attribute Vector|属性向量
它把原来分散的动态属性统一成为一个数学状态输入。
210.2 为什么需要向量
单独处理属性:
Position
Velocity
Force
Pressure
系统当然可以计算。
但真正的行为逻辑往往不是由一个属性决定,而是多个属性之间共同决定。
例如机械手接近鸡蛋:
Distance ↓
Velocity ↓
Pressure ↑
Force ↑
Stability →
这些变量之间存在关联。
因此需要从:
A1
A2
A3
A4
A5
...
转换为:
X
即:
X=[A1,A2,A3,…,An]TX=[A_1,A_2,A_3,\ldots,A_n]^T
这样 Method 就可以把整个当前状态作为数学输入。
210.3 Attribute Vector 与 State Vector
这里需要严格区分两个概念。
Attribute Vector|属性向量
表示:
当前对象拥有的动态属性集合。
例如:
A(t)=[PositionVelocityForcePressureStabilityDistanceOrientation]A(t)= \begin{bmatrix} Position\\ Velocity\\ Force\\ Pressure\\ Stability\\ Distance\\ Orientation \end{bmatrix}
State Vector|状态向量
表示:
经过状态定义或状态计算后,机器用于描述当前对象状态的数学向量。
可以表示为:
S(t)=F(A(t))S(t)=F(A(t))
也就是说:
Attribute Vector
属性向量
↓
State Mapping
状态映射
↓
State Vector
状态向量
在简单情况下:
S(t)=A(t)S(t)=A(t)
在复杂情况下:
S(t)=F(A(t))S(t)=F(A(t))
因此不能简单认为 Attribute 和 State 完全相同。
210.4 Position|位置
Position 本身通常不是一个标量。
在三维空间中:
P=[xyz]P= \begin{bmatrix} x\\ y\\ z \end{bmatrix}
例如:
Position
=
[x, y, z]
因此整个 State Vector 可能进一步展开:
S=[xyzvxvyvzFPressureStabilityDistanceOrientation]S= \begin{bmatrix} x\\ y\\ z\\ v_x\\ v_y\\ v_z\\ F\\ Pressure\\ Stability\\ Distance\\ Orientation \end{bmatrix}
这样机器当前面对的对象,就被表示成一个数学状态点。
210.5 Orientation|方向
Orientation 同样可以具有多个维度。
例如简化为:
O=[θxθyθz]O= \begin{bmatrix} \theta_x\\ \theta_y\\ \theta_z \end{bmatrix}
那么:
Position
+
Velocity
+
Orientation
本身就已经形成多个维度。
所以不能把所有 Attribute 简单理解成:
一个数字
更准确的是:
Scalar Attribute
标量属性
Vector Attribute
向量属性
最终再统一形成:
State Vector
210.6 Attribute Vector 的工程表示
PHP 中可以先采用最简单的数组表示:
$attributeVector = array(
'position' => array($x, $y, $z),
'velocity' => array($vx, $vy, $vz),
'force' => $force,
'pressure' => $pressure,
'stability' => $stability,
'distance' => $distance,
'orientation'=> array($ox, $oy, $oz)
);
它在数学上对应:
X =
[
Position,
Velocity,
Force,
Pressure,
Stability,
Distance,
Orientation
]
PHP 数组只是工程上的容器。
真正的数学意义来自这些数据之间的计算关系。
210.7 Vector Class|向量类
后续可以建立独立的:
Vector
向量类
例如:
class Vector
{
protected $values = array();
public function __construct($values = array())
{
$this->values = $values;
}
public function getValues()
{
return $this->values;
}
public function get($index)
{
return isset($this->values[$index])
? $this->values[$index]
: null;
}
}
然后:
$stateVector = new Vector(array(
$x,
$y,
$z,
$vx,
$vy,
$vz,
$force,
$pressure,
$stability,
$distance
));
这样:
State
↓
State Vector
↓
Vector Object
开始真正进入数学工程层。
210.8 为什么不直接使用大量 if
假设:
Distance = 0.03
Velocity = 0.02
Pressure = 0.10
Force = 0.15
Stability = 0.95
传统程序可能写成大量:
if ($distance < 0.05) {
...
}
if ($pressure > 0.1) {
...
}
if ($stability < 0.9) {
...
}
当变量越来越多:
Position
Velocity
Acceleration
Force
Pressure
Temperature
Distance
Orientation
Object Mass
Object Fragility
...
组合数量会快速增加。
这就容易重新走向:
场景A → 程序A
场景B → 程序B
场景C → 程序C
而不是你要的通用行为逻辑。
210.9 Vector 的意义
向量的意义在于:
把一个对象当前的多个动态因素放进同一个数学空间。
例如:
S(t)=[x,y,z,vx,vy,vz,F,P,S,D,O]S(t)= [x,y,z,v_x,v_y,v_z,F,P,S,D,O]
于是 Method 不再需要知道:
“这是鸡蛋场景”
它只需要处理:
当前状态向量
即:
Action=M(S(t))Action = M(S(t))
这样:
Egg
Glass
Bottle
Tool
都可以进入同一个数学方法。
不同的只是:
Segg≠Sglass≠SbottleS_{egg} \neq S_{glass} \neq S_{bottle}
所以输出自然可以不同。
210.10 State Space|状态空间
当 State Vector 建立以后,就自然进入:
State Space|状态空间
例如:
S=[PositionVelocityForcePressureStabilityDistanceOrientation]S= \begin{bmatrix} Position\\ Velocity\\ Force\\ Pressure\\ Stability\\ Distance\\ Orientation \end{bmatrix}
每一个具体的 State Vector:
S1
S2
S3
S4
都可以看成状态空间中的一个状态点。
于是:
现实对象
↓
动态属性
↓
State Vector
↓
State Space
这为后面研究动态行为提供数学基础。
210.11 时间维度
因为 ICAI 是动态认知系统,所以不能只定义:
SS
而应该定义:
S(t)S(t)
例如:
S(t0)→S(t1)→S(t2)S(t_0) \rightarrow S(t_1) \rightarrow S(t_2)
即:
Current State
↓
State(t0)
↓
State(t1)
↓
State(t2)
这就产生了状态变化:
ΔS=S(t1)−S(t0)\Delta S=S(t_1)-S(t_0)
进一步:
dSdt\frac{dS}{dt}
表示状态随时间的变化趋势。
210.12 这一步连接动态数学
到这里,前面你提出的:
施加力度和移动位置应该有数学关系。
就可以进入真正的数学结构。
例如:
P(t)P(t)
表示位置。
那么:
V(t)=dP(t)dtV(t)=\frac{dP(t)}{dt}
表示速度。
进一步:
A(t)=dV(t)dtA(t)=\frac{dV(t)}{dt}
表示加速度。
而 Force 可以参与动力学关系:
F=maF=ma
于是:
Position
↓
Velocity
↓
Acceleration
↓
Force
并不是几个孤立的属性,而形成动态数学关系。
210.13 离散工程实现
实际软件系统通常采样得到:
t0
t1
t2
t3
因此 PHP 工程中可以使用离散计算。
例如:
Vt=Pt−Pt−1ΔtV_t= \frac{P_t-P_{t-1}} {\Delta t}
代码:
$velocity = array(
($x - $lastX) / $dt,
($y - $lastY) / $dt,
($z - $lastZ) / $dt
);
这样:
实时位置
↓
离散时间差
↓
速度
完全可以通过普通软件工程实现。
不需要大模型。
210.14 State Vector 与 Method
现在可以正式建立:
S(t)→M→A(t)S(t) \rightarrow M \rightarrow A(t)
即:
State Vector
状态向量
↓
Method
方法
↓
Action
动作
例如:
A(t)=M(S(t))A(t)=M(S(t))
其中:
S(t)
当前状态向量
M
动态方法
A(t)
动作结果
这就是后续行为工程的数学入口。
210.15 更进一步:动态系统
如果动作会改变下一时刻状态,那么可以写成:
St+1=F(St,At)S_{t+1} = F(S_t,A_t)
即:
Current State
↓
Method
↓
Action
↓
World Change
↓
New State
形成:
S(t)
↓
M
↓
A(t)
↓
Environment
↓
S(t+1)
这与 ICAI 原来的闭环完全接上:
Real-Time Data
↓
Element
↓
Object
↓
Attribute Vector
↓
State Vector
↓
Method
↓
Action
↓
Device
↓
Feedback
↓
New State Vector
↺
210.16 这才是真正的“动态属性”
因此第209章的:
Dynamic Attribute
到了第210章变成:
Dynamic Attribute
↓
Attribute Vector
↓
State Vector
例如:
Position(t)
Velocity(t)
Force(t)
Pressure(t)
Stability(t)
Distance(t)
Orientation(t)
形成:
X(t)=[P(t)V(t)F(t)Q(t)St(t)D(t)O(t)]X(t)= \begin{bmatrix} P(t)\\ V(t)\\ F(t)\\ Q(t)\\ St(t)\\ D(t)\\ O(t) \end{bmatrix}
这里每一个元素都可以继续细分。
例如:
P(t)=[x,y,z]TP(t)=[x,y,z]^T
所以最终形成的是一个多维动态状态。
210.17 与人工行为逻辑的对应
人的行为并不是:
发现鸡蛋
↓
调用“鸡蛋程序”
而更接近:
感知
↓
对象
↓
位置
↓
距离
↓
运动
↓
接触
↓
力度
↓
稳定性
↓
当前整体状态
↓
动作调整
在 ICAI 中可以对应:
Real-Time Data
↓
Object Instance
↓
Dynamic Attributes
↓
Attribute Vector
↓
State Vector
↓
Method
↓
Action
这正是你现在这条工程路线的核心。
210.18 第210章的软件工程层次
现在形成三个不同层次:
Attribute Class
属性类
↓
Attribute Instance
属性实例
↓
Attribute Vector
属性向量
再:
Attribute Vector
↓
State Mapping
↓
State Vector
再:
State Vector
↓
Method
↓
Action
所以整个后续工程不会把:
Class
Object
Attribute
State
Method
Action
混成一个东西。
每一层都有明确职责。
210.19 第210章核心架构
Object Instance
对象实例
│
├── Position
├── Velocity
├── Force
├── Pressure
├── Stability
├── Distance
└── Orientation
↓
Attribute Vector
属性向量
↓
State Vector
状态向量
↓
Mathematical Model
数学模型
↓
Method
方法
↓
Action
动作
210.20 第210章核心结论
第210章正式完成从:
动态属性
到:
数学状态
的转换。
核心公式:
X(t)=[A1(t)A2(t)⋮An(t)]X(t)= \begin{bmatrix} A_1(t)\\ A_2(t)\\ \vdots\\ A_n(t) \end{bmatrix}
并通过状态映射:
S(t)=F(X(t))S(t)=F(X(t))
进入行为计算:
A(t)=M(S(t))A(t)=M(S(t))
最终形成:
Dynamic Attribute
动态属性
↓
Attribute Vector
属性向量
↓
State Vector
状态向量
↓
Method
动态方法
↓
Action
行为动作
第210章的意义,就是把 ICAI 的“动态属性”正式从软件变量提升为可以进行线性代数、微分计算和动态系统计算的数学对象。
而下一章就可以自然进入:
第211章 State Space|状态空间
核心研究:
State Vector
↓
State Space
↓
State Transition
↓
State(t)
↓
State(t+1)
也就是从“当前状态是什么”,正式进入“状态如何变化”。