Thematic Role System

David went to the meeting with Ashok by car.

Thematic Role
verb : go
agent : David
coagent : Ashok
destination : meeting
conveyance : car

Prepositional Constraints
Preposition, Themantic Roles
by | agent, conveyance, location
for | beneficiary, duration
from | source
to | destination
with | coagent, instrument

e.g.
That was written by Ashok.
David went to New York by train
David stood by the statue.

formal logic

Why do we need formal logic?
Soundness: Only valid conclusions can be proven.
Completeness: All valid conclusions can be proven.

Vertebrate -> Bird -> Eagle, Bluebird, Penguin
If an animal has feathers, then it is a bird.
If an animal lays eggs and it files, then it is a bird.

Frame: How do we make sense of a sentence?

Ashok ate a frog.
subject: Ashok
object: a frog
time:
utensils:
object-alive: false
object-is: in-subject
subject-mood: happy

David ate a pizza at home:
subject: David
object: a pizza
time:
utensils:
object-alive: false
object-is: in-subject
subject-mood: happy

Angela ate lasagna with her dad last night at Olive Garden.
subject : Angela
object : lasagna
location : Olive Garden
time : night
utensils :
object-alive : false
object-is : in-subject
subject-mood : happy

Levels of Cognitive Architectures

Low Level <-> High Level
Hardware/Implementation Level(e.g. a brain, transister), Algrithm/Symbol Level(e.g. means-ends analysis, semantic networks), Task/Knowledge Level(e.g. selecting a pitch, playing baseball)

The layers of Watson: the physical computer searching and decision-making answering the inputted clue

Assumptions of a Cognitive Architecture
– Goal-oriented
– Rich, complex envrionment
– Significant knowledge
– Symbols and abstractions
– Flexible and function of the environment
– Learning

Architecture + Content = Behavior
Function for cognitive architectures: f:P* -> A
Percepts -> Action

SOAR
Procedural, Semantic, Episodic
-> Working Memory

Semantic Networks

A:B
x -> x :unchanged
y -> y :expanded
z -> z :deleted

lexically: nodes
structurally: directional links
semantically: application specific labels

Guards and prisonaers

similarity weight
5point for unchanged, 4 for reflected, 3 for rotated, 2 for scaled, 1 for deleted, 0 for shape changed

Fundamental Conundrums of Artificial Intelligence

-intelligent agents have limited resources
-computation is local, but problems have global constraints
-logic is deductive, but many problems are not
-The world is dynamic, but knowledge is limited
-Problem solving, reasoning, and learning are complex, but explanation and justification are even more complex

Characteristics of AI Agents
-Agent have limited computing power
-Agent have limited sensors
-Agent have limited attention
-Computational logic is fundamentally deductive
-AI agents’ knowledge is incomplete relative to the world

input ->
Cognitive System
Metacognition
Deliberation:Reasoning, Learning, Memory
Reaction
-> output

Foundation
machine learning, semantic web, airplane autopilot, improvisational robots

Implement P controller

import random
import numpy as np
import matplotlib.pyplot as plt

class Robot(object):
def __init__(self, length=20.0):
self.x = 0.0
self.y = 0.0
self.orientation = 0.0
self.length = length
self.steering_noise = 0.0
self.distance_noise = 0.0
self.steering_drift = 0.0

def set(self, x, y, orientation):
self.x = x
self.y = y
self.orientation = orientation % (2.0 * np.pi)

def set_noise(self, steering_noise, distance_noise):
self.steering_noise = steering_noise
self.distance_noise = distance_noise

def set_steering_drift(self, drift):
self.steering_drift = drift

def move(self, steering, distance, tolerance=0.001, max_steering_angle=np.pi/4.0):

if steering > max_steering_angle:
steering = max_steering_angle
if steering < -max_steering_angle: steering = -max_steering_angle if distance < 0.0: distance = 0.0 steering2 = random.gauss(steering, self.steering_noise) distance2 = random.gauss(distance, self.distance_noise) steering2 += self.steering_drift turn = np.tan(steering2) * distance2 / self.length if abs(turn) < tolerance: self.x += distance2 * np.cos(self.orientation) self.y += distance2 * np.sin(self.orientation) self.orientation = (self.orientation + turn) % (2.0 * np.pi) else: radius = distance2 / turn cx = self.x - (np.sin(self.orientation) * radius) cy = self.y + (np.cos(self.orientation) * radius) self.orientation = (self.orietation + turn) % (2.0 + np.pi) self.x = cx + (np.sin(self.orientation) * raidus) self.y = cy - (np.cos(self.orientation) * raidus) def __repr__(self): return '[x=%.5f y=%.5f orient=%.5f]' % (self.x, self.y, self.orientation) [/python]

Robot motion

Generating smooth paths

x0 … xn-1
xi

smoothing algorithm
yi = xi
optimize (xi-yi)^2 -> min (yi-yi+1)^2 ->min (original path)

from copy import deepcopy

def printpaths(path,newpath):
	for old, new in zip(path,newpath):
        print '['+ ', '.join('%.3f'%x for x in old) + \
               '] -> ['+ ', '.join('%.3f'%x for x in new) +']'

# Don't modify path inside your function.
path = [[0, 0],
        [0, 1],
        [0, 2],
        [1, 2],
        [2, 2],
        [3, 2],
        [4, 2],
        [4, 3],
        [4, 4]]

def smooth(path, weight_data = 0.5, weight_smooth = 0.1, tolerance = 0.000001):

	newpath = [[0 for row in range(len(path[0]))] for col in range(len(path))]
	for i in range(len(path)):
		for j in range(len(path[0]))
		newpath[i][j] = path[i][j]

	change = tolerance
	while change >= tolerance:
		change = 0.0
		for i in range(1, len(path)-1):
			for j in range(len(path[0])):
				aux = newpath[i][j]
				newpath[i][j] += weight_data * (path[i][j] - newpath[i][j])
				newpath[i][j] += weight_smooth * (newpath[i-1][j] \ + newpath[i+_][j])
				change += abs(aux - newpath[i][j])
	return newpath

printpaths(path,smooth(path))

Motion Planning

Motion Planning
Given: Map, starting location, goal location, cost
Goal: Find minimum cost

Each Actions: move, turn

grid = [[0, 0, 1, 0, 0, 0],
        [0, 0, 1, 0, 0, 0],
        [0, 0, 0, 0, 1, 0],
        [0, 0, 1, 1, 1, 0],
        [0, 0, 0, 0, 1, 0]]
init = [0, 0]
goal = [len(grid)-1, len(grid[0])-1]
cost = 1

delta = [[-1, 0],
		[0, -1],
		[1, 0],
		[0, 1]]

delta_name = ['^','<','v','>']

def search(grid, init, goal,cost):
	closed = [[0 for row in range(len(grid[0]))] fro col in range(len(grid))]

	x = init[0]
	y = init[1]
	g = 0

	open = [[g, x, y]]
	return path

Circular motion

from math import *
import random

landmarks = [[0.0, 100.0], [0.0, 0.0], [100.0, 0.0],[100.0, 100.0]]
world_size = 100.0
max_steering_angle = pi/4

class robot:

	def __init__(self, length = 100.0):
		self.x = random.random() * world_size
		self.y = random.random() * world_size
		self.orientation = random.random() * 2.0 * pi
		self.length = length
		self.bearing_noise = 0.0
		self.steering_noise = 0.0
		self.distance_noise = 0.0

	def __repr__(self):
		return '[x=%.6s y=%.6s orient=%.6s]' % (str(self.x), str(self.y), str(self.orientation))

	def set(self, new_x, new_y, new_orientation):

		if new_orientation < 0 or new_orientation >= 2 * pi:
			raise ValueError, 'Orientation must be in [0..2pi]'
		self.x = float(new_x)
		self.y = float(new_y)
		self.orientation = float(new_orientation)

	def set_noise(self, new_b_noise, new_s_noise, new_d_noise):
		self.bearing_noise = float(new_b_noise)
		self.steering_noise = float(new_s_noise)
		self.distance_noise = float(new_d_noise)

	def move(self, motion, tolerance = 0.001):

		steering = motion[0]
		distance = motion[1]

		if abs(steering) > max_steering_angle:
			raise ValueError, 'Exceeding max steering angle'

		if distance < 0.0:
			raise ValueError, 'Moving backwards is not valid'
		return result