第187章 Method Matching
方法匹配
第186章建立了:
Same Goal
+
Different Scene
↓
Different Method
第187章进一步解决:
当前认知形成以后,机器如何从已有的可用 Method 中找到与当前场景最匹配的方法?
因此建立:
Current Cognition
+
Available Methods
↓
Method Matching
↓
Selected Method
1. Method Matching 的基本结构
系统预先拥有一组可执行方法:
Available Methods
│
├── GraspMethod
├── MoveMethod
├── AvoidMethod
├── ReleaseMethod
└── RepositionMethod
当前场景经过认知以后:
Current Scene
↓
Cognition
形成:
Current Cognition
然后:
Current Cognition
+
Available Methods
↓
Method Matching
得到:
Selected Method
例如:
Current Cognition
=
Egg + Stable + Reachable
匹配:
GraspMethod
而:
Current Cognition
=
Egg + Unstable + NearEdge
匹配:
RepositionMethod
如果:
Current Cognition
=
Obstacle + CollisionRisk
则可能匹配:
AvoidMethod
2. Method Matching 不是名称匹配
这里需要明确:
Egg
↓
GraspMethod
不是 Method Matching。
真正的匹配依据应该是:
Object
+
State
+
Relation
+
Risk
+
Goal
+
Capability
例如:
Egg
+
Stable
+
Accessible
+
Low Risk
+
Goal = Move
匹配:
GraspMethod
而:
Egg
+
Rolling
+
Near Edge
+
High Risk
+
Goal = Move
可能匹配:
RepositionMethod
因此:
Method Matching 匹配的是“当前认知条件”和“Method 所要求的条件”,而不是 Object Name。
3. Method 也具有条件
为了能够进行匹配,每一个 Method 可以具有自己的条件结构。
例如:
GraspMethod
{
required_state:
Stable
required_relation:
Reachable
required_capability:
Grasp
risk_limit:
Low
}
而:
RepositionMethod
{
required_state:
Unstable
required_capability:
Move
risk_limit:
Medium
}
于是:
Current Cognition
可以与:
Method Conditions
进行结构比较。
4. Method Matching 的 OOP 结构
可以建立:
class MethodMatcher
{
public function match($cognition, $methods)
{
}
public function checkCondition($cognition, $method)
{
}
public function calculateScore($cognition, $method)
{
}
public function select($matches)
{
}
}
调用:
$matcher = new MethodMatcher();
$result = $matcher->match(
$currentCognition,
$availableMethods
);
形成:
Cognition Instance
+
Method Instances
↓
MethodMatcher
↓
Matching Result
↓
Selected Method
5. Method Matching 的基本计算
最简单可以建立条件匹配:
Current Cognition
↓
Compare
↓
Method Conditions
例如:
Current Cognition
-----------------
State = Stable
Reachable = True
Risk = Low
Goal = Move
与:
GraspMethod
-----------
State = Stable
Reachable = True
Risk <= Low
Goal = Move
匹配成功:
Match = True
因此:
GraspMethod
成为候选方法。
6. 多个 Method 同时匹配
现实中可能出现:
Current Cognition
同时满足:
GraspMethod
MoveMethod
RepositionMethod
因此不能简单:
First Match
↓
Execute
而应该:
Current Cognition
↓
Available Methods
↓
Condition Matching
↓
Candidate Methods
↓
Method Evaluation
↓
Best Match
例如:
GraspMethod Score = 0.82
MoveMethod Score = 0.61
RepositionMethod Score = 0.34
最终:
Selected Method
=
GraspMethod
7. Method Matching 与第186章连接
第186章:
Current Scene
+
Goal
+
Capability
↓
Dynamic Method Selection
第187章进一步拆开:
Current Cognition
↓
Available Methods
↓
Condition Matching
↓
Candidate Methods
↓
Evaluation
↓
Selected Method
因此:
Dynamic Method
回答:
为什么 Method 会变化?
而:
Method Matching
回答:
当前情况下到底匹配哪个 Method?
两章形成上下游关系。
8. Method Matching 与 Cognitive Method
认知方法:
perceive()
understand()
reason()
evaluate()
decide()
负责形成:
Current Cognition
然后:
Current Cognition
↓
Method Matching
选择行为方法:
GraspMethod
MoveMethod
AvoidMethod
ReleaseMethod
RepositionMethod
因此需要区分两类 Method:
Cognitive Methods
↓
形成 Cognition
Behavior Methods
↓
解决当前 Goal
完整:
Scene
↓
Cognitive Methods
↓
Current Cognition
↓
Method Matching
↓
Behavior Method
↓
Action
9. Method Matching 与 Goal
Method 不能脱离 Goal。
例如:
Current Scene
=
Egg + Stable
如果:
Goal = Move Egg
可能:
GraspMethod
如果:
Goal = Leave Egg
可能:
ReleaseMethod
如果:
Goal = Protect Egg
可能:
AvoidMethod
因此:
Method Match
=
Cognition
+
Goal
+
Capability
10. Method Matching 与 Risk
Risk 也参与匹配。
例如:
Risk = Low
可能:
GraspMethod
但是:
Risk = High
则:
RepositionMethod
而:
Risk = Critical
可能:
AvoidMethod
甚至:
StopMethod
因此:
Risk
不是 Method 执行后的附属数据。
它可以直接参与:
Method Matching
11. Method Matching 与 Capability
机器拥有:
Capability
例如:
Robot
├── Grasp
├── Move
├── Rotate
└── Release
如果某 Method 要求:
Rotate
但是:
Capability.Rotate = False
那么:
RotateMethod
直接不能进入候选集合。
因此:
Available Methods
=
Registered Methods
∩
Machine Capability
然后才进行:
Method Matching
12. Method Matching 的结构化结果
不应该只返回:
GraspMethod
而应该返回:
{
"method": "GraspMethod",
"matched": true,
"score": 0.92,
"conditions": {
"state": true,
"relation": true,
"goal": true,
"capability": true,
"risk": true
}
}
最终:
Method Matching Result
↓
Selected Method
这样整个过程可以被记录、验证和分析。
13. Method Matching 与实时场景
由于:
Scene(t)
不断变化:
Scene(t+1)
所以匹配结果也必须实时变化。
例如:
Scene(t)
↓
Cognition(t)
↓
GraspMethod
发生:
Egg Rolling
以后:
Scene(t+1)
↓
Cognition(t+1)
↓
Method Matching
可能得到:
RepositionMethod
所以:
Match(t)
≠
Match(t+1)
这使 Method Matching 成为动态认知循环中的实时计算环节。
14. Method Matching 的程序链
完整 OOP 结构可以形成:
Scene
↓
SceneCognition
↓
MethodMatcher
↓
Available Methods
↓
Condition Matching
↓
Score
↓
Selected Method
例如:
$methods = $methodRegistry->getAvailableMethods();
$matches = $matcher->match(
$cognition,
$methods
);
$method = $matcher->select(
$matches
);
最终:
$method
就是当前场景下选择出来的:
Method Instance
15. Method Registry
如果系统方法越来越多,可以建立:
class MethodRegistry
{
protected $methods = [];
public function register($method)
{
$this->methods[] = $method;
}
public function getAvailableMethods()
{
return $this->methods;
}
}
注册:
$registry->register(new GraspMethod());
$registry->register(new MoveMethod());
$registry->register(new AvoidMethod());
$registry->register(new ReleaseMethod());
$registry->register(new RepositionMethod());
于是:
Method Registry
↓
Available Methods
↓
Method Matcher
这样 Method 就成为系统中可管理、可扩展的独立对象。
16. Method Matching 的核心关系
最终可以定义:
Method Matching
=
Current Cognition
+
Goal
+
Capability
+
Available Methods
计算:
Current Cognition
+
Method Conditions
↓
Match
↓
Score
↓
Selection
得到:
Selected Method
17. 与机器执行的连接
最终完整链:
Real-Time Data
↓
Elements
↓
Objects
↓
Relations
↓
Current Scene
↓
Scene Cognition
↓
Cognitive Methods
↓
Current Cognition
↓
Method Matching
↓
Selected Method
↓
Behavior Parameters
↓
Machine API
↓
Robot
这里已经形成一个非常清晰的系统边界:
Cognitive System
────────────────────
Scene
Cognition
Method Matching
Decision
│
│ JSON / API
↓
Behavior / Machine System
────────────────────
Method Execution
Action
Device
因此认知系统不需要直接控制每一个电机。
它只需要产生:
当前场景下机器应该采用什么 Method,以及该 Method 所需要的结构化参数。
18. 本章核心原则
Method Matching Principle
ICAI 不将某一个任务固定绑定到某一个行为方法,而是将当前 Cognition 与系统中可用的 Method 进行结构条件匹配,根据当前 State、Relation、Risk、Goal 和 Capability 等条件筛选和评价候选 Method,最终获得适用于当前场景的 Method Instance。
核心:
Current Cognition
+
Available Methods
↓
Condition Matching
↓
Method Evaluation
↓
Method Selection
↓
Method Instance
↓
Behavior
↓
Action
因此第185–187章已经形成一条完整工程链:
第185章
Cognitive Method
↓
理论 Method → OOP Method
第186章
Dynamic Method
↓
Method 随 Scene 动态变化
第187章
Method Matching
↓
从 Available Methods 中匹配当前 Method
下一章可以自然进入 第188章 Method Computation:
Selected Method
↓
Element
+
Object
+
Relation
+
State
+
Goal
+
Parameters
↓
Method Computation
↓
Result
也就是正式开始研究你这套体系最关键的下一层:Method 被匹配出来以后,如何直接对已经实例化的场景结构进行算法运算,并产生机器可以执行的具体数据。