第260章 ICAI MVC Runtime|ICAI MVC 认知运行系统
260.1 提出背景
经过前面多个章节的工程化定义,ICAI 已经形成了较为完整的软件对象体系。
系统内部已经建立:
- Object Model|对象模型
- Scene Model|场景模型
- Cognitive Model|认知模型
- Behavior Model|行为模型
- Device Model|设备模型
同时建立:
- Object Engine|对象引擎
- Scene Engine|场景引擎
- Cognitive Engine|认知引擎
- Behavior Engine|行为引擎
- Device Engine|设备引擎
在系统控制层建立 Controller,在表现层建立 Cognitive Interface 与 Smarty Template,在运行观察层建立 Real-Time Cognitive Dashboard。
因此,ICAI 已经不再是若干相互独立的类和模块,而需要进一步形成一个能够持续接收数据、更新对象、形成场景、产生认知、执行行为、驱动设备、接收反馈并重新认知的完整运行系统。
由此提出:
ICAI MVC Runtime|ICAI MVC 认知运行系统。
ICAI MVC Runtime 的核心任务,是把已经建立的 Model、Engine、Controller、View 与 Runtime 组织成为一个连续的软件运行过程。
其基本结构为:
Controller
↓
Engine
↓
Model
↓
Smarty
↓
Runtime
但是,从机器认知运行角度看,这五层并不是简单的线性调用关系,而是一个持续循环的运行结构:
Runtime
↓
Controller
↓
Engine
↓
Model
↓
Cognition
↓
Behavior
↓
Action
↓
Device
↓
World
↓
Feedback
↓
Runtime
因此,ICAI MVC Runtime 的本质,是将机器认知模型转化为一个能够持续运行的动态软件系统。
260.2 ICAI MVC Runtime 的定义
ICAI MVC Runtime|ICAI MVC 认知运行系统,是由 Model、Engine、Controller、Interface/View 与 Runtime 共同构成的机器认知软件运行体系。
其定义为:
RTt=F(Mt,Et,Ct,Vt,Dt,Ft)RT_t=F(M_t,E_t,C_t,V_t,D_t,F_t)
其中:
- RTtRT_t:时刻 tt 的 Runtime State,运行状态;
- MtM_t:Model State,模型状态;
- EtE_t:Engine State,引擎状态;
- CtC_t:Controller State,控制状态;
- VtV_t:View / Interface State,界面状态;
- DtD_t:Dynamic Data,动态数据;
- FtF_t:Feedback,反馈数据。
因此,Runtime 并不是某一个独立的数据表,也不是某一个普通 PHP Class,而是多个软件组件在时间维度上的协同运行状态。
260.3 MVC 在 ICAI 中的工程结构
ICAI MVC 并不是传统意义上单纯用于网页开发的 MVC。
在 ICAI 中:
Model
=
机器认知结构
Engine
=
机器认知计算与处理
Controller
=
系统控制与流程协调
Smarty
=
认知结果表现
Runtime
=
整个系统的持续运行
因此形成:
ICAI MVC Runtime
│
┌──────────────┼──────────────┐
↓ ↓ ↓
Model Engine Controller
│ │ │
└──────────────┼──────────────┘
↓
Cognitive Runtime
↓
Smarty / Interface
↓
Human / System
其中 Model 保存结构,Engine 执行计算,Controller 负责协调,Smarty 负责表现,而 Runtime 负责让整个系统持续运行。
260.4 Model Layer|认知模型层
ICAI Model Layer 是整个认知软件系统的数据结构基础。
主要包括:
Object Model
Scene Model
Cognitive Model
Behavior Model
Device Model
其内部关系为:
Object Model
↓
Scene Model
↓
Cognitive Model
↓
Behavior Model
↓
Device Model
Object Model 描述当前对象。
Scene Model 描述多个对象组成的当前场景。
Cognitive Model 描述机器当前形成的认知结构。
Behavior Model 描述当前目标驱动的行为过程。
Device Model 描述可执行动作的设备及其能力、状态和约束。
因此:
Mt={OMt,SMt,CMt,BMt,DMt}M_t= \{OM_t,SM_t,CM_t,BM_t,DM_t\}
其中:
- OMtOM_t:Object Model;
- SMtSM_t:Scene Model;
- CMtCM_t:Cognitive Model;
- BMtBM_t:Behavior Model;
- DMtDM_t:Device Model。
Model Layer 的主要任务不是执行动作,而是维护机器当前可计算的认知结构。
260.5 Engine Layer|认知引擎层
Engine Layer 负责对 Model 进行计算、更新和处理。
主要包括:
Object Engine
↓
Scene Engine
↓
Cognitive Engine
↓
Behavior Engine
↓
Device Engine
其基本关系为:
Et=F(OMt,SMt,CMt,BMt,DMt,Dt)E_t=F(OM_t,SM_t,CM_t,BM_t,DM_t,D_t)
Engine 不直接等同于 Model。
例如:
Object Model
=
对象当前是什么状态
Object Engine
=
如何创建、更新和处理对象
同样:
Scene Model
=
当前场景结构
Scene Engine
=
如何根据动态对象重新构建场景
因此,Model 是状态与结构,Engine 是计算与处理。
260.6 Controller Layer|控制器层
Controller 是 ICAI MVC Runtime 的协调层。
Controller 不承担全部认知计算,也不直接代替 Engine。
其主要职责是:
接收输入
↓
识别请求
↓
调用 Engine
↓
更新 Model
↓
返回结果
↓
更新 Interface
例如:
RuntimeController
↓
ObjectEngine
↓
ObjectModel
↓
SceneEngine
↓
SceneModel
↓
CognitiveEngine
↓
CognitiveModel
↓
BehaviorEngine
↓
BehaviorModel
↓
DeviceEngine
↓
DeviceModel
Controller 的作用是控制系统流程,而不是将所有认知逻辑集中到一个巨大程序中。
因此,ICAI 保持模块之间的独立性。
260.7 Smarty Presentation Layer|认知表现层
Smarty Template 位于系统表现层。
其作用是把 Controller 提供的结构化数据转换为 HTML。
基本关系:
Model
↓
Controller
↓
Smarty Data
↓
Smarty Template
↓
HTML
例如 Cognitive Model 可以被转换为:
当前目标
当前对象
对象属性
对象状态
当前场景
当前认知
当前行为
当前动作
当前设备
反馈状态
Smarty 不负责重新计算认知。
因此:
Smarty
≠
Cognitive Engine
而是:
Cognitive System
↓
Controller
↓
Smarty
↓
Human
这样可以保持机器认知逻辑与界面表现之间的独立性。
260.8 Runtime Layer|运行层
Runtime 是 ICAI MVC Runtime 最重要的动态层。
它负责让系统从一次调用变成持续运行。
其基本过程为:
Receive Data
↓
Update Object
↓
Update Attribute
↓
Update Relation
↓
Update State
↓
Update Scene
↓
Update Cognition
↓
Update Behavior
↓
Generate Action
↓
Execute Device
↓
Receive Feedback
↓
Update State
↓
Update Scene
↓
Re-Cognition
因此 Runtime 形成:
Rt+1=T(Rt,Dt,At,Ft)R_{t+1}=T(R_t,D_t,A_t,F_t)
其中:
- RtR_t:当前运行状态;
- DtD_t:当前动态数据;
- AtA_t:当前动作;
- FtF_t:执行反馈;
- TT:状态转移函数。
这意味着 ICAI 并不是执行一次程序之后结束。
它可以:
运行
↓
获得数据
↓
计算
↓
执行
↓
获得反馈
↓
重新计算
↓
继续运行
260.9 ICAI Runtime State|认知运行状态
为了统一 Runtime,可以建立运行状态向量:
Rt=[Gt,Ot,Sct,Ct,Bt,At,Dt,Ft]R_t= [G_t,O_t,Sc_t,C_t,B_t,A_t,D_t,F_t]
其中:
- GtG_t:Goal,当前目标;
- OtO_t:Objects,当前对象;
- SctSc_t:Scene,当前场景;
- CtC_t:Cognition,当前认知;
- BtB_t:Behavior,当前行为;
- AtA_t:Action,当前动作;
- DtD_t:Device,当前设备;
- FtF_t:Feedback,当前反馈。
因此,Runtime 可以实时维护:
Goal
↓
Objects
↓
Scene
↓
Cognition
↓
Behavior
↓
Action
↓
Device
↓
Feedback
当反馈产生以后:
Feedback
↓
Object Update
↓
Scene Update
↓
Cognition Update
↓
Behavior Update
↓
New Action
从而形成完整的认知运行闭环。
260.10 ICAI Runtime 与世界状态
ICAI Runtime 最终必须与外部世界产生关系。
可以表示为:
Wt+1=F(Wt,At)W_{t+1}=F(W_t,A_t)
其中:
- WtW_t:世界在时刻 tt 的状态;
- AtA_t:机器执行的动作;
- Wt+1W_{t+1}:动作执行后的世界状态。
世界发生变化后产生新的实时数据:
Wt+1→Dt+1W_{t+1} \rightarrow D_{t+1}
然后:
Dt+1→Ot+1→Sct+1→Ct+1D_{t+1} \rightarrow O_{t+1} \rightarrow Sc_{t+1} \rightarrow C_{t+1}
因此:
World
↓
Real-Time Data
↓
Object
↓
Scene
↓
Cognition
↓
Behavior
↓
Action
↓
Device
↓
World
这是 ICAI Runtime 的核心闭环。
260.11 Runtime 中的事件机制
为了让系统能够处理动态变化,可以建立 Event Runtime。
事件可以包括:
ObjectCreated
ObjectUpdated
AttributeChanged
RelationChanged
StateChanged
SceneChanged
CognitionChanged
BehaviorStarted
BehaviorChanged
ActionStarted
ActionCompleted
DeviceStarted
DeviceError
FeedbackReceived
事件产生后,Runtime 根据事件类型调用相应 Engine。
例如:
ObjectUpdated
↓
SceneEngine
↓
SceneChanged
↓
CognitiveEngine
↓
CognitionChanged
↓
BehaviorEngine
这样,系统不需要每次重新执行所有模块,而可以根据实际状态变化进行相应处理。
260.12 Runtime Kernel|运行内核
在工程实现中,可以进一步建立:
Runtime Kernel|运行内核。
Runtime Kernel 负责统一管理:
Object Engine
Scene Engine
Cognitive Engine
Behavior Engine
Device Engine
Feedback Manager
State Manager
Event Manager
其结构可以表示为:
Runtime Kernel
│
├── Object Engine
├── Scene Engine
├── Cognitive Engine
├── Behavior Engine
├── Device Engine
│
├── State Manager
├── Feedback Manager
└── Event Manager
Runtime Kernel 不替代这些 Engine,而是负责统一调度。
因此:
Runtime Kernel
↓
调用 Engine
↓
Engine 处理 Model
↓
Model 更新
↓
Runtime State 更新
260.13 PHP OOP 工程映射
ICAI MVC Runtime 可以通过 PHP OOP 建立对应的运行对象。
例如:
class RuntimeController
{
protected $objectEngine;
protected $sceneEngine;
protected $cognitiveEngine;
protected $behaviorEngine;
protected $deviceEngine;
public function run($data)
{
$objects = $this->objectEngine->update($data);
$scene = $this->sceneEngine->build($objects);
$cognition = $this->cognitiveEngine->process($scene);
$behavior = $this->behaviorEngine->process($cognition);
$action = $behavior->getAction();
$result = $this->deviceEngine->execute($action);
return $result;
}
}
这里的重点并不是具体代码,而是说明:
RuntimeController
↓
ObjectEngine
↓
SceneEngine
↓
CognitiveEngine
↓
BehaviorEngine
↓
DeviceEngine
已经可以被映射为明确的软件对象关系。
260.14 ICAI MVC Runtime 的完整运行模型
经过前面各层的建立,ICAI 可以形成完整运行模型:
World
↓
Real-Time Data
↓
Element
↓
Object Instance
↓
Object Model
↓
Relation
↓
State
↓
Scene Model
↓
Cognitive Model
↓
Behavior Model
↓
Action
↓
Device Model
↓
Device Engine
↓
Physical Device
↓
World Change
↓
Feedback
↓
State Update
↓
Scene Update
↓
Cognition Update
↓
Behavior Update
↓
New Action
而 MVC 软件结构则对应:
Controller
↓
Engine
↓
Model
↓
Smarty
↓
Runtime
两者结合以后形成:
ICAI MVC Runtime
│
┌───────────────┼───────────────┐
↓ ↓ ↓
Controller Engine Model
│ │ │
└───────────────┼───────────────┘
↓
Cognitive Runtime
↓
Behavior Runtime
↓
Device Runtime
↓
World
↓
Feedback
↓
Runtime
因此,MVC 不再只是网站开发结构,而成为 ICAI 机器认知软件系统的工程组织方式。
260.15 ICAI MVC Runtime 的核心特征
ICAI MVC Runtime 形成以下几个基本特征。
第一,结构化
系统中的认知对象均具有明确的软件结构。
Object
Attribute
Relation
State
Scene
Cognition
Behavior
Device
第二,动态化
系统不是静态数据集合,而是:
Statet→Statet+1State_t\rightarrow State_{t+1}
不断发生状态变化。
第三,可计算
对象属性、状态、关系、场景和行为都可以进入明确的计算过程。
第四,可执行
认知结果能够进一步形成:
Method
↓
Behavior
↓
Action
↓
Device
第五,可反馈
执行结果重新进入认知系统:
Action
↓
World Change
↓
Feedback
↓
Re-Cognition
第六,可观察
通过 Cognitive Interface 与 Real-Time Cognitive Dashboard,可以观察:
Object
Scene
Cognition
Behavior
Action
Device
Feedback
第七,可扩展
新的 Object、Method、Behavior、Device 可以通过新的软件对象加入系统,而不需要改变整个 Runtime 的基本结构。
260.16 第二十三部分的工程完成
至此,ICAI 已经完成从 MVC 软件架构到机器认知运行系统的转换。
第二十三部分所建立的不是单独的网页系统,而是一套完整的:
ICAI MVC Cognitive Runtime|ICAI MVC 认知运行体系。
其完整关系为:
Model
↓
Engine
↓
Controller
↓
Interface
↓
Smarty
↓
Runtime
↓
World
↓
Feedback
↓
Model Update
进一步展开为:
Real World
↓
Real-Time Data
↓
Element
↓
Object
↓
Attribute
↓
Relation
↓
State
↓
Scene
↓
Cognition
↓
Method
↓
Behavior
↓
Action
↓
Device
↓
World Change
↓
Feedback
↓
Re-Cognition
这意味着 ICAI 已经完成了一个重要的工程阶段:
从认知理论 → 对象模型 → PHP OOP → MVC → Engine → Controller → Interface → Runtime。
260.17 本章总结
第260章建立了 ICAI MVC Runtime|ICAI MVC 认知运行系统。
ICAI MVC Runtime 将:
Controller
+
Engine
+
Model
+
Smarty
+
Runtime
统一为一个连续的软件运行体系。
其中:
Model
=
认知结构
Engine
=
认知计算
Controller
=
流程控制
Smarty
=
认知表现
Runtime
=
持续运行
而真正的机器认知闭环为:
World
↓
Data
↓
Object
↓
Scene
↓
Cognition
↓
Behavior
↓
Action
↓
Device
↓
World
↓
Feedback
↓
Re-Cognition
由此,ICAI 的软件工程结构已经从单纯的类、对象和模块,进入到完整认知运行系统阶段。
第二十三部分 ICAI MVC 认知系统(第231—260章)至此完成。
下一阶段将不再主要讨论 MVC 内部结构,而是解决一个新的工程问题:
如何让已经完成的 ICAI MVC Runtime 成为一个可以被其他独立软件系统调用、传递结构化认知数据并返回认知结果的独立系统。
因此,下一部分进入:
第二十四部分 ICAI API + JSON|独立系统通信工程
核心转换关系为:
ICAI MVC Runtime
↓
API
↓
JSON
↓
Independent System
Communication
这将使 ICAI 从一个完整的本地认知运行系统,进一步成为一个可以向外部软件提供认知能力的独立系统。