水壶问题_人工智能中的水壶问题

本文介绍了人工智能领域的一个经典问题——水壶问题。给定一个3加仑和一个4加仑的水壶,任务是在没有其他测量工具的情况下,将4加仑的壶装满2加仑的水。通过遵循一系列生产规则,可以在7次操作后达到目标状态,成功解决这个问题。
摘要由CSDN通过智能技术生成

水壶问题

In the water jug problem in Artificial Intelligence, we are provided with two jugs: one having the capacity to hold 3 gallons of water and the other has the capacity to hold 4 gallons of water. There is no other measuring equipment available and the jugs also do not have any kind of marking on them. So, the agent’s task here is to fill the 4-gallon jug with 2 gallons of water by using only these two jugs and no other material. Initially, both our jugs are empty.

人工智能的水壶问题中 ,我们提供了两个水壶:一个可以容纳3加仑的水,另一个可以容纳4加仑的水。 没有其他可用的测量设备,并且壶上也没有任何标记。 因此,代理商的任务是仅使用这两个水罐,而不用其他材料,向2加仑的水填充4加仑的水罐。 最初,我们两个水罐都是空的。

So, to solve this problem, following set of rules were proposed:

因此,为解决此问题,提出了以下规则集:

Production rules for solving the water jug problem

解决水壶问题的生产规则

Here, let x denote the 4-gallon jug and y denote the 3-gallon jug.

在此, x表示4加仑的水罐, y表示3加仑的水罐。

S.No.Initial StateConditionFinal stateDescription of action taken
1.(x,y)If x<4(4,y)Fill the 4 gallon jug completely
2.(x,y)if y<3(x,3)Fill the 3 gallon jug completely
3.(x,y)If x>0(x-d,y)Pour some part from the 4 gallon jug
4.(x,y)If y>0(x,y-d)Pour some part from the 3 gallon jug
5.(x,y)If x>0(0,y)Empty the 4 gallon jug
6.(x,y)If y>0(x,0)Empty the 3 gallon jug
7.(x,y)If (x+y)<7(4, y-[4-x])Pour some water from the 3 gallon jug to fill the four gallon jug
8.(x,y)If (x+y)<7(x-[3-y],y)Pour some water from the 4 gallon jug to fill the 3 gallon jug.
9.(x,y)If (x+y)<4(x+y,0) Pour all water from 3 gallon jug to the 4 gallon jug
10.(x,y)if (x+y)<3(0, x+y)Pour all water from the 4 gallon jug to the 3 gallon jug
序号 初始状态 健康)状况 最终状态 采取行动的描述
1。 [x,y) 如果x <4 (4,y) 完全充满4加仑的水罐
2。 [x,y) 如果y <3 (x,3) 完全充满3加仑的水罐
3。 [x,y) 如果x> 0 (xd,y) 倒入4加仑水罐中的一部分
4。 [x,y) 如果y> 0 (x,yd) 倒入3加仑水罐中的一部分
5, [x,y) 如果x> 0 (0,y) 清空4加仑的水罐
6。 [x,y) 如果y> 0 (x,0) 清空3加仑的水罐
7 [x,y) 如果(x + y)<7 (4,y- [4-x]) 从3加仑的水罐里倒一些水,充满4加仑的水罐
8。 [x,y) 如果(x + y)<7 (x- [3-y],y) 将4加仑的水倒入3加仑的水。
9。 [x,y) 如果(x + y)<4 (x + y,0) 将所有水从3加仑的水倒到4加仑的水
10。 [x,y) 如果(x + y)<3 (0,x + y) 将所有水从4加仑的水倒到3加仑的水

The listed production rules contain all the actions that could be performed by the agent in transferring the contents of jugs. But, to solve the water jug problem in a minimum number of moves, following set of rules in the given sequence should be performed:

列出的生产规则包含代理商在转移水罐内容物中可以执行的所有操作。 但是,为了以最少的移动次数解决水壶问题,应按照给定顺序执行以下规则集:

Solution of water jug problem according to the production rules:

根据生产规则解决水壶问题:

S.No.4 gallon jug contents3 gallon jug contentsRule followed
1.0 gallon0 gallonInitial state
2. 0 gallon3 gallonsRule no.2
3. 3 gallons0 gallonRule no. 9
4. 3 gallons3 gallonsRule no. 2
5.4 gallons2 gallonsRule no. 7
6. 0 gallon2 gallonsRule no. 5
7. 2 gallons 0 gallonRule no. 9
序号 4加仑水罐内容物 3加仑水罐内容物 遵循规则
1。 0加仑 0加仑 初始状态
2。 0加仑 3加仑 规则二
3。 3加仑 0加仑 规则编号 9
4。 3加仑 3加仑 规则编号 2
5, 4加仑 2加仑 规则编号 7
6。 0加仑 2加仑 规则编号 5
7 2加仑 0加仑 规则编号 9

On reaching the 7th attempt, we reach a state which is our goal state. Therefore, at this state, our problem is solved.

在达到第7 尝试后,我们达到了一种状态,即目标状态。 因此,在这种状态下,我们的问题得以解决。

翻译自: https://www.includehelp.com/ml-ai/water-jug-problem-in-artificial-intelligence.aspx

水壶问题

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值