首页 理论 架构 工程 文档 白皮书 著作 研究 案例 下载 博客 关于 开始使用 →

第35章 从 Information 到 Object

第35章 从 Information 到 Object

本章大纲

  1. 信息输入
  2. 元素识别
  3. 对象建立
  4. 属性建立
  5. 关系建立
  6. 方法建立
  7. 对象完整化
  8. 信息 → EOM
  9. 实际运行案例

35.1 信息输入

在前面的章节中,我们已经分别建立了:

Information
Scene
Element
Object
Property
Relation
Method
EOM

但是这些模块还需要一条完整的数据转换路径。

第35章解决的问题就是:

一条外部信息进入 SAI 以后,如何逐步形成一个完整 Object?

基本过程:

外部信息
   ↓
Information
   ↓
Element
   ↓
EOM
   ↓
Object
   ├── Property
   ├── State
   ├── Relation
   └── Method

因此,本章是前面 Information、Element、Object、Relation、Method 和 EOM 的连接章节。


35.2 信息输入

Information 是整个过程的起点。

例如外部传感器获得:

温度:32℃

Information 可以表示为:

Information
{
    type: "sensor",
    source: "temperature-001",
    content: 32,
    time: 14:20:00
}

如果是场景信息:

客厅温度32℃,有人,风扇关闭。

则 Information 可以包含:

Information
{
    type: "scene",
    source: "scene-collector-001",

    content:
    {
        room: "living-room",
        temperature: 32,
        person: "present",
        fan: "off"
    }
}

35.2.1 Information 不等于 Object

例如:

温度32℃

这是 Information。

它并不意味着已经建立:

Room Object

因为系统还需要判断:

32 是什么?
属于什么对象?
来自哪里?
与什么对象有关?

所以:

Information
→ 原始进入信息

而:

Object
→ 经过识别和组织后的实体

两者不能直接等同。


35.3 元素识别

Information 进入系统以后,需要从信息中识别 Element。

例如:

客厅温度32℃,有人,风扇关闭。

可以识别出:

Element
├── living-room
├── temperature
├── 32
├── person
├── present
├── fan
└── off

进一步给每个元素建立结构:

Element
├── id
├── type
├── value
├── source
├── state
└── time

35.3.1 元素识别不是对象建立

这一点非常重要。

例如:

fan

被识别出来以后,只能说明:

存在一个 fan 元素

不能立即认为已经建立:

fan-001 Object

因为还需要确定:

对象身份
对象类型
对象属性
对象状态
对象关系
对象方法

因此:

Element Recognition
≠
Object Creation

35.3.2 元素识别过程

可以表示为:

Information
      ↓
解析
      ↓
识别候选元素
      ↓
确定 Element Type
      ↓
确定 Element Value
      ↓
确定 Source
      ↓
Element

例如:

温度32℃

形成:

Element A
type = property
value = temperature

Element B
type = value
value = 32

然后通过上下文和关系组织:

temperature
      ↓
value
      ↓
32

35.4 对象建立

当 Element 被识别以后,下一步是建立 Object。

例如:

fan

识别为对象元素:

Element
type = object
value = fan

系统可以建立:

Object
id   = fan-001
type = fan

35.4.1 对象 ID

Object ID 是对象进入 EOM 后的重要身份标识。

例如:

fan-001
room-001
person-001
sensor-001

对象 ID 用于:

查询
关联
关系建立
属性更新
状态更新
方法调用

例如:

fan-001

后续收到:

speed = 1200

系统就可以知道:

speed

应该更新到:

fan-001

而不是创建一个完全无关的新对象。


35.4.2 Object 建立过程

Element
   ↓
判断是否为对象元素
   ↓
Object Type
   ↓
Object ID
   ↓
创建 Object

例如:

Element
type = object
value = fan

形成:

Object
id = fan-001
type = fan

35.5 属性建立

Object 建立以后,需要将其他相关 Element 组织成 Property。

例如:

fan
speed
1200

可以形成:

Fan
├── type = fan
└── Property
    └── speed = 1200

再例如:

fan
location
living-room

形成:

Fan
├── speed = 1200
└── location = living-room

35.5.1 Property 建立关系

基本关系:

Object
   ↓
has_property
   ↓
Property

例如:

fan-001
   ↓
has_property
   ↓
speed = 1200

35.5.2 Property 的来源

属性不能只有:

speed = 1200

还应该尽可能保留来源:

speed
value = 1200
source = speed-sensor-001
time = 14:20:10
state = valid

这样以后发生变化:

1200 → 1500

系统才能知道:

什么变了
什么时候变了
来自哪里

35.6 关系建立

Object 和 Property 建立以后,还需要建立 Object 之间的 Relation。

例如:

Fan
LivingRoom

通过场景信息知道:

Fan 位于 LivingRoom

建立:

fan-001
   ↓
located_at
   ↓
room-001

35.6.1 Relation 的来源

Relation 也应该来自实际信息。

例如:

客厅里有一个风扇。

识别:

Object A = fan
Object B = living-room

关系:

located_at

最终:

fan-001 → located_at → room-001

35.6.2 Relation 不是凭空产生

这一点对于 SAI 非常重要。

不能因为:

Fan
Room

两个对象存在,就自动认为:

Fan → located_at → Room

必须存在:

Information
Scene
Element
Fact
Rule

等可以支持该关系的数据或规则。

所以:

信息依据
   ↓
关系建立

而不是:

对象存在
   ↓
随意建立关系

35.7 方法建立

Method 与 Property、Relation 不同。

Property 描述:

Object 有什么

Relation 描述:

Object 与谁有什么联系

Method 描述:

Object 能做什么

例如:

Fan

可以具有:

turnOn()
turnOff()
setSpeed()

于是:

Fan
├── Property
│   ├── speed
│   └── location
│
├── State
│   └── off
│
└── Method
    ├── turnOn()
    ├── turnOff()
    └── setSpeed()

35.7.1 Method 的来源

Method 可以来自:

Object Type Definition
Object Capability
System Configuration
Device Definition
Extension

例如系统已经定义:

type = fan

对应:

Methods
├── turnOn
├── turnOff
└── setSpeed

当:

fan-001

建立以后,可以加载对应方法。


35.7.2 Method 不一定来自当前 Information

这一点需要与 Property 区分。

例如:

Information:
风扇关闭。

可以得到:

Object = Fan
State = off

但:

turnOn()
turnOff()
setSpeed()

可能来自系统已经定义的:

Fan Object Type

因此:

Information
→ 识别 Object

之后:

Object Type
→ 加载 Object Capability
→ Method

35.8 对象完整化

当 Object、Property、State、Relation、Method 都建立以后,一个 Object 才逐步完整。

例如:

Object
Fan

最开始只有:

fan-001
type = fan

然后增加 Property:

speed = 0
location = living-room

增加 State:

off

增加 Relation:

fan-001
→ located_at
→ room-001

增加 Method:

turnOn()
turnOff()
setSpeed()

最终:

Fan
│
├── ID
│   └── fan-001
│
├── Type
│   └── fan
│
├── Property
│   ├── speed = 0
│   └── location = living-room
│
├── State
│   └── off
│
├── Relation
│   └── located_at → room-001
│
└── Method
    ├── turnOn()
    ├── turnOff()
    └── setSpeed()

这就是一个相对完整的 EOM Object。


35.9 信息 → EOM

现在把整个过程统一起来。

Information
      ↓
Information Analysis
      ↓
Element Recognition
      ↓
Element
      ↓
Object Identification
      ↓
Object
      ↓
Property Construction
      ↓
Relation Construction
      ↓
Method Loading
      ↓
Object Completion
      ↓
EOM

可以进一步压缩成:

Information
    ↓
Element
    ↓
Object
    ↓
Property + State
    ↓
Relation
    ↓
Method
    ↓
Complete Object

35.9.1 信息到 EOM 的数据转换

例如输入:

客厅温度32℃,有人,风扇关闭。

第一阶段:

Information

第二阶段:

Elements
├── living-room
├── temperature
├── 32
├── person
├── present
├── fan
└── off

第三阶段:

Objects
├── room-001
├── person-001
└── fan-001

第四阶段:

Properties

room-001
└── temperature = 32

person-001
└── location = living-room

fan-001
└── location = living-room

第五阶段:

States

room-001
└── occupied

person-001
└── present

fan-001
└── off

第六阶段:

Relations

person-001
→ located_at
→ room-001

fan-001
→ located_at
→ room-001

第七阶段:

Methods

fan-001
├── turnOn()
├── turnOff()
└── setSpeed()

最终:

EOM
│
├── Room
│   └── room-001
│       ├── temperature = 32
│       └── state = occupied
│
├── Person
│   └── person-001
│       ├── state = present
│       └── located_at → room-001
│
└── Fan
    └── fan-001
        ├── location = living-room
        ├── state = off
        ├── located_at → room-001
        └── Methods
            ├── turnOn()
            ├── turnOff()
            └── setSpeed()

35.10 实际运行案例

下面使用一个完整的 SAI 运行案例。

场景:

温度传感器检测到客厅温度为 32℃,场景中有人,客厅风扇处于关闭状态。


第一步:Sensor 获取数据

TemperatureSensor
        ↓
32℃

形成:

SensorData
{
    sensor_id: temperature-001,
    type: temperature,
    value: 32,
    unit: C
}

第二步:InformationReceiver 接收

Sensor
   ↓
InformationReceiver
   ↓
Information

Information:

{
    type: "sensor",
    source: "temperature-001",
    content: 32
}

第三步:SceneCollector 建立场景

系统同时获得:

temperature = 32
person = present
fan = off
location = living-room

Scene:

Scene
├── Space
│   └── living-room
│
├── Environment
│   └── temperature = 32
│
├── Objects
│   ├── person
│   └── fan
│
└── States
    ├── person = present
    └── fan = off

35.11 Scene → Element

Perception 对 Scene 进行处理后,形成:

Element
├── room
├── living-room
├── temperature
├── 32
├── person
├── present
├── fan
└── off

此时仍然只是元素集合。


35.12 Element → Object

系统识别对象:

room
person
fan

建立:

room-001
person-001
fan-001

形成:

Object
├── room-001
├── person-001
└── fan-001

35.13 Object → Property

把相关属性加入对象。

Room

room-001
├── name = living-room
└── temperature = 32

Person

person-001
└── location = living-room

Fan

fan-001
└── location = living-room

35.14 Object → State

继续建立对象状态:

room-001
state = occupied

person-001
state = present

fan-001
state = off

35.15 Object → Relation

建立对象关系:

person-001
    ↓
located_at
    ↓
room-001

以及:

fan-001
    ↓
located_at
    ↓
room-001

最终形成:

          room-001
          /      \
         /        \
person-001        fan-001
                   │
                   └── state = off

35.16 Object → Method

根据 fan 对象类型加载:

turnOn()
turnOff()
setSpeed()

最终:

fan-001
├── Property
│   ├── location = living-room
│   └── speed = 0
│
├── State
│   └── off
│
├── Relation
│   └── located_at → room-001
│
└── Method
    ├── turnOn()
    ├── turnOff()
    └── setSpeed()

35.17 完整 EOM

最终形成:

EOM
│
├── Elements
│   ├── room
│   ├── temperature
│   ├── 32
│   ├── person
│   ├── present
│   ├── fan
│   └── off
│
├── Objects
│   │
│   ├── room-001
│   │   ├── type = room
│   │   ├── temperature = 32
│   │   └── state = occupied
│   │
│   ├── person-001
│   │   ├── type = person
│   │   ├── state = present
│   │   └── location = living-room
│   │
│   └── fan-001
│       ├── type = fan
│       ├── speed = 0
│       ├── state = off
│       └── location = living-room
│
├── Relations
│   ├── person-001
│   │   → located_at
│   │   → room-001
│   │
│   └── fan-001
│       → located_at
│       → room-001
│
└── Methods
    └── fan-001
        ├── turnOn()
        ├── turnOff()
        └── setSpeed()

35.18 EOM 形成以后发生什么

到这里,SAI 才真正拥有了可以用于后续认知处理的结构化对象。

例如:

Room
temperature = 32
state = occupied

Fan
state = off

Cognition 可以进一步处理:

当前场景
→ 人在客厅
→ 温度32℃
→ 风扇关闭

Reasoning 可以根据已经存在的:

Fact
+
Rule
+
Relation
+
State

进行推理。

Decision 再根据推理结果选择:

turnOn()

Behavior 执行:

Fan
→ turnOn()

于是形成:

Information
 ↓
Element
 ↓
EOM
 ↓
Cognition
 ↓
Reasoning
 ↓
Decision
 ↓
Behavior
 ↓
Method
 ↓
Object State

35.19 EOM 不是数据库表结构

需要特别区分:

EOM

和:

Database

数据库主要解决:

数据保存
数据查询
数据更新
数据索引

EOM 解决:

元素组织
对象形成
对象关系
对象属性
对象状态
对象方法

数据库可以作为 EOM 的持久化基础:

EOM
 ↓
Storage
 ↓
Database / File

但:

Database ≠ EOM

EOM 是 SAI 的对象组织模型


35.20 EOM 与认知的关系

EOM 本身不是 Cognition。

它提供的是:

结构

例如:

Person
   ↓
located_at
   ↓
Room

Room
temperature = 32

Fan
state = off

Cognition 才进一步回答:

这些对象是什么?
它们之间意味着什么?
当前场景代表什么?

所以:

EOM
 ↓
提供结构化世界
 ↓
Cognition
 ↓
理解结构

进一步:

EOM
 ↓
Fact / Relation / State
 ↓
Reasoning
 ↓
Conclusion

35.21 信息到对象的核心转换

第35章最重要的转换可以概括为:

Information
     ↓
识别
     ↓
Element
     ↓
组织
     ↓
Object
     ↓
补充
 ┌───┼────┬─────┐
 ↓   ↓    ↓     ↓
Property State Relation Method
 └───┴────┴─────┘
          ↓
      Complete Object

也可以表示成:

信息
 ↓
元素
 ↓
实体
 ↓
属性
 ↓
状态
 ↓
关系
 ↓
方法
 ↓
完整对象

这就是:

从 Information 到 Object 的基本形成过程。


本章完整示例

下面用简化 PHP OOP 形式表示整个转换过程:

<?php

// 1. Information

$information = array(
    'type' => 'scene',
    'source' => 'scene-001',
    'content' => array(
        'room' => 'living-room',
        'temperature' => 32,
        'person' => 'present',
        'fan' => 'off'
    )
);


// 2. Elements

$elements = array(
    'room' => 'living-room',
    'temperature' => 32,
    'person' => 'present',
    'fan' => 'off'
);


// 3. Objects

$room = new Object(
    'room-001',
    'room'
);

$person = new Object(
    'person-001',
    'person'
);

$fan = new Object(
    'fan-001',
    'fan'
);


// 4. Properties

$room->setProperty(
    'name',
    'living-room'
);

$room->setProperty(
    'temperature',
    32
);

$person->setProperty(
    'location',
    'living-room'
);

$fan->setProperty(
    'location',
    'living-room'
);

$fan->setProperty(
    'speed',
    0
);


// 5. States

$room->setState(
    'occupied'
);

$person->setState(
    'present'
);

$fan->setState(
    'off'
);


// 6. Relations

$personRelation = new Relation(
    'relation-000001',
    'located_at',
    'person-001',
    'room-001',
    'scene-001'
);

$fanRelation = new Relation(
    'relation-000002',
    'located_at',
    'fan-001',
    'room-001',
    'scene-001'
);


// 7. Methods

$fan->addMethod(
    'turnOn',
    $turnOn
);

$fan->addMethod(
    'turnOff',
    $turnOff
);

$fan->addMethod(
    'setSpeed',
    $setSpeed
);

最终:

Information
      ↓
Elements
      ↓
Objects
      ↓
Properties
      ↓
States
      ↓
Relations
      ↓
Methods
      ↓
Complete EOM

以上 PHP 代码是本章的设计示例,用于说明 SAI Framework 的 OOP 结构,未作为实际项目代码执行验证。


本章小结

第35章完成了 SAI Framework 中一个非常重要的数据形成过程:

Information
→ Element
→ Object
→ Property
→ State
→ Relation
→ Method
→ Complete Object

其中最关键的不是“把信息保存下来”,而是:

把进入 SAI 的信息逐步组织成可识别、可描述、可关联、可操作的 Object。

完整过程:

外部世界
   ↓
Information
   ↓
Element Recognition
   ↓
Element
   ↓
Object Identification
   ↓
Object
   ├── Property
   ├── State
   ├── Relation
   └── Method
   ↓
EOM
   ↓
Cognition

因此,第34章建立的是:

EOM = Element + Object + Method

而第35章解决的是:

Information
      ↓
如何进入 EOM
      ↓
如何最终形成 Object

到这里,SAI Framework 已经完成了从:

信息世界

向:

对象世界

的第一次核心转换。

下一篇 第十篇 Perception 将在这个基础上进一步回答:

SAI 如何从 Scene 中感知出 Element?

即:

Scene
 ↓
Perception
 ↓
Element
 ↓
EOM
 ↓
Object

这会正式进入 SAI 的感知层

Leave a Reply

Your email address will not be published. Required fields are marked *