Overview Artificial Intelligence is a field of study that encompasses computational techniques for...

Preview:

Citation preview

Overview

•Artificial Intelligence is a field of study that encompasses computational techniques for performing tasks that apparently require intelligence when performed by humans. •Artificial Intelligence is concerned primarily with those aspects of human mental activity that are approximate (heuristic), and abstract (symbolic) in nature.

Algorthimic seriesHeuristic Series

Tractable Intractable

Magic square

n!, n infinity

Problem Scale

TractableIntractableGuessed by

Classic AI

A Contrast !!! AI versus Algorithm Based Puzzle

Representation of Intelligence

Visualizing as a multidimensional space, with different aspects of intelligence lying along the axes of various dimensions.

E.g. : The Arithmetic Dimension of Intelligence of a human being might vary from the ability to count and proceed to the ability to add, subtract, multiply, divide, and so forth.

The arithmetic dimension of intelligence: 

Count Add/Subtract Multiply/Divide Proving new facts   

Applications of AI

Like statistics, AI brings a collection of techniques that can be applied in other fields as history, biology, or engineering.

•Expert Systems - The most famous and widely used of all AI technologies.

Encapsulate knowledge for specific domains. Applicable to domains that have problem spaces with clear boundaries. Solves problems within its specific domain by using the encapsulated. E.g.: Medical Diagnosis Systems, Geological Analysis etc.

•Games - Relatively small problems that are characterized by clear rules and are usually

easy to represent symbolically. Because of the small magnitude of the problem they make excellent testing beds for AI concepts and techniques

•Machine Learning - Goal is to enable knowledge-based programs to increase

their knowledge by learning. Recent example: Self – Learning auto driver.

•Natural-Language Understanding and Generation Focuses on the recognition and production of human speech and writing.

•Neural Network Modeled after human brain. The components of a neural network

are linked together in a network and function in a manner similar to that of human neurons.

Steps To Solve AI Problems

•Define a format for a “Unique State Representation”

•Construct a “Legal Moves Generator Function”

•Construct a “New State Generator Function”

•Define a “State Evaluation Function”

•Select appropriate search strategy.

Step I: Define a format for a “Unique State Representation”

 To make computer understand our problem we should represent the problem SYMBOLLICALLY. E.g.: Initial State, Current State, and Goal State. 

In 8’s Puzzle: Initial State: Goal State:5 4 3 1 2 38 * 7 4 5 66 2 1 7 8 * 

Various ways of representation

One way: Initial State = (5 4 3 8 * 7 6 2 1) Goal State = (1 2 3 4 5 6 7 8 *) Zigzag Pattern Second way:Initial State = (5 4 3 7 1 2 6 8 *) Goal State = (1 2 3 6 * 8 7 4 5) Circular Pattern

Step 2: Construct a “Legal Moves Generator Function”

2 4 65 * 71 3 8

2 * 65 4 71 3 8

2 4 65 3 71 * 8

2 4 6* 5 71 3 8

2 4 65 7 *1 3 8

Current State

All possible moves from the parent state

This function will return all the possible moves from the current state

Step 3: Construct a New State Generator Function”

The function will return a new state if the current state and a legal move is passed. Prototype:New State NewStateGenerator(<set of legal moves>, Current State) Our case:New State = NewStateGenerator(((* 2 8 3 1 4 5 7 6)

(2 1 8 3 * 4 5 7 6) (2 8 * 3 1 4 5 7 6)), (2 * 8 3 1 4 5 7 6))

Now depending upon Step 4 the value of New State would be one of the states in the set of legal moves.

Step 4: Define a “State Evaluation Function”

This function is “the essence of an AI program”.  Prototype:Weight EvalFunction(A State)In our case (8th Puzzle) there are several standard heuristic functions.

Number of Squares in their

position

2 3 41 5 6 = (1 +1 + 1) = 38 7 *

Manhattan Distance Approach:Calculate the state’s numeric representation by summing the number of steps required to move each square to it’s position. Zero if the square is in it’s place.

2 3 41 5 6 = (1 + 1 + 3 + 0 + 0 + 1 + 1 + 0) = 78 7 *

Decision: (Based upon the Search Strategy Chosen in Step 5F(n) = g(n) + h(n), where:

G(n) = the length of the path from the start state to nH(n) = number of tiles out of place in state n without counting the blank space

The Complete Tree for 8th puzzleF(n) = g(n) + h(n)G(n) = the length of the path from the start state to nH(n) = number of tiles out of place in state n without counting the blank space

Step 5: Select Appropriate Search StrategyWhy A* ?A* algorithm opens nodes in an order that gives highest priority to nodes likely to be on the shortest path To do this, it adds g the cost of the best path found so far between the start node and the current node, to the estimated Distance h.Algorithm:begin input the start node S and the set GOALS of goal nodes OPEN = {S}; CLOSED = {}; G[S] = 0; PRED[S] = NULL; found = false; while OPEN is not empty and found is false do begin L = the set of nodes on OPEN for which F is the least; if L is a singleton then let X be its sole element else if there are any goal nodes in L then let X be one of them else let X be any element of L remove X from OPEN and put X into CLOSED; if X is a goal node then found = true; else begin

generate the set SUCCESSORS of successors of X;for each Y in SUCCESSORS do if Y is not already on OPEN or on CLOSED then begin

G[Y] = G[X] + distance(X, Y);F[Y] = G[Y] + h(Y); PRED[Y] = X;

A* Continued …

insert Y on OPEN end else /* Y is on OPEN or on CLOSED */

begin Z = PRED[Y]; temp = F[Y] – G[Z] – distance(Z, Y) + G[X] + distance(X, Y) if temp < F[Y] then begin

G[Y] = G[Y] – F[Y] + temp;F[Y] = temp; PRED[Y] = X;if Y is on CLOSED then insert Y on OPEN and remove Y from CLOSED;

end;end;

end; end; if found is false then output “Failure” else trace the pointers in the PRED fields from X back to S, “CONSing” each node onto the growing list of nodes to get the path from S to Xend;

Screen Shot: Eighth Puzzle

 

Problem Statement – Magic Square

A magic square is an n x n matrix in which each of the integers 1, 2, 3, …, n2 appears exactly once and all columns sums, row sums, and diagonal sums are equal. In this example it is:

17 24 1 8 15

23 5 7 14 16

4 6 13 20 22

10 12 19 21 3

11 18 25 2 9

Algorithm - Magic Square

•Place 1 in the middle of the top row. •Then after integer k has been placed, move up one row and one column to the right to place the next integer k + 1, unless one of the following occurs:

•If a move takes you above the top row in the jth column, move to the bottom of the jth column and place k + 1 there •If a move takes you outside to the right of the square in the ith row, place k + 1 in the ith row of the leftmost column •If a move takes you to an already filled square or if you move out of the square at the upper right-hand corner, place k + 1 immediately below k

Conclusion

• Without the use of heuristic evaluators search algorithms useexhaustive approaches that can’t “see” where they are going

untilthey get there. • Consequently they often spend a lot of time searching in

totally fruitless directions. • If some general guiding information is available, the

searching can be biased to move in the general direction of the goal from the very beginning.

 

This is the approach taken by heuristic search methods toimplement the “fuzzy logic” of where the goal might be and

howfar it is from the goal.

SOLVING TIC-TAC-TOE USING MINMAX ALGORITHM

• Most games can be thought of as search problems.

• Moving from the current state till we reach the winning state.

• Opponent always chooses actions which prevent you from winning

• Key idea is to choose a move such that you can win no matter what move our opponent chooses

Overview :

Figure- 1

A very simple example

Why We Go For Evaluation Functions ?

• Its very difficult to look ahead all through the end of the game.

• Look ahead as far as possible .we will end up with the leaf nodes

• Evaluate each of the leaf node by using evaluation functions which move to make next

Defination of Evaluation Function :

It is function which, given a position, will return some sort of numeric value, which corresponds to how good the situation is, or how likely we believe each of those is to lead to a win.

DEFINATION:

“ A technique that chooses the best move from a given game tree with the help of the evaluation function ”

MINMAX ALGORITHM

• Build search tree down to leaves

• Apply evaluation function

• Use leaf values to determine values at next level up

if max’s move : max value of children

if min’s move : min value of children

• Continue up the tree to the root

Minmax Algorithm :

TIC-TAC-TOE

Defination :

Tic-Tac-Toe or X & O’s is a simple two player game where players put either X or O on the grid. Any player who can achieve three of his symbols in the same line wins.

SOLVING TIC-TAC-TOE

Consider playing TicTacToe by the following strategic rules R, and the heuristics stated H

R1: if completing three-in-a-row is possible, do so.

R2: if the opponent threatens to complete three-in-a-

row, prevent this if possible.

H1: occupy the central square whenever possible.

H2: occupy a corner square whenever possible.

Evaluation function for Tic-Tac-Toe

F(n) = G(n)-H(n)

Where ,

G(n) = Number of possible rows/columns/diagonals where I (player X) could win

H(n) = Number of rows/columns/diagonals where my opponent (player O) could win.

 

• Assume that our look ahead is 2 moves

Figure - 3

Figure - 4

Next Search Starts from here

Conclusion

•In the TicTacToe evaluation function given above, where we count individual rows and columns. The Linear functions have the disadvantage of rarely being the best way to evaluate a situation, as most games depend not only on individual pieces but also on their relationships.

•One way to vastly improve performance is to redefine the game in terms of "meta-moves", or strategies, instead of individual moves. This has the advantage of greatly reducing the size of the search.

•Finally, an approach which has been very successful for developing evaluation functions is to Create a large number of different functions (giving different weights for pieces, board positions, etc.) and Play them against each other to determine which is best.

Important terminology related to Neuron:

Dendrites: It is the input for a neuron.

Axon: Cord that carries an output signal.

Synapses: Gap between dendrites and output area of the neuron.

Signals traveled from the synapses through the dendrites are weighted and summed as they are gathered by the branching structure. The total weighted sum of input must be high enough for the cell to fire and produce an output pulse.

Threshold: The level of excitation that must exceed for a neuron.

Refractory period: After the neuron has been fired, it takes some time( few milliseconds) for the neuron to recover and prepare itself to respond to input information once more.

The output is 0 if α < θ The output is 1 if α >= θ

How is calculation done? 3-Input neuron

How is calculation done?3-Input neuron

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:   0 0 0/1 0/1 0/1 1 0/1 1

By applying the firing rule gives the following column

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:   0 0 0 0/1 0/1 1 1 1

The network is trained to recognise the patterns T and H. The associated patterns are all black and all white respectively as shown below.

If we represent black squares with 0 and white squares with 1 then the truth tables for the 3 neurons after generalization are

Top neuron

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:   0 0 1 1 0 0 1 1

Middle neuronX1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:   1 0/1 1 0/1 0/1 0 0/1 0

Bottom neuron

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:   1 0 1 1 0 0 1 0

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:   1 0 1 1 0 0 1 0

Bottom Neuron

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:

  1 0/1 1 0/1 0/1 0 0/1 0

Middle Neuron

X1:   0 1 0 1 0 1 0 1

X2:   0 0 1 1 0 0 1 1

X3:   0 0 0 0 1 1 1 1

                   

OUT:

  0 0 1 1 0 0 1 1

Top Neuron

1st neuron was created in 1943 by aNeurophysist WARREN Mc Cullochand a logician Walter pits.

ANN(Artificial Neural Networks) Theyare programs designed to simulate theway a simple biologiacal nervous systemis believed to operate.

Forecasting: Future sales, Market performance, economic indications, medical outcomes, weather, crop forecast, environmental risks.

Modelling: System control, chemical structure, welding control, plastic moulding.

Why are ANN better ?

They can work with large number of variables

They have the ability to acquire knowledge via learning from experience.

They create their own relations amongst information – no equation

They provide general solutions to good productive accuracy.

They handle noisy or missing data.

•Follow Algorithms. •Unless the steps to be followed are known the computer cant proceed. Hence problems that we understand only can be solved

•Learn by example. •Cannot be programmed to perform a specific task.•Accepts multiples inputs having different weightings and gives one output depending on weights.

Computer ANN

Comparing Computers with ANN

A Neuron is an element which thinks by itself. It gives an outputwhich is testable, accurate and quantitative. It follows a Methodology which is efficient and suitable for network ofNeurons(Neural Networks). Neural networks are an efficient,And powerful means of computation. The creation of neuralnetworks was inspired by the study of human brain. Indeed, many aspects of neural networks attempt to emulate biological Function. They do not store “Knowledge” in a memory bank. The information is distributed through the network and isStored in the form of weighted connections.

Conclusion:

Recommended