第二十章 感知组合结构与认知对象理论
Cognitive Object Theory Based on Perception Combination Structure
第十九章建立了感知元素组合理论,解决的是:
多个感知元素如何通过对象、空间、时间、状态、关系和事件组织成更高层次的结构。
但是,组合完成之后,还存在一个更加重要的问题:
组合出来的结构究竟是什么?
如果只是得到:
Person
+
Office
+
Computer
+
Working
+
10:00
+
Near
系统虽然已经完成元素组合,但仍然只是一个结构集合。
真正进入认知层,还需要形成:
Cognitive Object
即:
认知对象。
因此,第二十章进一步研究:
- 组合结构;
- 认知对象;
- 对象身份;
- 对象属性;
- 对象状态;
- 对象关系;
- 对象行为;
- 对象上下文;
- 对象记忆;
- 对象生命周期;
- CognitiveObject PHP OOP 模型;
- MVC;
- Smarty;
- Service;
- Repository;
- Cognitive Kernel 接口。
20.1 认知对象基本概念
Basic Concept of Cognitive Object
传统面向对象编程中的对象通常表示:
Object
=
Properties
+
Methods
例如:
class Robot
{
public $name;
public $position;
public $state;
public function move()
{
}
}
但是 WSaiOS 所面对的对象更加复杂。
一个现实对象不仅拥有:
属性
还具有:
空间
时间
状态
关系
运动
事件
行为
历史
上下文
因此:
Cognitive Object
=
Object
+
Perception
+
State
+
Relation
+
Context
+
Memory
20.2 从感知元素到认知对象
WSaiOS 的基本形成过程:
Environment
↓
Perception
↓
Perception Element
↓
Fusion
↓
Association
↓
Combination
↓
Structure
↓
Cognitive Object
例如:
视觉:
Person
空间:
Position = Office A
时间:
10:00
状态:
Working
关系:
Near Computer
经过组合:
Person
+
Office A
+
10:00
+
Working
+
Near Computer
最终形成:
Cognitive Object:
Person_001
并具有:
Identity
Space
Time
State
Relation
Behavior
Context
20.3 认知对象与普通对象的区别
这是本章的核心区别之一。
普通对象:
Object
主要回答:
它是什么?
认知对象:
Cognitive Object
回答:
它是什么?
以及:
它在哪里?
它什么时候存在?
它现在是什么状态?
它和谁有什么关系?
它发生过什么?
它正在做什么?
它可能形成什么行为?
因此:
Object
↓
描述实体
而:
Cognitive Object
↓
描述实体及其认知上下文
20.4 认知对象核心结构
WSaiOS 可以建立:
CognitiveObject
{
ID
Identity
Attributes
Space
Time
State
Motion
Relations
Events
Behavior
Context
Memory
Meaning
}
其中:
Identity
对象身份。
Attributes
对象属性。
Space
对象空间信息。
Time
对象时间信息。
State
对象状态。
Motion
对象运动。
Relations
对象关系。
Events
对象发生的事件。
Behavior
对象行为。
Context
对象上下文。
Memory
对象历史记忆。
Meaning
对象当前认知意义。
20.5 对象身份元素
Object Identity Element
认知系统首先必须解决:
我正在认知的是谁?
例如:
Person_001
Robot_001
Machine_001
Vehicle_001
对象身份可以包括:
Object ID
Type
Name
Category
Identifier
模型:
IdentityElement
{
ID
Type
Name
Category
Identifier
}
对象身份是后续所有感知元素关联的基础。
没有稳定身份:
Position
State
Motion
Event
Memory
就无法可靠归属于同一个对象。
20.6 对象属性结构
认知对象可以拥有多个属性。
例如:
Robot_001
属性:
Brand
Model
Weight
Power
Sensor
属性结构:
Attribute
{
Name
Value
Type
Source
Time
}
注意:
WSaiOS 中属性也可以具有时间。
例如:
Battery = 80%
到了:
10:30
可能变成:
Battery = 65%
因此属性并不是绝对静态的。
20.7 对象空间结构
认知对象必须知道:
对象在哪里?
空间结构:
Space
{
Position
Direction
Region
Distance
Topology
}
例如:
Robot_001
Position:
x = 10
y = 20
z = 2
还可以具有:
Direction = North
Region = Factory_A
因此:
Cognitive Object
+
Spatial Structure
可以形成:
Spatially Located Object
20.8 对象时间结构
对象不仅存在于空间,也存在于时间。
例如:
Robot_001
生命周期:
08:00 Created
09:00 Started
10:00 Moving
11:00 Stopped
12:00 Maintenance
形成:
Object Timeline
模型:
TimeStructure
{
CreatedAt
StartTime
CurrentTime
LastUpdate
History
}
20.9 对象状态结构
状态是认知对象的重要部分。
例如:
Machine
可能经历:
Idle
↓
Running
↓
Warning
↓
Stopped
因此:
CurrentState
只是当前状态。
而完整认知对象还需要:
PreviousState
StateHistory
StateTransition
StateTrend
形成:
Object State Structure
20.10 对象运动结构
运动属于对象状态变化的重要维度。
例如:
Robot
运动:
Position A
↓
Position B
↓
Position C
可以计算:
Direction
Velocity
Acceleration
Distance
Trajectory
形成:
Motion Structure
因此:
Space
+
Time
+
Motion
共同形成:
Dynamic Spatial Object
20.11 对象关系结构
对象不是孤立存在。
例如:
Person
Uses
Computer
以及:
Computer
On
Desk
形成:
Person
↓ Uses
Computer
↓ On
Desk
因此认知对象可以保存:
Relations[]
每个关系:
Relation
{
Source
Type
Target
Time
Space
Confidence
}
20.12 对象事件结构
对象会不断产生事件。
例如:
Robot Started
Robot Moved
Robot Stopped
Robot Charged
因此:
CognitiveObject
可以拥有:
Events[]
形成:
Object Event History
事件不是对象本身。
而是:
对象在时间过程中产生的动态事实。
因此:
Object
↓
Event
↓
Object History
20.13 对象行为结构
多个事件进一步形成行为。
例如:
RobotDetectedObject
↓
RobotMoved
↓
RobotStopped
↓
RobotGrasped
形成:
ObjectHandlingBehavior
因此:
Events
↓
Event Sequence
↓
Behavior
行为结构:
Behavior
{
Type
Events
Start
End
Pattern
Meaning
}
20.14 对象上下文结构
同一个对象在不同上下文中的意义可能不同。
例如:
Temperature = 80
如果对象是:
Machine
可能表示:
High Machine Temperature
如果对象是:
Oven
可能属于:
Normal Operating Temperature
因此:
Object
+
Context
才能形成更加准确的认知意义。
20.15 认知对象意义模型
认知对象最终需要形成:
Meaning
例如:
Person_001
原始数据:
Position = Office
State = Working
Near = Computer
Time = 10:00
认知意义:
Employee Working In Office
因此:
Data
↓
Structure
↓
Context
↓
Meaning
20.16 认知对象形成规则
WSaiOS 可以建立:
CognitiveObjectRule
例如:
IF
Object = Person
AND
Region = Office
AND
State = Working
AND
Near = Computer
THEN
Meaning = OfficeWorkingPerson
形成:
Elements
+
Relations
+
Context
+
Rule
↓
Cognitive Object
20.17 认知对象的稳定性
认知对象必须解决一个关键问题:
今天看到的 Person_001 和一分钟之后看到的 Person_001,是不是同一个对象?
这就是:
Object Continuity
对象连续性。
可以依据:
Identity
Position
Motion
Time
Attributes
Relations
History
进行判断。
20.18 对象连续性模型
例如:
10:00
Person_001
Position A
10:01
Person_001
Position B
如果:
Distance(A,B)
符合正常运动范围:
Same Object
否则可能:
New Object
因此:
Previous Object
+
Current Perception
+
Continuity Rule
↓
Object Identity Decision
20.19 CognitiveObjectBuilder
认知对象应该由 Builder 构建。
class CognitiveObjectBuilder
{
public function build(
$identity,
array $elements,
array $relations = [],
$context = null
) {
$object = new CognitiveObject();
$object->setIdentity($identity);
$object->setElements($elements);
$object->setRelations($relations);
$object->setContext($context);
return $object;
}
}
其职责:
Perception Combination
↓
CognitiveObjectBuilder
↓
CognitiveObject
20.20 CognitiveObjectAnalyzer
Builder 负责构建。
Analyzer 负责分析:
Identity
State
Relations
Context
Meaning
Continuity
例如:
class CognitiveObjectAnalyzer
{
public function analyze($object)
{
$this->analyzeIdentity($object);
$this->analyzeState($object);
$this->analyzeRelations($object);
$this->analyzeContext($object);
return $object;
}
}
20.21 CognitiveObjectService
服务层统一组织流程:
class CognitiveObjectService
{
protected $builder;
protected $analyzer;
public function create(
$identity,
array $elements,
array $relations = [],
$context = null
) {
$object = $this->builder->build(
$identity,
$elements,
$relations,
$context
);
return $this->analyzer
->analyze($object);
}
}
形成:
Controller
↓
CognitiveObjectService
↓
Builder
↓
CognitiveObject
↓
Analyzer
↓
Cognitive Kernel
20.22 CognitiveObject PHP OOP 模型
class CognitiveObject
{
protected $id;
protected $identity;
protected $attributes = [];
protected $space;
protected $time;
protected $state;
protected $motion;
protected $relations = [];
protected $events = [];
protected $behaviors = [];
protected $context;
protected $memory;
protected $meaning;
public function getIdentity()
{
return $this->identity;
}
public function getState()
{
return $this->state;
}
public function getRelations()
{
return $this->relations;
}
public function addRelation($relation)
{
$this->relations[] = $relation;
}
public function addEvent($event)
{
$this->events[] = $event;
}
public function addBehavior($behavior)
{
$this->behaviors[] = $behavior;
}
public function getMeaning()
{
return $this->meaning;
}
}
20.23 CognitiveObjectRepository
认知对象需要持久化。
因此建立:
class CognitiveObjectRepository
{
public function save(CognitiveObject $object)
{
// 保存认知对象
}
public function findById($id)
{
// 查询认知对象
}
public function findByType($type)
{
// 查询对象
}
}
这样:
CognitiveObject
↓
Repository
↓
Database
实现对象持久化。
20.24 认知对象数据库结构
基础对象表:
CREATE TABLE cognitive_objects (
id INT AUTO_INCREMENT PRIMARY KEY,
object_id VARCHAR(100) NOT NULL,
object_type VARCHAR(100),
object_name VARCHAR(255),
meaning VARCHAR(255),
context VARCHAR(255),
current_state VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
对象属性:
CREATE TABLE cognitive_object_attributes (
id INT AUTO_INCREMENT PRIMARY KEY,
object_id VARCHAR(100),
attribute_name VARCHAR(100),
attribute_value TEXT,
attribute_type VARCHAR(50),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
对象关系:
CREATE TABLE cognitive_object_relations (
id INT AUTO_INCREMENT PRIMARY KEY,
source_object_id VARCHAR(100),
relation_type VARCHAR(100),
target_object_id VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
20.25 对象生命周期
认知对象不是永久不变。
生命周期:
Unknown
↓
Detected
↓
Identified
↓
Active
↓
Changed
↓
Inactive
↓
Lost
因此可以建立:
Object Lifecycle
生命周期事件:
ObjectDetected
ObjectIdentified
ObjectUpdated
ObjectChanged
ObjectLost
这些事件进入:
Event System
20.26 对象生命周期与状态机
对象生命周期可以使用状态机表达:
Detected
↓
Identified
↓
Active
↓
Inactive
↓
Lost
状态转换:
StateTransition
例如:
class ObjectStateMachine
{
public function transition(
$currentState,
$event
) {
// 根据事件进行状态转换
}
}
形成:
Event
↓
StateMachine
↓
Object State
20.27 认知对象与 Memory
认知对象不能只有当前状态。
还需要:
Memory
例如:
Person_001
历史:
08:00 Office
09:00 Meeting Room
10:00 Office
这些历史构成:
Object Memory
形成:
CognitiveObject
↓
Event History
↓
Memory
↓
Experience
20.28 认知对象与经验
如果对象历史不断积累:
Events
↓
Patterns
↓
Repeated Behavior
↓
Experience
例如:
Person
每天 09:00
进入 Office
系统可以形成:
Behavior Pattern
进一步形成:
Experience
因此:
Object
↓
History
↓
Pattern
↓
Experience
20.29 认知对象与 Cognitive Kernel
认知对象最终进入 Cognitive Kernel:
Perception
↓
Elements
↓
Fusion
↓
Combination
↓
Cognitive Object
↓
Cognitive Kernel
Cognitive Kernel 可以进一步处理:
Meaning
Reasoning
Prediction
Decision
20.30 MVC 工程结构
WSaiOS 认知对象模块:
cognitive/
│
├── controllers/
│ └── CognitiveObjectController.php
│
├── models/
│ ├── CognitiveObject.php
│ ├── CognitiveIdentity.php
│ ├── CognitiveAttribute.php
│ ├── CognitiveRelation.php
│ └── CognitiveContext.php
│
├── services/
│ ├── CognitiveObjectService.php
│ ├── CognitiveObjectBuilder.php
│ └── CognitiveObjectAnalyzer.php
│
├── repositories/
│ └── CognitiveObjectRepository.php
│
├── rules/
│ ├── ObjectIdentityRule.php
│ └── ObjectContinuityRule.php
│
├── state/
│ └── ObjectStateMachine.php
│
└── views/
└── cognitive_object.tpl
20.31 Controller 职责
Controller:
Request
↓
Controller
只负责:
接收输入
参数验证
调用 Service
返回结果
不要在 Controller 中直接进行:
对象识别
状态分析
关系推理
事件组合
这些属于:
Service
Analyzer
Rule
StateMachine
20.32 Smarty 展示
Controller:
$object = $service->create(
$identity,
$elements,
$relations,
$context
);
$smarty->assign(
'object',
$object
);
$smarty->display(
'cognitive_object.tpl'
);
Smarty:
<h2>认知对象</h2>
<p>对象:
{$object.identity}
</p>
<p>状态:
{$object.state}
</p>
<p>意义:
{$object.meaning}
</p>
关系:
<h3>对象关系</h3>
{foreach $object.relations as $relation}
<div>
{$relation.type}
</div>
{/foreach}
原则:
Smarty 只负责认知对象的表现层,不负责认知对象形成。
20.33 认知对象与 MVC 分层
最终职责:
Controller
↓
请求控制
Service
↓
业务流程
Builder
↓
对象构建
Analyzer
↓
认知分析
Rule
↓
确定性规则
Repository
↓
数据持久化
Model
↓
对象结构
Smarty
↓
表现
形成完整:
PHP OOP
+
MVC
+
Smarty
+
MySQL
工程体系。
20.34 感知元素组合到认知对象
现在可以形成新的核心链:
Perception Element
↓
Element Fusion
↓
Element Association
↓
Element Combination
↓
Combination Structure
↓
Cognitive Object
例如:
Visual
+
Spatial
+
Time
+
State
+
Relation
↓
Perception Combination
↓
CognitiveObject
20.35 认知对象到事件
认知对象形成以后:
Cognitive Object
↓
State Change
↓
Method
↓
Event
例如:
Machine
State = Running
变为:
State = Stopped
形成:
MachineStopped
因此:
Cognitive Object
+
State Change
↓
Event
20.36 认知对象到行为
事件进一步形成:
Event Sequence
↓
Behavior
例如:
PersonEntered
↓
PersonMoved
↓
PersonSat
形成:
SittingBehavior
因此:
Cognitive Object
↓
Events
↓
Behavior
20.37 认知对象到认知结构
最终:
Cognitive Object
+
Relations
+
Events
+
Behavior
+
Context
+
Memory
形成:
Cognitive Structure
因此:
Object
↓
Object Structure
↓
Cognitive Structure
20.38 WSaiOS 感知—认知对象架构
完整结构:
Environment
↓
Perception
↓
Perception Elements
↓
Fusion
↓
Association
↓
Combination
↓
Object Structure
↓
Cognitive Object
↓
State / Relation
↓
Event
↓
Behavior
↓
Cognition
↓
Memory
↓
Reasoning
↓
Decision
20.39 Cognitive Object Kernel
可以在 Cognitive Kernel 中建立对象入口:
class CognitiveObjectKernel
{
protected $objectService;
public function process($input)
{
$object =
$this->objectService
->createFromPerception(
$input
);
return $object;
}
}
形成:
Perception
↓
CognitiveObjectKernel
↓
CognitiveObject
20.40 本章总结
本章建立了 WSaiOS 认知对象理论。
核心观点:
- 感知元素是认知基础单元;
- 感知元素融合解决多源信息统一;
- 感知元素组合形成结构;
- 结构进一步形成认知对象;
- 认知对象不是普通数据对象;
- 认知对象具有身份;
- 认知对象具有属性;
- 认知对象具有空间;
- 认知对象具有时间;
- 认知对象具有状态;
- 认知对象具有运动;
- 认知对象具有关系;
- 认知对象具有事件;
- 认知对象具有行为;
- 认知对象具有上下文;
- 认知对象可以具有记忆;
- 认知对象具有动态生命周期;
- CognitiveObjectBuilder 负责对象构建;
- CognitiveObjectAnalyzer 负责对象分析;
- CognitiveObjectService 负责业务流程;
- CognitiveObjectRepository 负责持久化;
- ObjectStateMachine 负责状态生命周期;
- RuleEngine 负责对象识别与连续性规则;
- MVC 负责工程分层;
- Smarty 负责对象表现;
- PHP OOP 负责对象模型与业务逻辑;
- Cognitive Object 是感知体系进入认知体系的重要桥梁。
20.41 最终理论模型
环境
↓
感知
↓
感知元素
↓
感知元素融合
↓
元素关联
↓
感知元素组合
↓
组合结构
↓
认知对象
↓
对象状态
↓
对象关系
↓
对象事件
↓
对象行为
↓
认知结构
↓
记忆
↓
经验
↓
推理
↓
决策
↓
行动
WSaiOS Cognitive Object OOP 模型
PerceptionElement
│
↓
ElementFusion
│
↓
ElementCombination
│
↓
CognitiveObjectBuilder
│
↓
CognitiveObject
│
├── Identity
├── Attribute
├── Space
├── Time
├── State
├── Motion
├── Relation
├── Event
├── Behavior
├── Context
└── Memory
│
↓
CognitiveObjectAnalyzer
│
↓
Cognitive Kernel
WSaiOS 当前理论链
感知元素
↓
感知元素融合
↓
感知元素组合
↓
认知对象
↓
状态
↓
方法
↓
事件
↓
事件组合
↓
行为
↓
场景
↓
认知
↓
记忆
↓
经验
↓
推理
↓
决策
由此,WSaiOS 的理论开始从**“感知元素层”进入“认知对象层”**。
这一层非常关键,因为后续的行为认知、场景认知、记忆对象、经验对象以及推理对象,都可以建立在 CognitiveObject 这一统一 OOP 基础之上。