0% found this document useful (0 votes)
7 views

AI Ch3

Artifical Intelligence
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

AI Ch3

Artifical Intelligence
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Chapter3

State Search Space

• Problems are solved by searching among alternative choices.


– Humans consider a number of alternative strategies on their way to solving a problem.
– A Chess player considers a number of alternative moves.
– A mathematician chooses from a different strategies to find a proof for a theorem.
– A physician evaluates a number of possible diagnoses.
‫مساحة البحث الحالية‬
.‫ُتحل المشاكل من خالل البحث بين الخيارات البديلة‬ •
.‫ُيعتبر البشر عدًدا من االستراتيجيات البديلة في طريقهم لحل مشكلة ما‬ –
.‫ُيعتبر العب الشطرنج عدًدا من الحركات البديلة‬ –
.‫يختار عالم الرياضيات من بين استراتيجيات مختلفة للعثور على دليل لنظرية معينة‬ –
‫يقوم الطبيب بتقييم عدد من التشخيصات المحتملة‬ –

Page 1 of 31
By: Muhammad Mahmoud
How human beings think?
• Human beings do not search the entire state space (exha ustive search).
• Only alternatives that experience has shown to be effective are explored.
• Human problem solving is based on judgmental rules that limit the exploration of
search space to those portions of state space that seem somehow promising.
• These judgmental rules are known as “heuristics”.
‫كيف يفكر البشر؟‬
.)‫• البشر ال يبحثون في جميع مساحة الحالة (البحث الشامل‬
.‫• يتم استكشاف البدائل فقط التي أظهرت التجربة أنها فّعالة‬
‫• حل مشاكل البشر يعتمد على قواعد استداللية تقّيد استكشاف مساحة البحث إلى تلك األجزاء من‬
.‫مساحة الحالة التي تبدو واعدة بطريقة ما‬
."‫• ُتعرف هذه القواعد االستداللية باسم "الخوارزميات االستداللية‬
All AI is search ?
• Not totally true (obviously) but more true than you might think.
• All life is problem solving !!
Finding a good/best solution to a problem between many possible solutions
‫هل كل الذكاء الصناعي هو بحث؟‬
.‫• ليس صحيًح ا تماًم ا (بوضوح) ولكنه أكثر صحة مما قد تعتقد‬
!‫• جميع الحياة هي حل مشكالت‬
.‫ أفضل لمشكلة بين العديد من الحلول الممكنة‬/ ‫البحث عن حل جيد‬

Problem-Solving Agents

• A kind of goal-based agents that decide what to do by finding sequences of actions


that lead to desirable states.

• Goals help to organize behavior by limiting the objectives that the agent is trying to
achieve.
‫وكالء حل المشكالت‬

‫• نوع من الوكالء المبنيين على األهداف يقررون ما يجب فعله عن طريق العثور على سالسل من‬
.‫األفعال التي تؤدي إلى حاالت مرغوب فيها‬

.‫• تساعد األهداف في تنظيم السلوك من خالل تحديد األهداف التي يحاول الوكيل تحقيقها‬

Page 2 of 31
By: Muhammad Mahmoud
Example: Romania

On holiday in Romania; currently in Arad, Flight leaves tomorrow from Bucharest.


 Formulate goal:
 be in Bucharest

 Formulate problem:
 states: various cities
 actions: drive between cities

 Find solution:
 sequence of cities, e.g.,
Arad, Sibiu, Fagaras, Bucharest

‫ رومانيا‬:‫مثال‬
.‫ الرحلة تغادر غًدا من بوخارست‬،‫في عطلة في رومانيا؛ حالًيا في أراد‬

:‫ صياغة المشكلة‬- :‫ العثور على الحل‬-


:‫ صياغة الهدف‬-
‫ مختلف المدن‬:‫ الحاالت‬- ‫ على‬،‫ تسلسل من المدن‬-
‫ القيادة بين‬:‫ األفعال‬-
‫بوخارست‬
،‫سيبيو‬ ،‫ أراد‬،‫المثال‬ ‫ أنسبيل‬-
‫يكون في‬

‫المدن‬ ‫ بوخارست‬،‫فاجاراس‬

Problem Solving Agent (cont.)


 Goal formulation is the first step in problem solving, based on the current situation
and the agent’s performance measure.

 Problem formulation is the process of deciding what actions and states to consider,
given the goal formulation.

‫وكيل حل المشكالت‬
‫ صياغة الهدف هي الخطوة األولى في‬-
‫ استناًدا إلى الوضع الحالي‬،‫حل المشكالت‬
.‫وقياس أداء الوكيل‬

‫ صياغة المشكلة هي عملية اتخاذ قرار‬-


‫بشأن اإلجراءات والحاالت التي يجب‬
.‫ بناًء على صياغة الهدف‬،‫النظر فيها‬

Page 3 of 31
By: Muhammad Mahmoud
Problem Solving Agent (cont.)

• An agent with several immediate options of unknown value can decide what to do by
first examining different possible sequences of actions that lead to states of known
value, and then choosing the best sequences.
 The process of looking for a sequence of actions that reaches
the goal is called search.
 A search algorithm takes a problem as input and returns a
solution in the form of an action sequence.
 Once a solution is found, the actions it recommends can be carried out through
the execution phase.
 Thus, the agent design is simply consists of “formulate, search, execute”
phases.
• Once the solution has been executed, the agent will formulate a new
goal.

‫• الوكيل الذي يمتلك عدة خيارات فورية ذات قيمة غير معروفة يمكنه اتخاذ قرار حول ما‬
‫يجب القيام به من خالل دراسة مختلف سالسل األفعال الممكنة التي تؤدي إلى حاالت ذات‬
.‫ ثم اختيار أفضل السالسل‬،‫قيمة معروفة‬
.‫ العملية التي يتم فيها البحث عن سلسلة من األفعال التي تصل إلى الهدف تسمى بالبحث‬-
.‫ خوارزمية البحث تأخذ مشكلة كمدخالت وتعيد حًال في شكل سلسلة من األفعال‬-
.‫ يمكن تنفيذ اإلجراءات التي يوصي بها من خالل مرحلة التنفيذ‬،‫ بمجرد العثور على الحل‬-
."‫ تنفيذ‬،‫ بحث‬،‫ تصميم الوكيل يتكون ببساطة من مراحل "صياغة‬،‫ بالتالي‬-
.‫ سيقوم الوكيل بصياغة هدف جديد‬،‫بمجرد تنفيذ الحل‬

Problem Solving Agent (Function)

Page 4 of 31
By: Muhammad Mahmoud
Problem Solving Agent (cont.)

• We will consider the problem of designing goal-based agents in fully observable,


deterministic, discrete, known environments.

• The agent must find a sequence of actions that reaches the goal.
• The performance measure is defined by:
 (a) reaching the goal, and …
 (b) how “expensive” the path to the goal is.
.‫سننظر في مشكلة تصميم الوكالء المبنية على األهداف في بيئات معروفة تماًما ومحددة وغير مستمرة‬
.‫ يجب على الوكيل أن يجد سلسلة من األفعال التي تصل إلى الهدف‬-
:‫ تحدد قياسات األداء عن طريق‬-
...‫ و‬،‫) الوصول إلى الهدف‬a(
.‫) كيفية "تكلفة" المسار إلى الهدف‬b(

Problem formulation & Solution ‫صياغة المشكلة والحل‬


A problem is really a collection of information that the agent will use to decide what to do.

 A problem can be defined formally by five components:


1. The initial state that the agent starts in.

2. A description of the possible actions available to the agent.


Page 5 of 31
By: Muhammad Mahmoud
3. A description of what each action does; named transition model.

4. The goal test, which determines whether a given state is a goal state.

5. A path cost function that assigns a numeric cost to each path.

‫المشكلة في الواقع هي مجموعة من المعلومات التي سيستخدمها الوكيل التخاذ قرار بما‬
.‫يجب القيام به‬
:‫يمكن تعريف المشكلة رسمًيا من خالل خمس مكونات‬
.‫ الحالة االبتدائية التي يبدأ الوكيل فيها‬.1
.‫ وصف لألفعال الممكنة المتاحة للوكيل‬.2
.‫ وصف لما يقوم به كل فعل؛ نموذج االنتقال المسمى‬.3
.‫ الذي يحدد ما إذا كانت حالة معينة هي حالة هدف‬،‫ اختبار الهدف‬.4
.‫ وظيفة تكلفة المسار التي تعين تكلفة عددية لكل مسار‬.5

Ex: Map Navigation problem formulation

A problem is defined by Five items:


1. initial state
» "at Arad"
2. actions
»e.g., from the state In(Arad),
the applicable actions are {Go(Sibiu), Go(Timisoara), Go(Zerind)}.
3. Transition model :
» we have RESULT(In(Arad), Go(Zerind)) = In(Zerind)
» or successor function Succ(x) = set of action–state pairs
e.g., Succ(In(Arad)) = {<Go(Zerind), In(Zerind)>, … }
4. goal test, can be
» explicit, e.g., x = "at Bucharest"
» implicit, e.g., Checkmate(x)
5. path cost (additive)
» e.g., sum of distances, number of actions executed, etc.
» c(x,a,y) is the step cost, assumed to be ≥ 0

 A solution is a sequence of actions leading from the initial state (Arad) to a goal
state (Bucharest).
‫صياغة مشكلة تنقل الخريطة‬

Page 6 of 31
By: Muhammad Mahmoud
‫يتم تعريف المشكلة بخمس عناصر‪.1 :‬الحالة االبتدائية‬
‫» "في أراد"‬
‫‪ .2‬األفعال‬
‫» على سبيل المثال‪ ،‬من الحالة "في أراد"‪،‬‬
‫األفعال المطبقة هي {االنتقال إلى سيبيو‪ ،‬االنتقال إلى تيميشوارا‪ ،‬االنتقال إلى زيريند}‪.‬‬
‫‪ .3‬النموذج االنتقالي‪:‬‬
‫» لدينا نموذج ‪(RESULT‬في أراد‪ ،‬االنتقال إلى زيريند) = في زيريند‬
‫» أو دالة الخطوة التالية )‪ = Succ(x‬مجموعة من أزواج الفعل والحالة مثاًل ‪(Succ ،‬في أراد) = {<االنتقال إلى‬
‫زيريند‪ ،‬في زيريند>‪}... ،‬‬
‫‪ .4‬اختبار الهدف‪ ،‬ويمكن أن يكون‬
‫» صريًح ا‪ ،‬على سبيل المثال‪" = x ،‬في بوخارست"‬
‫» ضمنًيا‪ ،‬على سبيل المثال‪ ،‬اختبار الخسارة ()‪)Checkmate(x‬‬
‫‪ .5‬تكلفة المسار (إضافية)‬
‫» على سبيل المثال‪ ،‬مجموع المسافات‪ ،‬عدد اإلجراءات التنفيذية‪ ،‬وما إلى ذلك‪.‬‬
‫» )‪ c(x، a، y‬هو تكلفة الخطوة‪ ،‬وُيفترض أن تكون ≥ ‪0‬‬

‫الحل هو تسلسل من األفعال الذي يقود من الحالة االبتدائية (أراد) إلى حالة هدف (بوخارست)‬

‫‪Ex: Vacuum cleaner Problem‬‬

‫‪formulation‬‬
‫‪Agent location and dirt location o‬‬
‫?‪o How many possible states‬‬
‫?‪o What if there are n possible locations‬‬
‫‪o The size of the state space grows exponentially‬‬
‫!‪o with the “size” of the world‬‬
‫–‬ ‫‪Let the world contain just two locations.‬‬
‫–‬ ‫‪Each location may or may not contain dirt.‬‬
‫–‬ ‫‪The agent may be in one location or the other.‬‬
‫–‬ ‫‪Then, there are 8 possible world states.‬‬

‫‪Page 7 of 31‬‬
‫‪By: Muhammad Mahmoud‬‬
‫–‬ ‫‪A larger environment with n locations has States.‬‬
‫?‪Actions‬‬
‫‪• The agent has three possible actions: Left, Right, and Suck.‬‬
‫?‪Goal‬‬
‫‪• The goal is to clean up all the dirt - set of goal states is{7,8}.‬‬

‫مشكلة مكنسة الكهرباء‬


‫تعريف المشكلة‪:‬‬
‫‪ -‬موقع الوكيل وموقع األتربة‪.‬‬
‫‪ -‬كم عدد الحاالت الممكنة؟‬
‫‪ -‬ماذا لو كان هناك ‪ n‬مواقع ممكنة؟‬
‫‪ -‬يزداد حجم مساحة الحالة بشكل متسارع مع "حجم" العالم!‬
‫‪ -‬افترض أن العالم يحتوي فقط على موقعين‪.‬‬
‫‪ -‬كل موقع قد يحتوي على أتربة أو قد ال يحتوي‪.‬‬
‫‪ -‬قد يكون الوكيل في موقع أو اآلخر‪.‬‬
‫‪ -‬بالتالي‪ ،‬هناك ‪ 8‬حاالت عالمية ممكنة‪.‬‬
‫‪ -‬بيئة أكبر تحتوي على ‪ n‬مواقع لها حاالت‪.‬‬
‫األفعال؟‬
‫‪ -‬الوكيل لديه ثالثة أفعال ممكنة‪ :‬اليسار‪ ،‬اليمين‪ ،‬والتنظيف‪.‬‬
‫الهدف؟‬
‫‪ -‬الهدف هو تنظيف كل األتربة ‪ -‬مجموعة من الحاالت الهدف هي {‪.}8 ،7‬‬

‫‪Ex: Vacuum world state space graph‬‬

‫•‬ ‫‪states? figure dirt and robot locations (ignore dirt‬‬


‫)‪amounts‬‬ ‫مثال‪ :‬رسم مساحة الحالة لعالم المكانس الكهربائية‬
‫•‬ ‫‪actions? Left, Right, Suck‬‬
‫‪ -‬الحاالت‪ :‬صورة لمواقع األتربة ومواقع الروبوت (تجاهل‬
‫•‬ ‫‪goal test? no dirt at all locations‬‬ ‫كميات األتربة)‬
‫•‬ ‫‪path cost? 1 per action‬‬ ‫‪ -‬األفعال‪ :‬يسار‪ ،‬يمين‪ ،‬تنظيف‬
‫‪ -‬اختبار الهدف‪ :‬عدم وجود أتربة في جميع المواقع‬
‫‪ -‬تكلفة المسار‪ 1 :‬لكل إجراء‬

‫‪Page 8 of 31‬‬
‫‪By: Muhammad Mahmoud‬‬
Ex: The 8-puzzle

• states? locations of tiles ‫• الحاالت؟ مواقع القطع‬


• actions? move blank left, right, up, down ،‫• األفعال؟ نقل القطعة الفارغة يساًر ا‬
• goal test? = goal state (given) ‫ ألسفل‬،‫ ألعلى‬،‫يميًنا‬
• path cost? 1 per move ‫• اختبار الهدف؟ = الحالة الهدف‬
)‫(المعطاة‬

Ex: Robot motion planning

Page 9 of 31
By: Muhammad Mahmoud
• states? real-valued coordinates of robot joint angles parts of the object to be
assembled (angles, displacements).
• actions? continuous motions of robot joints
• goal test? complete assembly , Configuration in which object is grasped.
• path cost? time to execute
.)‫ انحرافات‬،‫• الحاالت؟ إحداثيات حقيقية لزوايا مفاصل الروبوت وأجزاء الكائن المراد تجميعه (زوايا‬
.‫• األفعال؟ حركات مستمرة لمفاصل الروبوت‬
.‫ تكوين يتم فيه إمساك الكائن‬،‫• اختبار الهدف؟ تجميع كامل‬
.‫• تكلفة المسار؟ الوقت الالزم للتنفيذ‬

Example: Tic-Tac-Toe
• Nodes(N): all the different configuration of Xs and Os that the game can have.
• Arcs (A): generated by legal moves by placing an X or an O in unused location.
• Start state (S): an empty board.
• Goal states (GD): a board state having three Xs in a row, column, or diagonal.
• The arcs are directed, then no cycles in the state space, directed acyclic graph
(DAG).
• Complexity: 9! Different paths can be generated.
.‫ التي يمكن أن تتبعها اللعبة‬Os ‫ و‬Xs ‫ جميع التكوينات المختلفة لـ‬:)N( ‫• العقد‬
.‫ في الموقع الغير مستخدم‬O ‫ أو‬X ‫ ُتولد بواسطة الحركات القانونية عن طريق وضع‬:)A( ‫• األسهم‬
.‫ لوح فارغ‬:)S( ‫• الحالة االبتدائية‬
.‫ في صف أو عمود أو قطر‬Xs ‫ حالة لوح تحتوي على ثالثة‬:)GD( ‫• حاالت الهدف‬
.)DAG( ‫ مخطط موجه دائري‬،‫ ثم ال توجد دورات في مساحة الحالة‬،‫• األسهم موجهة‬
.‫! يمكن توليد مسارات مختلفة‬9 :‫• التعقيد‬

Problem Types ‫أنواع المشكالت‬

:‫هناك أربعة أنواع أساسية من المشكالت‬


Page 10 of 31
By: Muhammad Mahmoud ‫ المشكالت ذات الحالة الواحدة‬.1
There are four essentially different types of problems:

1. Single-state problems

2. Multiple-state (sensor less) problems

3. Contingency problems

4. Exploration problems

1- Single-State Problem

 Single-state problems
» The agent’s sensors provide enough information for the agent to tell exactly which
state it is in  Fully observable.

» The agent knows exactly the effects of all its actions  Deterministic.

» Then, the agent can calculate exactly which state it will be in after any sequence of
actions.
:‫المشكالت ذات الحالة الواحدة‬
‫ حيث توفر أجهزة االستشعار للوكيل ما يكفي من المعلومات ليعرف بالضبط في أي حالة‬-
.‫يتواجد => مرئي بالكامل‬
.‫ يعرف الوكيل تماًما تأثيرات جميع أفعاله => قطعي‬-
.‫ يمكن للوكيل حساب بالضبط في أي حالة سيكون بعد أي تسلسل من األفعال‬،‫ بعد ذلك‬-

Ex: Vacuum Cleaner as Single-state


problem

.
 initial state: 5.

 The goal is to clean up all the dirt


- set of goal states is {7,8}.

 Solution?
-The action sequence [Right, Suck] will
get to a goal state

2- Multiple-State Problem
Page 11 of 31
By: Muhammad Mahmoud
 Multiple-state (sensorless)

 problems
» The agent is not certain about which state in a given set of states it is in (has limited
access to the world state)  Non-observable.

» The agent knows exactly the effects of all its actions  Deterministic.

» the agent must reason about sets of states that it might get to, rather than single
states.
:)‫المشكالت ذات الحاالت المتعددة (بدون استشعار‬
‫ الوكيل غير متأكد من الحالة التي يتواجد فيها ضمن مجموعة معينة من الحاالت (لديه وصول‬-
.‫محدود إلى حالة العالم) => غير مرئي‬
.‫ الوكيل يعرف تماًما تأثيرات جميع أفعاله => قطعي‬-
.‫ بدًال من حاالت فردية‬،‫ يجب على الوكيل التفكير في مجموعات من الحاالت التي قد يصل إليها‬-

Ex: Vacuum Cleaner as Multiple-state


problem

q Initial state:
start with one of the set {1, 2, 3, 4, 5, 6, 7,
8}.

q Goal: {7,8}.

q Solution? [right, suck, left, suck]


Ø Right à {2; 4; 6; 8}
Ø Suck à {4; 8}
Ø Left à {3; 7}
Ø Suck à {7}

3- Contingency problems

Page 12 of 31
By: Muhammad Mahmoud
 Contingency problems
» Nondeterministic and/or partially observable

» Solving this problem requires sensing during the execution phase.


 Percepts provide new information about current state

» The agent must now calculate a whole tree of actions, rather than a single
action sequence.
 Each branch of the tree deals with a possible contingency that
might arise.
:‫مشكالت الظروف‬
.‫أو جزئيًا مرئية‬/‫ قد تكون غير قطعية و‬-
.‫ حل هذه المشكلة يتطلب االستشعار خالل مرحلة التنفيذ‬-
.‫ اإلدراكات توفر معلومات جديدة حول الحالة الحالية‬-
.‫ بدًال من تسلسل اإلجراء الفردي‬،‫ يجب على الوكيل اآلن حساب شجرة كاملة من اإلجراءات‬-
.‫ كل فرع من الشجرة يتعامل مع ظروف محتملة قد تنشأ‬-

Ex: Vacuum Cleaner as Contingency


Problem

 Percept : [L, Clean]

 Initial state: one of the set


{5,7}

 Goal: {7,8}.

 Solution?
[Right, if dirt then Suck].

4-Exploration problems

Page 13 of 31
By: Muhammad Mahmoud
 Exploration problems:
» Unknown state space (as lost in a desert without a map)

» The agent must experiment, gradually discovering what its actions do and what sorts
of states exist.

» This is a kind of search, but a search in the real world rather than in a model there of.

» If it survives, the agent learns a "map" of the environment, which it can then use to
solve subsequent problems.

:‫مشكالت االستكشاف‬
.)‫ مساحة الحالة غير معروفة (مثل الضياع في الصحراء بدون خريطة‬-
.‫ واكتشاف تدريجي لما تقوم به أفعاله وأنواع الحاالت الموجودة‬،‫ يجب على الوكيل التجريب‬-
.‫ ولكن بحث في العالم الحقيقي بدًال من نموذج له‬،‫ هذا نوع من البحث‬-
‫ التي يمكنه بعد ذلك استخدامها لحل المشاكل‬،‫ يتعلم الوكيل "خريطة" للبيئة‬،‫ إذا نجا‬-
.‫الالحقة‬

Basic Idea
Page 14 of 31
By: Muhammad Mahmoud
• Let’s begin at the start state and expand it by making a list of all possible
successor states.
• Maintain a frontier or a list of unexpanded states (open list).

• At each step, pick a state from the frontier to expand.

• Keep going until you reach a goal state.

 Try to expand as few states as possible.

‫لنبدأ من الحالة االبتدائية ونوسعها عن طريق إنشاء قائمة بجميع‬


.‫الحاالت الالحقة الممكنة‬
‫• االحتفاظ بحافة أو قائمة بالحاالت غير الموسعة (القائمة‬
.)‫المفتوحة‬
.‫ اختر حالة من الحافة للتوسيع‬،‫• في كل خطوة‬
.‫• استمر حتى تصل إلى حالة هدف‬

Search: Basic idea Search: Basic Search: Basic idea

idea

Search: Basic idea Search: Basic Idea Search: Basic idea


Search: Basic idea

Search: Basic

Search: Basic idea idea

Page 15 of 31
By: Muhammad Mahmoud
Search: Basic idea Search: Basic

idea

Search: Basic

idea

Searching for Solutions

• Search algorithms work by considering various possible


action sequences.
• The action sequences start with the initial state form a search tree

Page 16 of 31
By: Muhammad Mahmoud
where:
 The root of the tree is start state;
 The branches are actions ;and

 The nodes correspond to states in the state space


of the problem.

‫• تعمل خوارزميات البحث عن طريق النظر في مجموعات‬


.‫مختلفة من تسلسالت األفعال الممكنة‬
‫• تبدأ تسلسالت األفعال من الحالة االبتدائية لتشكل شجرة‬
:‫بحث حيث‬
‫ جذر الشجرة هو الحالة االبتدائية؛‬-
‫ الفروع هي األفعال؛ و‬-
.‫ العقد تتوافق مع الحاالت في مساحة الحالة للمشكلة‬-

Tree Search Algorithm Outline

• Initialize the frontier using the starting state.


• While the frontier is not empty:

– Choose a frontier node according to search strategy and take it


off the frontier.

– If the node contains the goal state, return solution.

– Else expand the node and add its children to the frontier.

.‫• قم بتهيئة الحافة باستخدام الحالة االبتدائية‬


:‫• طالما الحافة غير فارغة‬
.‫ اختر عقًدا من الحافة وفًقا الستراتيجية البحث واخرجه من الحافة‬-
.‫ فعد بالحل‬،‫ إذا احتوى العقد على حالة هدف‬-
.‫ قم بتوسيع العقد وأضف أطفاله إلى الحافة‬،‫ في غير ذلك‬-

Tree search: Example


Frontier = Start State

Page 17 of 31
By: Muhammad Mahmoud
Tree search: Example

Frontier

Choose one from


frontiers to expand

New
frontiers

Page 18 of 31
By: Muhammad Mahmoud
Tree Search Algorithm

Search algorithms all share this basic structure; they vary primarily
according to how they choose which state to expand next—the so-
called search strategy.
‫خوارزميات البحث تشترك جميعها في هذا الهيكل األساسي؛ وتختلف أساسًا وفًقا لكيفية‬
.‫ ما ُيعرف باستراتيجية البحث‬- ‫اختيارها للحالة التي ستوسع بعدها‬

Page 19 of 31
By: Muhammad Mahmoud
Repeated states

• In(Arad) is a repeated state in the search tree, generated in this case by a loopy
path.
• Considering such loopy paths means that the complete search tree for Romania
is infinite.
• loops can cause certain algorithms to fail.

• So, we need to avoid theses repeated states.

‫ هي حالة متكررة في شجرة‬In(Arad) ‫• حالة‬


‫ تم إنشاؤها في هذه الحالة بواسطة‬،‫البحث‬
.‫مسار دائري‬
‫• التفكير في مثل هذه المسارات الدائرية‬
‫يعني أن شجرة البحث الكاملة لرومانيا غير‬
.‫محدودة‬
‫• يمكن أن تتسبب الحلقات في فشل بعض‬
.‫الخوارزميات‬
‫ نحتاج إلى تجنب هذه الحاالت‬،‫• لذلك‬
.‫المتكررة‬

Avoiding Repeated States

• The way to avoid exploring redundant paths that caused by repeated states is to
remember where state has been.
–To do this, we enhance the TREE-SEARCH algorithm with a data structure called the
explored set (also known as the closed list), which remembers every expanded node.
–Newly generated nodes that match previously generated nodes can be discarded instead
of being added to the frontier.

• The new algorithm is called GRAPH-SEARCH and it is more efficient on problems with
many repeated states.

‫• الطريقة لتجنب استكشاف المسارات الزائدة التي تسببت فيها الحاالت المتكررة هي تذكر مواقع تلك‬
.‫الحاالت‬
‫ نعزز خوارزمية البحث في الشجرة ببنية بيانات ُتسمى مجموعة االستكشاف (المعروفة‬،‫ للقيام بذلك‬-
.‫ التي تذكر كل عقد تم توسيعه‬،)‫أيًض ا باسم القائمة المغلقة‬
.‫ يمكن التخلص من العقد الجديدة التي تطابق العقد السابقة المولدة بدًال من إضافتها إلى الحافة‬-

‫ وهي أكثر كفاءة في المشكالت التي تحتوي على العديد‬GRAPH-SEARCH ‫• ُتسمى الخوارزمية الجديدة‬
.‫من الحاالت المتكررة‬

Page 20 of 31
By: Muhammad Mahmoud
Graph-Search Algorithm

Infrastructure for search algorithms

• For each node n of the tree, we have a structure that contains four components:

• n.STATE: the state in the state space to which the node corresponds;

• n.PARENT: the node in the search tree that generated this node;

• n.ACTION: the action that was applied to the parent to generate the node;

• n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to
the node, as indicated by the parent pointers.
:‫ لدينا هيكل يحتوي على أربع مكونات‬،‫ في الشجرة‬n ‫• لكل عقد‬
.‫ الحالة في مساحة الحالة التي يتوافق معها العقد‬:n.STATE •
.‫ العقد في شجرة البحث الذي أنشأ هذا العقد‬:n.PARENT •
.‫ اإلجراء الذي تم تطبيقه على األب إلنشاء العقد‬:n.ACTION •
.‫ كما ُيشير إليه مؤشرات األب‬،‫ للمسار من الحالة االبتدائية إلى العقد‬،g(n) ‫ المعتادة تمييزًا ب‬،‫ التكلفة‬:n.PATH-COST •

Graph-Search Algorithm

Page 21 of 31
By: Muhammad Mahmoud
Infrastructure for search algorithms

• For each node n of the tree, we have a structure that contains four components:

• n.STATE: the state in the state space to which the node corresponds;

• n.PARENT: the node in the search tree that generated this node;

• n.ACTION: the action that was applied to the parent to generate the node;

• n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to
the node, as indicated by the parent pointers.
:‫ لدينا هيكل يحتوي على أربع مكونات‬،‫ في الشجرة‬n ‫• لكل عقد‬
.‫ الحالة في مساحة الحالة التي يتوافق معها العقد‬:n.STATE •
.‫ العقد في شجرة البحث الذي أنشأ هذا العقد‬:n.PARENT •
.‫ اإلجراء الذي تم تطبيقه على األب إلنشاء العقد‬:n.ACTION •
‫ كما ُيشير‬،‫ للمسار من الحالة االبتدائية إلى العقد‬،g(n) ‫ المعتادة تمييزًا ب‬،‫ التكلفة‬:n.PATH-COST •
.‫إليه مؤشرات األب‬

Implementation: States vs. nodes

• State : A (representation of) a physical configuration

• Node: A data structure constituting part of a ` search tree

• (includes parent, children, depth, path cost, etc.)

.‫ تمثيل لتكوين فيزيائي‬:‫• الحالة‬


‫ هيكل بيانات يشكل جزًءا‬:‫• العقد‬
،‫من شجرة البحث (يتضمن األب‬
.)‫ إلخ‬،‫ تكلفة المسار‬،‫ العمق‬،‫األطفال‬

Search strategies

A search strategy is defined by picking the order of node expansion


 Strategies are evaluated along the following dimensions:
 completeness: does it always find a solution if one exists?
 time complexity: number of nodes generated
 space complexity: maximum number of nodes in memory

Page 22 of 31
By: Muhammad Mahmoud
 optimality: does it always find a least-cost solution?

.‫إستراتيجية البحث ُتعرف من خالل اختيار ترتيب توسيع العقد‬


:‫االستراتيجيات ُتقَّيم على األبعاد التالية‬
‫ هل تجد دائًما حًال إذا كان موجوًدا؟‬:‫ االكتمال‬-
‫ عدد العقد الُمولدة‬:‫ تعقيد الوقت‬-
‫ أقصى عدد من العقد في الذاكرة‬:‫ تعقيد المساحة‬-
‫ هل تجد دائًما حًال بأقل تكلفة؟‬:‫ التميز‬-

 Time and space complexity are measured in terms of


:‫ُتقاس تعقيد الوقت والمساحة بالنسبة لـ‬
 b: maximum branching factor of the search tree
‫ أقصى عامل تفرع لشجرة البحث‬:b -
 d: depth of the least-cost solution ‫ عمق الحل بأقل تكلفة‬:d -
 m: maximum depth of the state space (may be ∞) ‫ العمق األقصى لمساحة الحالة (قد‬:m -
)∞ ‫يكون‬

Search Strategies (Cont.)


• Uninformed (Blind / Exhaustive/ Brute-Force) search:
– The search does not have additional information about states beyond that provided in the
problem definition.
– Include: breadth-first, uniform-cost, depth-first, depth limited, iterative deepening, and
bidirectional search
:)‫ القوة الخام‬/ ‫ الشامل‬/ ‫• البحث الغير ُم ستند (األعمى‬
.‫ البحث ال يحتوي على معلومات إضافية حول الحاالت بعد تلك الُمقدمة في تعريف المشكلة‬-
‫ التكرار‬،‫ البحث بعمق محدد‬،‫ البحث بالعمق‬،‫ البحث بالتكلفة الموحدة‬،‫ البحث بالعرض‬:‫ يشمل‬-
.‫ والبحث ذو االتجاهين‬،‫التدريجي‬
• Informed (Heuristic) search:

– The search is guided by an evaluation function:


– Include: Greedy best-first, A*, IDA*, and beam search
:)‫• البحث الموجه (الذكاء الصناعي‬ –
‫ والبحث الشعاعي‬،*A*، IDA ،‫ أفضلية الجشع‬:‫يشمل‬ - ‫ ُيوجه البحث بواسطة وظيفة تقييم‬- –
• Optimization

– The search is to find an optimal value of an objective function


– Include: Hill climbing, simulated annealing, genetic algorithms, Ant Colony
Optimization
:‫• التحسين‬ –
.‫ البحث هو للعثور على قيمة مثلى لوظيفة هدف‬- –
.‫ وتحسين مستعمل النمل‬،‫ الخوارزميات الجينية‬،‫ تبريد محاكي‬،‫ تسلق الجبل‬:‫ يشمل‬- –

Page 23 of 31
By: Muhammad Mahmoud
• Game playing
– An adversarial search: Mini-max algorithm, alpha-beta pruning

:‫• لعب األلعاب‬


.‫البيتا‬-‫ قص األلفا‬،‫األقصى‬-‫ خوارزمية الحد األدنى‬:‫ بحث تنافسي‬-

MCQ Chapter 3

1. Which phase of problem-solving involves deciding what actions and states to consider, given the goal
formulation?
a) Goal formulation
b) Problem formulation
c) Solution execution
d) Problem-solving agent design

2. What are the judgmental rules limiting the exploration of search space in human problem-solving
known as?
a) Algorithms
b) Heuristics
c) State space
d) Goal states

3. In problem-solving agents, what is the first step in problem-solving based on the current situation and
performance measure?
a) Goal formulation
b) Problem formulation
c) Solution execution
d) Problem-solving agent design

4. Which problem-solving agent decides what to do by finding sequences of actions leading to desirable
states?
a) Reactive agents
b) Deliberative agents
c) Goal-based agents
d) Utility-based agents

5. In the context of problem formulation, what determines whether a given state is a goal state?
a) Initial state
b) Transition model
c) Goal test
d) Path cost function

Page 24 of 31
By: Muhammad Mahmoud
6. Which type of problem-solving problem requires sensing during the execution phase?
a) Single-state problems
b) Multiple-state problems
c) Contingency problems
d) Exploration problems

7. In the context of search algorithms, what is the process of considering various possible action
sequences called?
a) Execution
b) Expansion
c) Search
d) Evaluation

8. Which algorithm enhances TREE-SEARCH by remembering previously expanded nodes to avoid


redundant paths?
a) Graph-Search
b) Depth-First Search
c) Breadth-First Search
d) Uniform-Cost Search

9. What are the components of a node in a search tree?


a) State, action, goal, path cost
b) State, parent, action, path cost
c) State, transition model, path cost, goal test
d) State, exploration, solution, path cost

10. Which search strategy evaluates nodes based on an evaluation function and guides the search
towards the goal?
a) Uninformed search
b) Heuristic search
c) Optimization search
d) Game-playing search

11. Which type of problem-solving agent is most appropriate for game-playing scenarios?
a) Goal-based agents
b) Reactive agents
c) Utility-based agents
d) Deliberative agents
Page 25 of 31
By: Muhammad Mahmoud
12. What type of problem-solving problem involves reasoning about sets of states rather than single
states?
a) Single-state problems
b) Multiple-state problems
c) Contingency problems
d) Exploration problems

13. Which algorithm efficiently handles problems with many repeated states by maintaining an explored
set?
a) Graph-Search
b) Depth-Limited Search
c) Uniform-Cost Search
d) Bidirectional Search

14. In problem formulation, what determines the numeric cost assigned to each path?
a) Initial state
b) Transition model
c) Goal test
d) Path cost function

15. What dimension evaluates search strategies based on whether they always find a solution if one
exists?
a) Completeness b) Time complexity
c) Space complexity d) Optimality

16. Which algorithm expands nodes based on the least-cost solution path?
a) A*
b) Greedy best-first
c) Depth-First Search
d) Breadth-First Search

17. In the context of problem-solving agents, what is the process of deciding what actions and states to
consider, given the goal formulation?
a) Goal formulation
b) Problem formulation
c) Solution execution
d) Problem-solving agent design

18. Which type of problem-solving problem involves reasoning about sets of states rather than single

Page 26 of 31
By: Muhammad Mahmoud
states?
a) Single-state problems
b) Multiple-state problems
c) Contingency problems
d) Exploration problems

19. What dimension evaluates search strategies based on the number of nodes generated?
a) Completeness
b) Time complexity
c) Space complexity
d) Optimality

20. Which search strategy does not have additional information about states beyond that provided in the
problem definition?
a) Uninformed search
b) Heuristic search
c) Optimization search
d) Game-playing search

21. Which algorithm efficiently handles problems with many repeated states by maintaining an explored
set?
a) Graph-Search
b) Depth-First Search
c) Uniform-Cost Search
d) Bidirectional Search

22. In problem formulation, what determines the numeric cost assigned to each path?
a) Initial state
b) Transition model
c) Goal test
d) Path cost function

23. What dimension evaluates search strategies based on whether they always find a solution if one
exists?
a) Completeness
b) Time complexity
c) Space complexity
d) Optimality
24. Which algorithm expands nodes based on the least-cost solution path?
a) A*
b) Greedy best-first
Page 27 of 31
By: Muhammad Mahmoud
c) Depth-First Search
d) Breadth-First Search

25. What is the process of considering various possible action sequences in problem-solving called?
a) Execution
b) Expansion
c) Search
d) Evaluation

26. Which search strategy evaluates nodes based on an evaluation function and guides the search
towards the goal?
a) Uninformed search
b) Heuristic search
c) Optimization search
d) Game-playing search

27. In problem-solving agents, what is the first step in problem-solving based on the current situation and
performance measure?
a) Goal formulation
b) Problem formulation
c) Solution execution
d) Problem-solving agent design

28. Which type of problem-solving problem involves reasoning about sets of states rather than single
states?
a) Single-state problems
b) Multiple-state problems
c) Contingency problems
d) Exploration problems

29. What dimension evaluates search strategies based on the number of nodes generated?
a) Completeness
b) Time complexity
c) Space complexity
d) Optimality

30. Which search strategy does not have additional information about states beyond that provided in the
problem definition?
a) Uninformed search
b) Heuristic search
c) Optimization search
Page 28 of 31
By: Muhammad Mahmoud
d) Game-playing search

31. Which algorithm efficiently handles problems with many repeated states by maintaining an explored
set?
a) Graph-Search
b) Depth-First Search
c) Uniform-Cost Search
d) Bidirectional Search

32. In problem formulation, what determines the numeric cost assigned to each path?
a) Initial state
b) Transition model
c) Goal test
d) Path cost function

33. What dimension evaluates search strategies based on whether they always find a solution if one
exists?
a) Completeness
b) Time complexity
c) Space complexity
d) Optimality

34. Which algorithm expands nodes based on the least-cost solution path?
a) A*
b) Greedy best-first
c) Depth-First Search
d) Breadth-First Search

35. What dimension evaluates search strategies based on whether they always find a solution if one
exists?
a) Completeness
b) Time complexity
c) Space complexity
d) Optimality
36. Which search strategy evaluates nodes based on an evaluation function and guides the search
towards the goal?
a) Uninformed search
b) Heuristic search
c) Optimization search
d) Game-playing search

Page 29 of 31
By: Muhammad Mahmoud
37. In problem-solving agents, what is the first step in problem-solving based on the current situation and
performance measure?
a) Goal formulation
b) Problem formulation
c) Solution execution
d) Problem-solving agent design

38. Which type of problem-solving problem involves reasoning about sets of states rather than single
states?
a) Single-state problems
b) Multiple-state problems
c) Contingency problems
d) Exploration problems

39. What dimension evaluates search strategies based on the number of nodes generated?
a) Completeness
b) Time complexity
c) Space complexity
d) Optimality

40. Which search strategy does not have additional information about states beyond that provided in the
problem definition?
a) Uninformed search
b) Heuristic search
c) Optimization search
d) Game-playing search

Ans)
1. b) Problem formulation 22. d) Path cost function
2. b) Heuristics 23. a) Completeness
3. a) Goal formulation 24. a) A*
4. c) Goal-based agents 25. c) Search
5. c) Goal test 26. b) Heuristic search
6. c) Contingency problems 27. a) Goal formulation
28. d) Exploration problems
Page 30 of 31
By: Muhammad Mahmoud 29. c) Space complexity
30. a) Uninformed search
31. a) Graph-Search

7. c) Search
8. a) Graph-Search
9. b) State, parent, action, path cost
10. b) Heuristic search
11. d) Deliberative agents
12. b) Multiple-state problems
13. a) Graph-Search
14. d) Path cost function
15. a) Completeness
16. a) A*
17. b) Problem formulation
18. d) Exploration problems
19. b) Time complexity
20. a) Uninformed search
21. a) Graph-Search

Page 31 of 31
By: Muhammad Mahmoud

You might also like