You are on page 1of 17

Engineering Systems Design and Analysis

(ENG 504)
504)
Lecture 4
/


Email: amhm@zu.edu.eg / amhm162@gmail.com
Webpage: http://www.staff.zu.edu.eg/amhm/

In the previous lectures

AI Paradigms.
Solving Problems by Search
Tree Search Algorithms
Depth-first search
Branch and bound algorithm
Examples:
Travelling Salesman Problem
Scheduling Problems
Local Search Algorithms
Genetic Algorithms
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Agenda

Branch and bound algorithm


Examples:
Travelling Salesman Problem
Scheduling Problems
Expert systems
Propositional logic

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Branch and Bound Algorithm (B&B)

Exercise #2
#2 (of Lecture #3
#3):
Given n tasks and n agents.
Each agent has a cost to complete each task
Assign each agent one task
Minimize cost
Example of the solution:
(C,1),(A,2),(D,3),(B,4)

A
B
C
D

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

1
11
14
11
17

2
12
15
17
14

3
18
13
19
20

Zagazig Univ-Eng. Faculty

4
40
22
23
28
2013/2014

Example #2
#2 (of Lecture #3
#3): solution:

4
Start

A,1
D,2
6

58

16

62

C,2
60

(B,3),(C,4)
7

B,1

61

12

A,2

B,2

(C,3),(B,4)
8

C,1
61

13

61

15

58

14

(D,3),(B,4)
64

62

D,2

B,2

(B,3),(D,4)

65

D,1
58

61

60

(A,3),(B,4)
10

65

(B,3),(A,4)
11

65

78

BSSF

numbers in left cell show order of traversing.

A
B
C
D

numbers in right cell show the lb,


cost of complete solutions are in red.
Pruned PSs are in brown.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

1
11
14
11
17

2
12
15
17
14

Zagazig Univ-Eng. Faculty

Branch and Bound Algorithm (B&B)

3
18
13
19
20

4
40
22
23
28

2013/2014

Exercise #3
#3 (of Lecture #3
#3):
Starting from A, find the shortest tour for this graph.
Construct the search tree using B&B algorithm.
Show why you may do pruning if this is the case at
any step.
What is the order of traversing the vertices?

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Example #3 (of Lecture #


#3
3): solution:

10

20

16

23

D,C,B

11

12

31

D
3

C
x

17

17

B
2

17

17

B
24

C
20

19

19

14

21

15

C,D,E
17

20

D,E,B
28

BSSF

unfeasible

B
-

C,B
x

13

B,F

F,B
34

37

28

unfeasible

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Expert Systems

2013/2014

Expert systems(ES)

An expert system (ES) is a software that uses a knowledge base of human


expertise for problem solving, or clarify uncertainties where normally one or
more human experts would need to be consulted.
An expert system is divided into two sub-systems: the knowledge base
and the inference engine .
The knowledge base represents facts about the world and rules.
The inference engine applies the rules to the known facts to deduce new
facts (or answers related questions)

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Expert Systems(ES)

2013/2014

ES Components:

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Knowledge--Based Systems (KBS)


Knowledge

Explained and organized in groups and structures

structures.
Information
Data
Row material
i.e., 20, -5, 100,8.2,

i.e., temperature is 27o C

Knowledge: is a high-level
structured data.
(condensed information)

Example: Variables and constants are Data, but procedure is Knowledge.


Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Knowledge--Based Systems (KBS)


Knowledge

10

Major issues in KBS:


Representation: transform existing problem knowledge into a problem
knowledge base in a computer format.
Inference: match current facts from the domain space to the existing
knowledge and inferring new facts.
Learning: the process of obtaining new knowledge. It is a step toward
adaptation. It is a major characteristic of intelligent systems.
Generalization.
Interaction.
Explanation.
Validation.
Adaptation.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Knowledge--Based Systems (KBS)


Knowledge

11

One more important definition: Information structure:


structure:
It contains information elements and links between them.
It is a collection of information elements with a defined organization,
operations over the elements, and a defined method of access to every
element.
Example: Stacks, Queues, and Lists.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Knowledge--Based Systems (KBS)


Knowledge

12

How to perform reasoning (inference) over knowledge?


Logic systems can do this job. Three types:
Propositional logic.
Predicate logic.
Fuzzy logic.
Each uses different kinds of rules of the form of:

IF A, THEN B, or A B

So, it is said that A is an antecedent (conditions),


and B a consequent (conclusions, actions).

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Inference in KBS

13

Inference is the process of acquiring new facts when interpreting existing


knowledge with current data.
Inference is differently realized in different logic systems and Al methods.
The inference process can be considered as a trace of states in the problem
Space.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Inference in KBS

2013/2014

14

An inference process is a chain of matching.


Two mechanisms to organize this matching:
Forward chaining:
chaining applies all the facts that are available at a given moment to
all the rules to infer all the possible conclusions.
Backward chaining:
chaining there is a goal state and we try to reach all possible facts
that lead to this goal.
Forward chaining inference starts with data, so it is data-driven.
Backward chaining inference is a goal-driven inference:
Inference process starts after a goal is identified.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Inference in KBS

15

Forward chaining example:

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Inference in KBS

2013/2014

16

Backward chaining example:

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

Propositional Logic

17

Propositional logic is a useful way of representing a simple knowledge base


consisting of propositions and logical connectives between them.
The major limit is that propositional logic can only deal with complete statements.
Example The following inference is not possible in propositional logic:

All humans are mortal.


Socrates is a human.
Therefore, Socrates is mortal.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

18

With the use of propositional logic we can construct rules (sentences) like:
IF (the temperature is above 120), THEN (there is overheating)
where the left-hand and the right-hand sides of the rule contain propositions
which can be only true or false.
i.e., P=the temperature is above 120, Q= there is overheating, P Q
Only an exact match between two propositions is possible.

The KB can be thought of as a set of sentences.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Logic Systems

19

A logic system consists of four parts:


An alphabet, Syntax, Semantics and Laws of inference.
An alphabet:
alphabet a set of basic symbols (propositional symbols).
Syntax: a set of operators for constructing sentences (expressions) or
Syntax
alternatively more complex structures from the alphabet elements.
Semantics: for defining the meaning of the constructions in the logic system.
Semantics
Laws of inference:
inference a set of laws for constructing semantically equivalent
but syntactically different sentences.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

20

The temperature is over 120 is an example of an alphabet (i.e., a symbol)


The semantic meaning of this symbol is expressed by two possible states:
True or False
False.
Propositional logic has the following syntactic connective symbols for constructing
more complex propositions from simple ones:
symbol

Logical meaning

Math. meaning

AND

conjunction

OR

disjunction

NOT

negation

implication

equality

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Propositional Logic

2013/2014

21

Evaluation of logical connectives

symbol

Logical meaning

PQ

is True iff both P and Q are True

P Q

is True iff either P or Q is True

is True iff P is False

P Q

is True unless P is True and Q is False

PQ

is True if both (P and Q) are True or both are False

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

22

Example: Given two propositions: P = "Temperature is high" and


Example
Q = "Humidity is high". Construct all possible expressions.
Answer: use a truth table:
table

PQ

PQ

P Q P Q

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Propositional Logic

2013/2014

23

Exercise #1:
Consider a vocabulary with only four propositions, A, B, C, and D.
How many models (states) are there for the following sentences?

a. B v C
b. A v B v C
c. (A B) A B C D

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

24

Example of translation between facts and logical sentences:


Assume that we have the following propositions:
P = it is sunny this afternoon
Q = it is colder than yesterday
R = we will go swimming
S = we will take a trip
T = we will be home by sunset

Then we can construct the following sentences:


It is not sunny this afternoon and it is colder than yesterday: PQ
We will go swimming only if it is sunny: P R
R
If we do not go swimming then we will take a trip: R S
If we take a trip, then we will be home by sunset: S T

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

25

Entailment: reflects the relation of one fact following from the others.

Knowledge base KB entails a sentence S if and only if S is true


for each state where KB is true: KB |=S
(Answer is True or False)

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

26

General Problem:
Problem
Given a knowledge base KB (a set of sentences) and
a sentence S(called a theorem)
Question: KB |=S ?
Solution techniques:
Truth table.
Construct all possible states bet. Propositions
Check at states where KB is true.
Inference rules.
Conversion to SAT problem.

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Propositional Logic

2013/2014

27

Example:
Example
Given a KB: (P Q), (P Q), and a theorem S: (P Q) Q
Question: KB |=S ?
solution: using a truth table:
KB
P

PQ

P Q

P Q

Answer: KB entails S
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

28

Exercise #2:
Given a KB: (P Q), (T Q), and a theorem S: (P T)
Question: KB |=S ?

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Propositional Logic

2013/2014

29

laws of inference in propositional logic:


1.

Modus ponens (affirmation):


P Q and P

2.

Modus tollens (negation):


P Q and Q

3.

First De Morgans rule:

4.

Second De Morgans rule:

5.

Chain rule:

(P Q)

(P Q)

P Q
P Q

P Q and Q R P R

Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

2013/2014

Propositional Logic

30

Exercise #3
#3: The Car Monitoring Problem.
We have the following symbols:
P: is True if there is overheating
Q: is True if the brakes react slowly
T: is True if cooling temperature is over 120
G: is True if the gauge works properly
S: is True if the car stops
Here is our KB:

Can our KB entail this theorem:


T S

Rule 1: If there is overheating OR the brakes react slowly Then stop the car
Rule 2: If the cooling temperature is over 120 AND the gauge works properly
Then there is overheating.
Dr. A. Helmi Eng. Sys. Design and Analysis (ENG 504)

Zagazig Univ-Eng. Faculty

Thanks

2013/2014

You might also like