Title: IELM 231: IT for Logistics and Manufacturing
1IELM 231 IT for Logistics and Manufacturing
Course Agenda
Introduction
IT applications design Human-Computer Interface
Fundamental IT tools sorting, searching
The Client-Server architecture, Interacting
applications
IT in logistics, Case study 1 web-based auctions
How auctions work Web issues session
tracking Web issues secure communications Web
issues cash transactions
IT in logistics, Case study 2 web-search
Search robots Data processing, Data
storage/retrieval (DB, indexes) Data
presentation page ranking techniques
2Examples of Sorting
Google, Yahoo, - User inputs search word(s) -
Search engine finds many web-pages containing the
search word(s) - Search engine determines
relative importance rating (IR) for each page -
Search engine presents the links to pages,
ordered by decreasing IR
sort
Job scheduling - T-shirt manufacturer must
produce 100 different shirt types in next month
- Production manager ranks the jobs using some
heuristic, e.g. EDD Earliest due date ? do the
job with earliest due date first SPT Do the job
with minimum expected time to complete first -
Manager sorts the 100 jobs according to
heuristic, makes schedule
sort
3Examples of Searching.
Windows - Search for a file of given name in the
C drive - Search for a computer with given IP
address in a network
search
4Examples of Searching..
Electric Power Supply for Show _at_ WanChai
Lines in graph show maximum available capacity of
wires What is the maximum power that can be sent
from Power station in Lamma to Wan Chai
sub-station ?
5Examples of Searching
Graph shows maximum daily capacity (no. of train
bogeys) along railway routes
What is the maximum daily volume we can transport
from Detroit to San Fran?
6A simple sorting method Bubble Sort
Input a list of unsorted numbers Output the
numbers sorted in increasing order
Easy extensions words/names instead of
numbers sort in decreasing order
Main idea of bubble sort for n number Push the
largest to the right (n-th position) - Go from
left to right - For each pair, if the two
numbers are larger, smaller, swap them
// only (n-1) numbers remain to be sorted
(why?) - In the remaining unsorted list, push
the largest to the right (repeat this until
there are no more swaps).
7A simple sorting method Bubble Sort..
23 12 34 14 1 2
Sort
Bubble sort example
The first pass
12 23 34 14 1 2
12 23 34 14 1 2
12 23 14 34 1 2
After 4th pass
12 23 14 1 34 2
1 2 12 14 23 34
12 23 14 1 2 34
The 2nd pass
12 23 14 1 2 34
5th pass no swaps ? done!
12 14 23 1 2 34
1 2 12 14 23 34
12 14 1 23 2 34
12 14 1 2 23 34
After 3rd pass
12 1 2 14 23 34
8A simple sorting method Bubble Sort
Algorithm Bubble sort( input array A of
number) n number of elements in A repeat flag
false for counter 1 to n-1 do if
Acounter gt Acounter1 then swap(
Acounter, Acounter1) set flag
true end if end for n n-1 until (flag
false) or (n1)
9Improved Bubble Sort Comb sort
Problem with bubble sort small numbers at the
end of list take many steps to move to the front
Main idea of comb sort Initially, instead of
comparing neighboring elements (gap
1), compare numbers at larger distance Slowly
reduce the gap of comparison When gap reduces
to 1, and no more swaps, sorting is done
10Improved Bubble Sort Comb sort..
Algorithm Combsort( input array A of
numbers) gap A.length repeat //update the gap
value for a next comb if gap gt 1 gap gap /
1.3 end if i 0 flag false repeat if
Ai gt Aigap swap( Ai, Aigap) flag
true end if i i 1 until i gap gt
A.length until gap 1 and flag false
start with large gap, to push small numbers on
right side quickly to the left reduce the gap
after each pass
one comb (pass)
11Searching definitions.
Search Looking for optimal solutions to discrete
problems
Terminology Discrete problem ? there are
countable (though possibly infinite) feasible
solutions Search space ? the set of all
feasible partial solutions
There are several variables for each variable,
there are several possible values A solution
assign a value to each of the variables A
solution may be infeasible or feasible A
feasible solution may be optimal or not optimal.
12Exhaustive searches modeling
Search Looking for optimal solutions to discrete
problems
Exhaustive search - List all values for one
variable (? discrete!) - For the selected value,
list all possible values of the next variable -
etc.
Common method to model search space Graph Each
node ? a decision (e.g. a value of a
variable) Each arc ? next possible decision
after making some choice
Common exhaustive search methods - Depth
first - Breadth first - Best first
13Search example the n-Queens problem
Place N queens on an NxN chess board such that no
Queen attacks any other
Example partial solution of an 8-queens
problem (only 3 queens have been placed yet)
14Search methods terminology
We will restrict to search over a Graph, G Zero
or more node(s) of the graph are the Target, or
GOAL Search starts at some node, S Each step,
we exploring the graph a little more (i)
Select some node we have reached before (ii)
Check which other nodes we can directly go from
it (Expand it) We maintain two lists CLOSED
Set of nodes that (i) the search has
reached, (ii) are not the GOAL node (ii)
explored one step beyond OPEN Set of nodes
that (i) the search has reached, but not yet
explored
15Depth first search Last In First Out (LIFO)
INPUTS Graph G, MAX-DEPTH, start node S,
GOAL. 1. OPEN , CLOSED 2. Put S
into OPEN, depth( S) 0 3. If OPEN is empty,
exit (FAIL) 4. Remove topmost node from OPEN
and put it into CLOSED call it node n 5. If
depth( n) MAX-DEPTH, go to Step 3. 6. Expand
n, generating all its successors. For each
successor, Snj, Depth (Snj) depth(n)
1 make a pointer from Snj to n if Snj
GOAL, exit(SUCCESS report all nodes from Snj to
start) insert Snj at the beginning of
OPEN 7. If any successor is a dead-end, remove
it from OPEN. 8. Go to step 3
16Depth first example
The 4 Queens problem Note We can place
exactly 1 Q in each row Search starts at top
row MAX-DEPTH 4
17Summary of Depth First
Main idea Start at S, and put it in set OPEN
At each step Pick FIRST element of OPEN If
it is the GOAL we are done. Else Expand
it, Insert all the expanded nodes in the FRONT
of OPEN
Exercise Write how a depth first search of your
computers My Documents folder will explore
different sub-folders.
18Breadth First First In First Out (FIFO)
Main idea First explore all possible nodes at
lower depth, and only then look in the next
deeper level.
Breadth first search tree for the 4-Queens problem
19Depth first vs. Breadth first
If the search tree can be very deep, but you
expect the GOAL is not too far from the Start
node, then use Breadth first
Both, LIFO and FIFO are exhaustive search methods
? In the worst case, we will need to go
around the entire graph to find GOAL
Both are simple to implement (in a computer
program), but only useful for small or mid-sized
problems
20Best first guided search methods
Main idea Use a Heuristic function to identify
more promising paths Explore along the more
promising path first
more likely to lead to GOAL
Most popular best first method Branch and
Bound search
21Branch and Bound search in Scheduling
A simple job-scheduling problem 1 machine, n
tasks waiting to be done. Pi Process time for
the i-th task Di Due date for the i-th
task Li Cost charged per unit time of
tardiness for task i. Cost (Li X t), where t
no of time units of delay
Objective find the task sequence that will
minimize the total tardiness cost
22Background on task scheduling..
From your production controls class, recall
that In general, for most Real-world scheduling
problems, it is not possible to find the optimum
solution in reasonable time (even if using a
super-computer) Why ?
Real-world scheduling methods Production
managers usually use some heuristic to schedule
jobs
Heuristic a sensible choice, but no guarantee
of being optimal
Common heuristics Earliest Due Date (EDD),
Shortest Process Time (SPT)
23Background on task scheduling..
Real-world scheduling heuristics Earliest Due
Date (EDD), Shortest Process Time (SPT)
EDD Arrange tasks in sequence of earliest due
dates
SPT Arrange tasks in sequence of increasing
processing time
Question Using EDD or SPT, do we need to search
for a solution?
24Scheduling using Branch and Bound.
An example problem
Task Pi Di Li
1 37 49 1
2 27 36 5
3 1 1 1
4 28 37 5
4 tasks ? 4! 24 possible sequences to do the
tasks Which is the best? (1) We can list all
permutations, calculate Tardiness Cost for each,
and select the best one BUT (2) What if we
had 50 tasks ? 100 tasks ?
25Scheduling using Branch and Bound..
An example problem
Task Pi Di Li
1 37 49 1
2 27 36 5
3 1 1 1
4 28 37 5
Best first searching We need to find, for a
partial solution, an estimate of how good/bad it
is. For example, suppose we decided to do task 3
first (e.g. guided by SPT) How to estimate
whether this is a good choice or not ?
26Scheduling using Branch and Bound
An example problem
Task Pi Di Li
1 37 49 1
2 27 36 5
3 1 1 1
4 28 37 5
A backward planning approach Suppose we know
that task 2 will be done last, What is the worst
case delay cost in that case? Answer No matter
what sequence the other tasks are done, Task 2
will begin at t(37128) 66, and finish at
t662793 Therefore Tardiness cost for Task 2
W (93-36)5 285
27Scheduling using Branch and Bound.
An example problem
Task Pi Di Li
1 37 49 1
2 27 36 5
3 1 1 1
4 28 37 5
We can say that W is a lower bound on the total
tardiness cost
We can compute W for each possible choice of
which task is done last
We select the most promising among these choices,
to explore further
At each step, we expand the node with minimum W
until the optimum schedule is found
28Scheduling using Branch and Bound..
An example problem
Task Pi Di Li
1 37 49 1
2 27 36 5
3 1 1 1
4 28 37 5
29Best first algorithm...
Algorithm BranchAndBound_Scheduling OPEN 1.
Each task that may be done last is a successor of
START. Construct the search tree by adding
one node for each such task to START. Add
each node to OPEN 2. Calculate lower bound on
total penalty, W Li ( Di - SPj -Pi), for each
node found in step 1. SPj is the sum of all
tasks that remain to be assigned beyond task i in
the tree. 3. Let the node with the lowest W in
OPEN be node k expand k Each successor
of k is a task that is not on the path from START
to k. Add pointers from each successor to
k Add each successor of k to OPEN
Calculate W for each successor Remove k
from open and put it in CLOSED 4. Repeat step 3
until one sequence is completely determined.
The cost of this solution is the
Current_best. 5. Remove all nodes in OPEN with W
? Current_best (these are dead-ends!) 6. If
OPEN is not empty, expand the node with minimum W
in OPEN, as in Step 3 Update the current
minimum penalty cost if a lower penalty schedule
is discovered.
30When the search space is too large
In the worst case, branch-and-bound will take a
very long time to search of the best
solution For example, in our scheduling problem
the search space increases as n!, which is gets
too large very quickly.
How to search for solutions when the space is too
large to explore?
Heuristics Find some solution, and look for
better ones in its neighborhood This
general idea is used in methods like Genetic
Algorithms, Simulated annealing, etc.
31Summary
What you have learnt - Some examples where sort
and search are useful in IT apps - How to write
a simple sort function - How to implement
different types of graph searching
functions Depth first, Breadth first, and Best
first - Decide under what situation you will use
which search method
32References and Further Reading
Books For search methods Judea Pearl,
Heuristics Intelligent Search Strategies for
Computer Problem Solving, Addison Wesley
Web sources for sorting methods 1. Wikipedia,
Comb sort (wikipedia has very good article on
search algorithms also)
Next Communicating applications The
Client-Server Architecture