首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导COSC 320编程、讲解CS,Java程序设计 解析C/C++编程|解析Haskell程序
项目预算:
开发周期:
发布时间:
要求地区:
COSC 320 – 001
Analysis of Algorithms
2020 Winter Term 2
Project Topic Number: 5
Analysis of the algorithm: An Informed Search Strategy
Before we talk about the pseudo-code, we form the question almost same as the we
did in the first milestone, specifically:
States: Each state is basically representing a city on the map.
Initial state: Whatever the user decides to be.
Actions: A set of flights originating from the current city. For each flight, we have
flight fee, flight time, and waiting time.
Transition Model: (Referring to the definition) The action of taking P from A
would result in B.
Goal Test: If we are at the final location (the destination).
Path Cost: The result would be a set of actions, namely p = {P1, P2, …} that would
transfer the initial state to the goal state. Hence, the Path Cost would be the total
financial cost, waiting time between flights, and flight time. Different from Last
time, the Path Cost (g(n)) would work with a consistent heuristic function,
namely h(n), to decide which node to expand.
We call the function𝒇(𝒏) = 𝒈(𝒏) + 𝒉(𝒏): the estimated cost of cheapest path
cost from initial state to the goal state at node n.
A Consistent Heuristic:
We would use the same an artificial dataset that contains random statistics as the
previous milestone is, but we would add another matrix, namely D, to provide the extra
information to derive the h(n). In particular, the matrix defines the real distances
between any two cities.
∀𝐴, 𝐵 ∈ 𝑆, 𝑑𝐴,𝐵 𝑑𝑒𝑓𝑖𝑛𝑒𝑠 𝑡ℎ𝑒 𝑟𝑒𝑎𝑙 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑐𝑖𝑡𝑦 𝐴, 𝐵
𝑊ℎ𝑒𝑟𝑒 𝑆 𝑖𝑠 𝑡ℎ𝑒 𝑠𝑒𝑡 𝑜𝑓 𝑎𝑙𝑙 𝑠𝑡𝑎𝑡𝑒𝑠.
Pseudo-code
This time, we approach the problem using A* Search. Similar to Uniform Cost
Search, we use a priority queue to help us decide the path. This time, we use the
estimation g(n) instead of path cost.
define node with the state as problem’s initial state, path cost zero //initialization
define PriorityQueue
frontier to store all the nodes and sort by the estimated
cost
define Set explored //to be filled
while(true)
if frontier is empty then return failure //no solution
pop frontier and set node to it //now node is the lowest cost in frontier
if node is at goal state then return solution //there is optimal solution
add the state of node to the explored list
now iterate through all available actions at node
define child as the successor we are looking at in this iteration
if child’s state is not in frontier or explored then add it in to the frontier
else if child’s state is in frontier and child has a lower estimated cost// notice
that we use an “estimated cost” instead of “path cost” here
then update the frontier with the child //to get optimal solution
Proof of Correctness:
A* Search provides an optimal solution if such solution exists.
But, before we prove the correctness, let’s prove that the heuristic function h(n) is
consistent. In other words, the cost of any node n to its predecessor, namely n’, plus
its estimated cost is always greater or equal to n’s estimated cost.
ℎ(𝑛) ≤ 𝑐(𝑛, 𝑃𝑛,𝑛′
, 𝑛
′
) + ℎ(𝑛′)
Proof:
Recall that we define the path cost to be a sum of three terms:
𝑐(𝑛, 𝑃𝑛,𝑛′
, 𝑛
′
) = 𝑘1 ∙ 𝑔1 + 𝑘2 ∙ 𝑔2 + 𝑘3 ∙ 𝑔3𝑤ℎ𝑒𝑟𝑒 𝑘1 ≥ 1 , 𝑘2, 𝑘3 ≥ 0 &
𝑔1, 𝑔2, 𝑔3 𝑟𝑒𝑝𝑟𝑒𝑠𝑒𝑛𝑡𝑠 𝑡ℎ𝑒 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒, 𝑓𝑙𝑖𝑔ℎ𝑡 𝑡𝑖𝑚𝑒 𝑎𝑛𝑑 𝑤𝑎𝑖𝑡𝑖𝑛𝑔 𝑡𝑖𝑚𝑒
From this, we can derive that:
𝑔1
(𝑛, 𝑛′) ≤ 𝑘1 ∙ 𝑔1 + 𝑘2 ∙ 𝑔2 + 𝑘3 ∙ 𝑔3 = 𝑐(𝑛, 𝑃𝑛,𝑛
′ , 𝑛
′
) (𝑆0)
Now, according to the triangular inequality:
ℎ(𝑛) ≤ 𝑔1
(𝑛, 𝑛′) + ℎ(𝑛
′
)
Take in Statement 0 yields this:
ℎ(𝑛) ≤ 𝑐(𝑛, 𝑃𝑛,𝑛
′ , 𝑛
′
) + ℎ(𝑛
′
)
Lastly, add the g(n) on both sides, we have completed the proof:
𝑓(𝑛
′
) = 𝑔(𝑛
′
) + ℎ(𝑛) = 𝑔(𝑛) + 𝑐(𝑛, 𝑃𝑛,𝑛′
, 𝑛
′
) + ℎ(𝑛
′
) ≥ 𝑔(𝑛) + ℎ(𝑛)
Now that we have proved the heuristic function is consistent, we have basically
derived that “the values of estimations are always increasing along the path). See this:
∀𝑛 ∈ 𝑆 𝑤ℎ𝑒𝑟𝑒 𝑛 ℎ𝑎𝑠 𝑎 𝑠𝑢𝑐𝑐𝑒𝑠𝑠𝑜𝑟 𝑛𝑎𝑚𝑒𝑙𝑦 𝑛′, 𝑓(𝑛
′
) ≥ 𝑔(𝑛) + ℎ(𝑛)
Now let’s prove with induction that whenever the A* search expanded a node, it
expands the node with an optimal path. (Notice that this is not exactly same as
proving A* search yields the optimal solution. What we are going to prove contains
the statement.)
Base Case: The first node is always expanded with an optimal cost of 0.
Inductive Step: We argue by contradiction.
We assume the IH holds that all the nodes up to 𝑛0 are expanded with an
optimal cost. However, it would be absurd if we assume that 𝑛0′ is not expanded
with an optimal cost. Since there would have been another 𝑛′ sitting on the
presumably more optimal path that would have been selected by the priority
queue in the first place.
Hence, 𝐼𝑛𝑖𝑡𝑖𝑎𝑙 𝑆𝑡𝑎𝑡𝑒 ~ 𝑛0 𝑏𝑒𝑖𝑛𝑔 𝑒𝑥𝑝𝑎𝑛𝑒𝑑 𝑤𝑖𝑡ℎ 𝑜𝑝𝑡𝑖𝑚𝑎𝑙 𝑠𝑜𝑙
′𝑛
𝑦𝑖𝑒𝑙𝑑𝑠
→ 𝑛0
′ 𝑏𝑒𝑖𝑛𝑔 𝑒𝑥𝑝𝑎𝑛𝑒𝑑 𝑤𝑖𝑡ℎ 𝑜𝑝𝑡𝑖𝑚𝑎𝑙 𝑠𝑜𝑙′𝑛
Conclusion: By the principle of Strong Induction, we have derived that all nodes
in A* search are expanded with optimal solution.
Hence, A* search provide optimal solution to a graph search problem.
Running Time: A* search's time complexity is determined by the heuristic. The
number of nodes extended in the worst case of an unbounded search space is
exponential in the depth of the solution (the shortest path) d: 𝑂(𝑏
𝑑
), where b is the
branching factor (the average number of successors per state). This assumes that a
goal state exists at all, and is reachable from the start state; if it is not, and the state
space is infinite, the algorithm will not terminate.
The time complexity is polynomial when the search space is a tree, there is a single
goal state, and the heuristic function h meets the following condition:
where h* is the optimal heuristic, the exact cost to get from x to the goal. In other
words, the error of h will not grow faster than the logarithm of the "perfect
heuristic" h* that returns the true distance from x to the goal. [2]
Data Structure.
A priority queue is commonly used in A* implementations to perform the repeated
collection of minimum (estimated) cost nodes to extend. The open set, also known as
the fringe, is a priority queue. The node with the lowest f(x) value is removed from
the queue at each step of the algorithm, and its neighbors’ f and g values are modified
accordingly, and these neighbors are returned to the queue. The algorithm continues
until a target node is found (the node with the lowest F value of all fringe nodes).
Since h at the target is zero in a consistent heuristic, the F value of that goal is also the
cost of the shortest path. [3]
Unexpected Cases/Difficulties.
One of the difficulties is the dataset: how are we defining the path cost and estimated
cost matrix exactly? Same as what we’ve mentioned in the last milestone, when we
define a path cost P, we define it as x1*f1+ x2*f2+ x3*f3 where f is in the unit of CAD
or hours and x is empirically determined.
However, when we look at the heuristic function, we are measuring the distance
directly. It guarantees the function to be consistent, while it does not incorporate time
elements. One reason is that flight time and wait time estimations are untrivial to
derive when we try to look at two cities that do not have any available flight in
between. In fact, we cannot provide any coefficient k based on existing factors such
that: 𝑘 > 1, 𝑘 ∈ ℝ & 𝑓(𝑛) = 𝑔(𝑛) + 𝑘 ∗ ℎ(𝑛), 𝑤ℎ𝑒𝑟𝑒 𝑘 ∗ ℎ(𝑛) 𝑖𝑠 𝑎𝑑𝑚𝑖𝑠𝑠𝑖𝑏𝑙𝑒
We will look into this problem again when we implement the function. If it turns out
such k can be derived, we will modify the pseudo-code and provide the proof of
correctness again.
Task Separation and Responsibilities.
Jack Wang did the first draft of the Second Milestone including Data Structure and
Running Time.
Larry Gu revised the first draft, specifically, he:
rewrote the Analysis of the algorithm
provided explanations for the heuristic function
provided the Pseudo-code
rewrote the Proof of Correctness
rewrote the Unexpected Cases/Difficulties.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!