sgar91.files.wordpress.com€¦  · web viewwhere will adnan be after 30 steps? ... in a “word...

15
National University of Sciences and Technology College of Electrical and Mechanical Engineering Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence Student Name ____________________ Date__________________ Total Marks: 100, Max Time: 2 hrs Note: Total 6 questions. Attempt All. Incase of any confusion write your supposition and attempt it in the way you think is suitable. Problem 1: (10) Adnan (A) wants to go to Office (O), and he can take steps in any dire ction (Top, Left, Right, Down) after percepting the environment and fo llowing the rules. (see Figure 1) Percept Rules Percept ↔ Action { Top Open} ↔Move Top { Top Close, Right Open} ↔ Move Right { Top Close, Right Close, Left Open} ↔ Move Left { Top Close, Right Close, Left Close, Down Open} ↔ Move Down a) Will adnan ever reach the office? (Yes/ No) (1) b) Where will adnan be after 30 steps? (Write 30 in that block) (3) c) What type of agent is adnan? (1) (Simple Reflex Agent/ Model based reflex agent/ Utility based Agent) Now add a new memory based rule, to previous rules New additional rule “If block is already visited, consider it close. Incase of all close neighbours, you can visit already visited block. Priority order for visited nodes is Top, Right, Left, Bottom” d) Will adnan ever reach the office? (Yes/ No) (1) e) Where will adnan be after 15 steps? (Write 15 in that block) (3) f) What type of agent is adnan, now? (1) Sheet 1/10

Upload: doandat

Post on 27-May-2019

214 views

Category:

Documents


0 download

TRANSCRIPT

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Student Name ____________________ Date__________________Total Marks: 100, Max Time: 2 hrs

Note: Total 6 questions. Attempt All. Incase of any confusion write your supposition and attempt it in the way you think is suitable.

Problem 1: (10)Adnan (A) wants to go to Office (O), and he can take steps in any direction (Top, Left, Right, Down) after percepting the environment and following the rules. (see Figure 1)

Percept RulesPercept ↔ Action

{ Top Open} ↔Move Top{ Top Close, Right Open} ↔ Move Right{ Top Close, Right Close, Left Open} ↔ Move Left{ Top Close, Right Close, Left Close, Down Open} ↔ Move Down

a) Will adnan ever reach the office? (Yes/ No) (1)b) Where will adnan be after 30 steps? (Write 30 in that block) (3)c) What type of agent is adnan? (1)

(Simple Reflex Agent/ Model based reflex agent/ Utility based Agent)

Now add a new memory based rule, to previous rulesNew additional rule“If block is already visited, consider it close. Incase of all close neighbours, you can visit already visited block. Priority order for visited nodes is Top, Right, Left, Bottom”

d) Will adnan ever reach the office? (Yes/ No) (1)e) Where will adnan be after 15 steps? (Write 15 in that block) (3)f) What type of agent is adnan, now? (1)

(Simple Reflex Agent/ Model based reflex agent/ Utility based Agent)

Sheet 1/10

Down

Top

RightLeft

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Problem 3: (15)Five students (Shaneeb, Amsal, Kush, Ummamah, Raheel) got failed in various subjects and have to give improvement papers of 5 subjects in 4 days. Therefore, any two or more subjects of same students cannot have exam on same day.So assign the 5 subjects, a day such that there is no problem.

Variables = {AI, Gphs, DSD, TW, OS}Values = {Mon, Tue, Wed, Thrs}

Constraints can be shown with the help of figure. Constraints of AI are drawn, similarly other constraints can be drawn.

Shaneeb failed AI & GphsUmmamah failed Gphs and DSDAmsal failed OS, AI and DSDRaheel failed Gphs & TWKush failed DSD, Gphs & TW

a) Completely draw the CSP graph, showing all constraints. (5)b) Fill the table using forward checking+ MRV (5 + 3) Select the first variable with highest degree heuristic (having maximum constraints). After that choose variables with MRV (Minimum remaining values). Incase of equal MRVs, give

priority in order of AI: Gphs: DSD : TW : OS (highest to lowest priority) When assigning values, no need to use arc consistency or Least constraining value. Give priority

to Monday, Tuesday, Wednesday and then Thursday.

a) Which exam will be there on Thursday. (1)b) On which day will be the exam of AI (1)

Sheet 2/10

Problem 2: (10)Ali asif and Asif Ali are syncd together. When Ali moves Asif also moves, and when Asif moves Ali also moves. But both move In opposite directions. i.e. When one moves up, other moves down and vice versa. And similarly when one moves left other moves right and vice versa.

To eat burgers B1,B2,B3,B4,B5,B6, the person has to visit that block.

a) Ali can eat which burgers (B1/B2/B3)? Circle them? (3)b) Asif can eat which burgers (B4/B5/B6)? Circle them? (3)c) Shade all the portion of both blocks, where they CANNOT go?(4)

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Problem 4: (25)In a “word search” game, agent has to find the word “THIRTY”. The agent follows these steps to search a word.

Step 1) Search for alphabet “T” . Start from top row (left to right) and when a row finishes, jump to next row (left to right). Repeat till the last bottom row. ie. Here search sequence will be H, R, I, M, R and so on

Step 2) When “T” is found, it starts making a tree using BFS.Children of a node are its 8 possible neighbours (Neighbour Order: Left, LeftBottom, Bottom, Bottom Right, Right, Right Top, Top, Top Left).

If no neighbor exists in any direction then no node is generated for that direction

We expand only those nodes, which make a valid spelling, i.e. “T” has child “I” but this is not proper sequence, because we need “H”. So we don’t expand “I”.But child “H” is expanded, because it makes proper spelling.

Note: Words are formed in straight lines, so there is only one possible direction in each branch. i.e. after “H” only one child in left bottom direction is checked.

Step 3) If complete word is found, the search stops. If no word is found in the whole tree, delete the tree and make another tree for another next alphabet “T”

a) Which search algorithm is better in this problem, and why? (DFS or BFS) (3)b) How many times trees will be formed till the word is found (2)c) Draw the tree formed using BFS (which WILL have the complete solution) (5)d) Draw the last tree formed using BFS (which WILL NOT have the solution) (5)

Instead of searching from first alphabet “T”, we can search for last alphabet “Y”, and then search backwards “YTRIHT”.

e) How many times trees will be formed/deleted for searching “YTRIHT”? (5)f) Draw the last tree formed (which WILL NOT have the solution) (5)

Sheet 3/10

H R I M R I R N S RI T H H U M A I H IH M E I T H I S R UU E R E R A E R A NM E T N R N L M H AS R U H A A R H A NI H A T I U T H A SN E S R M R U H U HM T H I R A T U R RI R A N T U M Y A IH U R I U N S U R M

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Problem 5: (10)There are four cities Peshawar (P), Karachi (K), Quetta(Q), LaHore (L). Table shows the transport cost from one city to another. We can visit the cities in any order, but we need to find best order of visited cities. (LEAST COST). For that we will use hill climbing.

A node consists of a sequence e.g. P->K->L->Q , which means from Peshawar go to Karachi (3000Rs) + Karachi to Lahore (2000Rs) + Lahore to Quetta (1500Rs) = Total 6500Rs

A graph of neighbours is already shown. Start from PQKL and choose the best neighbor (LEAST cost) out of the three.(PQLK), (QPKL) and (PKQL).

In case of equal cost neighbours choose ANY neighbour.If you are stuck at a node, stay there.

Repeat the step twice again i.e. take 3 steps and choose a better city order.

Calculate and show the costs of all the neighbours in the figure when choosing one.

From Peshawar From Karachi From Lahore From QuettaTo Peshawar 0 Train (2000) Air (2500) Bus (2500)To Karachi Air (3000) 0 Bus (3500) Train(3000)To Lahore Bus (1000) Air (2000) 0 Air(1500)To Quetta Train (2000) Bus(1500) Train(1500) 0

Sheet 4/10

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Problem 6: (30)A social networking site “TRASHBOOK” has many users, and each user has a group of friends. (SEE FIGURE 6)As shown in figure, Zargham has 5 friends (circled together) Hassan, Ali, Mashab, Mehran and Asim. Similarly, Mehran has 6 friends etc. So each group shows friends of a person.

Our goal is to find a link between Zargham and Tofiq.

So we start making a tree of friends. First node will be zargham, and its sucessors will be his friends. Then each friend will have other friends as successors.

Person with no friend group has no successor. Also visit the successors in ALPHABETICAL order.

In repeated nodes, a name can come again in a tree e.g. Asim is successor of Zargham, and Zargham is again successor of AsimBut in non repeated nodes, once a name is GENERATED (NOT EXPANDED), it is not generated again.

The order of nodes VISITED (EXPANDED) by Depth first search will be,1) Zargham (Friends list alphabetical: Ali, Asim, Hassan, Mashab, Mehran): Ali is first alphabetically

so next node visited is Ali2) Ali (No friend List): So move back into tree and visit other successor of Zargham i.e. Asim3) Asim and so on…

The order of nodes VISITED (EXPANDED) by Breadth first search will be,1) Zargham (Friends list alphabetical: Ali, Asim, Hassan, Mashab, Mehran): Ali is first alphabetically

so next node visited is Ali2) Ali (No friend List): Visit other successor of Zargham i.e. Asim3) Asim (Generate successor nodes): Vist other successor of Zargham i.e. Hassan4) Hassan and so on…

a) Which will be the 15th node visited (using BFS and repeated nodes)? (3+1)b) Which will be the 15th node visited (using DFS and repeated nodes)? (3+1)c) Which will be the 15th node visited (using DFS and non repeated nodes)? (3+1)d) Draw a complete tree for BFS (non repeated nodes), till goal node “Tofiq” is GENERATED? How

many nodes needs to be visited starting from Zargham, till we reach Tofiq? (7+2)e) If we have to do bidirectional search. i.e. Search from Zargham, as well as Tofiq, at the same

time, in parallel. When both searches reach a common node (Not necessarily at the same time), then stop search. Draw both trees? What will be the path then? (7+2)

Sheet 5/10

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Sheet 6/10

Figure 6

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Student Name ____________________ Date__________________

Sheet 7/10

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

SOLUTION SHEET

Sheet 8/10

Solution 1a) _No___________________________b) Write 30 in figurec)_Simple Reflex Agent_____________d) _Yes__________________________e) Write 15 in figuref) _Model based Reflex Agent_______

Solution 2a) B2 , B3b) B4c) Shade the blocks

Solution 3

c) Complete the CSP graph

d) Complete the FC table

a) _No paper on Thursday_______________

b) _Tuesday_______________

Solution 4a) _Depth First Search___________b) _3 times (Including the solution tree)__c) Draw the Treed) Draw the treee) __Once (Including the solution tree)__f) __No Tree formed ________________

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Sheet 9/10

Solution 5

Starting from PQKL, take 3 steps.Move to next best neighbor (LEAST cost), and then another NEXT best neighbor.Show in figure which nodes you visited, and also the COSTS of all neighbours which you had to check

First Tree with Solution “THIRTY”

Last Tree with no Solution

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Sheet 10/10

Solution 6a) _Baqir______________________b) _Abbas_____________________c) _ Tofiq _____________________d) __ 26 nodes_________________e) Draw BOTH trees

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Sheet 11/10

BFS with no repeated nodes

Bidirectional tree 1

Bidirectional tree 2

National University of Sciences and TechnologyCollege of Electrical and Mechanical Engineering

Mid Term Exam Spring 2011 Degree 30C EC 342 Artificial Intelligence

Question 6 (No need to draw trees)

Sheet 12/10

Part b) DFS with repeated nodes Part a) BFS with repeated nodes

Part c) DFS with non repeated nodes