第251章 Cognitive Model|认知模型
从认知对象到完整认知模型
第231–250章完成了 ICAI MVC 认知系统的工程基础,使前面建立的:
Element
元素
↓
Object
对象
↓
Attribute
属性
↓
Relation
关系
↓
State
状态
↓
Scene
场景
↓
Cognition
认知
能够进入:
Model
模型
↓
Engine
引擎
↓
Controller
控制器
↓
Runtime
运行时
第251章开始,正式建立 Cognitive Model|认知模型。
这一章的核心不是再定义一个普通的 PHP Model,而是解决:
机器如何把当前对象、属性、关系、状态、场景以及目标组织成为一个可以运行的认知结构。
251.1 Cognitive Model|认知模型的定义
Cognitive Model|认知模型是对机器当前认知结构进行统一表示、组织和计算的数据模型。
它不是:
数据库模型
也不是:
普通业务 Model
而是:
现实世界
↓
实时数据
↓
对象结构
↓
当前场景
↓
认知结构
在软件系统中的统一表达。
可以表示为:
CMt=F(Ot,At,Rt,St,Sct,Gt)CM_t = F( O_t, A_t, R_t, S_t, Sc_t, G_t )
其中:
CM
Cognitive Model
认知模型
O
Object
对象
A
Attribute
属性
R
Relation
关系
S
State
状态
Sc
Scene
场景
G
Goal
目标
因此:
Cognitive Model
认知模型
│
├── Objects
├── Attributes
├── Relations
├── States
├── Scenes
└── Goals
251.2 Cognitive Model 不是一个静态模型
ICAI 的认知模型必须是动态的。
因为机器面对的是:
现实世界
而现实世界不断变化。
因此不是:
CMCM
而是:
CM(t)CM(t)
即:
Cognitive Model(t0)
↓
Cognitive Model(t1)
↓
Cognitive Model(t2)
每一个时刻,机器拥有的认知结构都可能不同。
251.3 Cognitive Model 的核心输入
认知模型的输入不是单一数据。
而是:
Real-Time Data
实时数据
↓
Element
元素
↓
Object
对象
↓
Attribute
属性
↓
Relation
关系
↓
State
状态
↓
Scene
场景
↓
Goal
目标
这些结构经过组织后形成:
Cognitive Model
因此:
认知模型是前面所有认知对象结构的综合运行表示。
251.4 Cognitive Model 与 Object Model 的区别
两者必须区分。
Object Model|对象模型
回答:
世界中有什么对象,以及对象具有什么结构。
例如:
Egg
├── Position
├── Weight
└── Stability
Cognitive Model|认知模型
回答:
机器当前如何理解这些对象,以及这些对象在当前场景中的状态、关系和目标意义。
例如:
Hand
↓
near
↓
Egg
↓
Egg State = stable
↓
Goal = grasp
因此:
Object Model
↓
Cognitive Model
对象模型是认知模型的基础之一。
251.5 Cognitive Model 的结构
可以建立统一结构:
Cognitive Model
│
├── Goal
│
├── Scene
│ │
│ ├── Object
│ │ └── Attribute
│ │
│ ├── Object
│ │ └── Attribute
│ │
│ ├── Relation
│ │
│ └── State
│
├── Cognition
│
├── Method
│
└── Action
因此完整认知模型已经不只是:
对象集合
而是:
目标
+
世界结构
+
当前状态
+
认知结果
+
方法
+
行为
251.6 Cognitive Model 的运行过程
ICAI 中可以形成:
Real-Time World
现实世界
↓
Real-Time Data
实时数据
↓
Object Construction
对象构建
↓
Scene Construction
场景构建
↓
State Evaluation
状态评估
↓
Cognitive Model
认知模型
↓
Cognitive Processing
认知处理
↓
Method
方法
↓
Action
动作
↓
World Change
现实变化
↓
Feedback
反馈
↓
Cognitive Model Update
认知模型更新
因此 Cognitive Model 是整个闭环中的认知结构中心。
251.7 PHP CognitiveModel Class
进入软件工程实现,可以建立:
<?php
class CognitiveModel
{
protected $goal = null;
protected $scene = null;
protected $cognition = null;
protected $methods = array();
protected $actions = array();
public function setGoal($goal)
{
$this->goal = $goal;
}
public function setScene(Scene $scene)
{
$this->scene = $scene;
}
public function setCognition($cognition)
{
$this->cognition = $cognition;
}
public function addMethod($method)
{
$this->methods[] = $method;
}
public function addAction($action)
{
$this->actions[] = $action;
}
public function getScene()
{
return $this->scene;
}
public function getCognition()
{
return $this->cognition;
}
}
这个 Class 暂时不负责具体计算。
它主要负责:
组织认知运行所需要的核心对象。
251.8 Cognitive Model 的对象关系
例如当前机器面对:
桌子
鸡蛋
机械手
认知模型可以形成:
Cognitive Model
│
↓
Scene
│
┌─────┼─────┐
↓ ↓ ↓
Hand Egg Table
│ │
└─near┘
│
↓
Egg State
stable
│
↓
Goal
grasp egg
于是机器当前的认知结构已经完整形成。
251.9 Cognitive Model 与 State Vector
第210章以后建立了:
Dynamic Attribute
↓
Attribute Vector
↓
State Vector
现在可以进一步连接:
S(t)→CognitiveModel(t)S(t) \rightarrow CognitiveModel(t)
即:
State Vector
状态向量
↓
State Evaluation
↓
Cognitive Model
例如:
S(t)=[Position,Velocity,Force,Pressure,Stability,Distance,Orientation]S(t)= [ Position, Velocity, Force, Pressure, Stability, Distance, Orientation ]
经过状态与对象关系处理后,形成机器当前的认知模型。
251.10 Cognitive Model 与目标
机器行为不能只有:
当前状态
还必须存在:
Goal
目标
例如:
Current State
鸡蛋在桌面上
Goal
抓取鸡蛋
于是:
Goal+CurrentState→CognitiveRequirementGoal + CurrentState \rightarrow CognitiveRequirement
然后:
Cognitive Requirement
↓
Method Selection
↓
Method Parameters
↓
Action
这使认知模型开始连接行为系统。
251.11 Cognitive Model 与 Method
前面第209–210章已经形成:
Dynamic Attribute
↓
Attribute Vector
↓
State Vector
↓
Method
现在进一步:
Cognitive Model
↓
Current State
↓
Required Method
↓
Method Parameters
↓
Method Calculation
因此 Method 不是孤立运行的。
它是在 Cognitive Model 提供的当前认知结构中运行。
251.12 Cognitive Model 与 Action
最终:
Actiont=M(St,Gt,Ct)Action_t=M(S_t,G_t,C_t)
其中:
S
Current State
当前状态
G
Goal
目标
C
Cognitive Context
认知上下文
因此:
Cognitive Model
↓
Current State
+
Goal
+
Context
↓
Method
↓
Action
这就开始形成真正的机器行为逻辑。
251.13 不为场景建立固定 Cognitive Model
仍然必须遵守前面确立的原则。
不能:
EggCognitiveModel.php
GlassCognitiveModel.php
BottleCognitiveModel.php
也不能:
KitchenSceneModel.php
FactorySceneModel.php
RobotSceneModel.php
因为现实场景是动态组合的。
应该只有:
CognitiveModel
然后运行时:
Real-Time Data
↓
Object
↓
Scene
↓
State
↓
Goal
↓
Cognitive Model Instance
不同场景只是产生不同的 Model Instance。
251.14 Cognitive Model Instance
因此:
CognitiveModel Class
↓
new CognitiveModel()
↓
CognitiveModel Instance
例如:
$cognitiveModel = new CognitiveModel();
$cognitiveModel->setScene($scene);
$cognitiveModel->setGoal($goal);
得到:
Cognitive Model Instance
│
├── Scene #5001
├── Goal #001
├── Current Cognition
├── Methods
└── Actions
它代表:
机器当前时刻的一次具体认知结构。
251.15 Cognitive Model 的动态更新
现实发生变化:
Hand Position
变化
导致:
Distance
变化
进一步:
Relation
变化
进一步:
State
变化
于是:
Scene
变化
最终:
Cognitive Model
变化
形成:
CM(t)
↓
World Change
↓
Feedback
↓
CM(t+1)
所以 Cognitive Model 也属于动态运行对象。
251.16 完整认知闭环
到这里,可以把前面大量章节压缩成一个工程闭环:
World
现实世界
↓
Real-Time Data
实时数据
↓
Element
元素
↓
Object Instance
对象实例
↓
Dynamic Attribute
动态属性
↓
Relation
关系
↓
Current State
当前状态
↓
Scene Instance
场景实例
↓
Cognitive Model
认知模型
↓
Method
方法
↓
Action
动作
↓
Device
设备
↓
World Change
现实变化
↓
Feedback
反馈
↓
Re-Cognition
重新认知
↺
这就是 ICAI 软件工程真正要实现的:
机器认知运行闭环。
251.17 与 MVC 的关系
现在进入第二十三部分以后,需要严格区分:
Cognitive Model
与 MVC 中普通的:
Model
MVC:
Controller
↓
Model
↓
View
解决的是软件系统的组织方式。
而:
Cognitive Model
解决的是:
机器当前认知结构
因此两者关系应该是:
MVC Model Layer
↓
Cognitive Model
↓
Object / Scene / State / Cognition
MVC 是软件架构。
Cognitive Model 是机器认知对象模型。
两者不能混为一个理论概念。
251.18 本章建立的核心层次
现在整个 ICAI 已经出现清晰的层次:
现实层
World
↓
数据层
Real-Time Data
↓
对象层
Element / Object / Attribute
↓
关系层
Relation
↓
状态层
State / State Vector
↓
场景层
Scene
↓
认知层
Cognitive Model
↓
方法层
Method
↓
行为层
Behavior / Action
↓
执行层
Device
↓
反馈层
Feedback
这是第251章最重要的工程意义。
251.19 Cognitive Model 的核心公式
可以将当前认知模型抽象为:
CM(t)=F[O(t),A(t),R(t),S(t),Sc(t),G(t)]CM(t)= F[ O(t), A(t), R(t), S(t), Sc(t), G(t) ]
然后认知结果:
C(t)=CognitiveFunction(CM(t))C(t)= CognitiveFunction(CM(t))
方法:
M(t)=MethodSelection(CM(t))M(t)= MethodSelection(CM(t))
动作:
Ac(t)=M(t,S(t),G(t))A_c(t)= M(t,S(t),G(t))
执行以后:
Worldt+1=Execute(Ac(t))World_{t+1} = Execute(A_c(t))
反馈:
CM(t+1)=Update(CM(t),Feedback)CM(t+1) = Update(CM(t),Feedback)
最终:
CM(t)→Cognition→Method→Action→Worldt+1→Feedback→CM(t+1)CM(t) \rightarrow Cognition \rightarrow Method \rightarrow Action \rightarrow World_{t+1} \rightarrow Feedback \rightarrow CM(t+1)
这就形成真正的动态认知系统。
251.20 第251章核心结论
第251章不是简单增加一个 CognitiveModel.php。
它真正完成的是:
Object
+
Attribute
+
Relation
+
State
+
Scene
+
Goal
↓
Cognitive Model
从而把此前建立的大量认知对象第一次统一到一个运行时认知结构中。
最终形成:
Cognitive Model
│
┌───────────────┼───────────────┐
↓ ↓ ↓
Scene Goal Cognition
│
┌────┼────┐
↓ ↓ ↓
Object Object Object
│
Attribute
│
State
│
Relation
↓
Method
↓
Action
↓
Device
↓
Feedback
↓
Cognitive Model Update
↺
因此,第251章之后,工程重点就从:
“机器有哪些认知对象?”
进一步进入:
“这些认知对象如何在一个统一 Cognitive Model 中运行,并驱动 Method、Behavior、Action?”
这正好把前面的认知对象工程与后面的认知控制、方法控制、行为控制和认知引擎连接起来。