CS 485 Fall 2005
Topics in Artificial Intelligence: Search Techniques

Assignment 4 – Optimization

Due Tuesday, Nov. 29

Obtain a free student edition of MPL Modeling Software from Maximal USA (http://www.maximal-usa.com) for use in solving Linear Programming problems (LP's) in this assignment. NOTE: you will not be able to use this software to solve LP's until you receive a license from Maximal USA. The license will be sent via email; you should take care of downloading and requesting a license as soon as possible.

1. Formulate as an LP and solve:

Mr. and Mrs. Adamson are going out of town for the weekend, which means Glen has to fix his own meals on Saturday. They will let him have whatever food he wants, as long as he can prove that he will meet the US Recommended Daily allowances in Protein, Vitamins A, B6, and C, Thiamine, Riboflavin, Niacin, Calcium, Iron, and Phosphorous. (They are not particulalry concerned about Folic Acid, Vitamin B12, Magnesium, Zinc, Copper, or Pantothenic Acid, because Glen has a chemistry set containing these ingredients, and they don't want him to get any ideas.) Glen assembles the nutritional information for his favorite foods (see below), and prepares a shopping list. It is to his benefit to meet the nutritional requirements at minimal cost, because he can keep any money left over after he buys the items. Notice that he must by whole packages of whatever items he buys (e.g., he cannot buy 1.7 bags of potato chips). Furthermore, although some of the items show asterisks in some of the categories (indicating that there is less than 2% of the RDA in a serving, he must consider these amounts to be 0%, because he cannot prove that the content is sufficient to meet his needs.

Formulate as an Integer Linear Program, and solve. (Note: data collected in 1990)

Prot
Vit. A
Vit. C
Thia
Ribo
Niac
Calc
Iron
Phos
Vit. B6
Serv/Pack
Price/Pack
Durkee's Onion Rings
4
 
 
2
2
2
 
2
6
 
3.2
$1.99
Ben & Jerry's Ice Cream
15
8
 
4
20
 
20
 
15
 
4
$2.69
Pringle's BBQ Chips
2
 
6
2
 
4
 
2
 
 
6.75
$1.95
Herr's Cheese Puffs
2
 
 
15
2
 
2
 
 
 
8
$1.29
Milky Way Candy Bar
4
10
 
 
8
 
6
2
 
 
1
$0.79
Kellogg's Pop Tarts
4
 
 
10
10
10
 
10
6
10
6
$1.99
Herr's BBQ Chips
 
 
10
2
2
4
 
2
 
4
1
$0.69
Pepperidge Farm Cookies
2
 
 
 
 
 
 
 
 
 
8
$2.09
Keebler Popcorn Deluxe
2
 
 
2
2
2
4
2
 
 
4
$1.29
Bachman Thin Pretzels
4
 
 
10
10
15
 
10
 
 
9
$1.39
Nacho Cheese Combos
4
 
 
2
2
4
4
2
 
 
8
$1.89

 

2. Transportation Problem:
Five patients require blood transfusions, according to the chart on the left. The current blood supply is shown in the chart on the right:

Patient
1
2
3
4
5
Blood Type
A
AB
B
O
A
Pints Needed
2
3
1
2
3
 
Blood Type
A
AB
B
O
Pints Available
7
4
6
5
Cost/Pint
1
4
2
5

Recall that type O is the universal donor and type AB is the universal recipient. This means that anybody can use type O and a type AB patient can use blood of any type. We wish to figure out how many pints of each type blood to give to each patient, in order to minimize cost.

 

3. A mill of the Fine-Webb Paper Company produces so-called liner board in jumbo reels having a standard width of 68 inches. (Each reel has a fixed length.) The company's customers, however, order reels having smaller widths (and the same fixed length as the larger reel). Today's orders are for 110 reels of 22-inch width, 120 reels of 20-inch width, and 80 reels of 12-inch width. These smaller widths are to be cut from the larger standard size reel.

For example, the company can decide to slit a jumbo reel into two reels each 22 inches wide, and one reel 20 inches wide; this leaves 4 inches of trim waste from the 68-inch jumbo. The production scheduler, Manny Blanks, wants to manufacture today's orders so as to minimize total trim waste.

  1. Find every possible way to slit a 68-inch jumbo reel into combinations of 22-inch, 20-inch, and 12-inch width reels. One such combination was already illustrated in the example. Calculate the trim waste for each combination. Label the combinations 1,2,3,... and let xi be the number of jumbo reels cut into Combination i.
  2. Formulate the problem as a linear programming model. (Note that if any smaller reels in excess of the customer requirements are produced, these too must be counted as waste.)
  3. Show that the objective function can also be written as
    min z = 68( x1 + x2 + ... )

4. Branch and Bound:

Using Branch and Bound, solve this Integer Linear Program. Show your logic tree in solving the problem.

max z = 6x1 + 5x2
s.t. 6x1 + 5x2 ≤ 56
6x1 + 3x2 ≤ 40
-x1 + 2x2 ≤ 8
2x1 - 2x2 ≤ 11
x1 , x2 ≥ 0, integer

 

5. Traveling Salesman Problem:

We saw that the n-city traveling salesman problem can be formulated and solved as an LP. Unfortunately, the number of constraints is exponential in n. We also saw that this large number of constraints is needed to ensure that no subcycles occur - e.g., for a 5-city TSP, we must ensure that subcycles such as 1->2->3->1 and 4->5->4 are eliminated.

Define the Relaxed TSP formulation as a set of constraints that ensure merely that each city is entered and exited exactly once, i.e., if xij is assigned the value 1 if i->j is in the tour and 0 if it is not in the tour, then constraints of the form xi1 + xi2 + ... + xin = 1 ensure that city i will be exited exactly once and constraints of the form x1j + x2j + ... + xnj = 1 ensure that city j will be entered exactly once. (Note that the variables xii and xjj should not be included in these equations, which will ensure they never receive a value.)

An approach to solving the TSP is to begin by solving the Relaxed TSP. If the Relaxed TSP provides a complete tour with no subcycles, stop. Otherwise, if subcycles exist, continue iteratively by introducing constraints that prevent those subcycles only. Using this method, solve the following TSP:

1 2 3 4 5 6
1
-
3
93
13
33
9
2
4
-
77
42
21
16
3
45
17
-
36
16
28
4
39
90
80
-
56
7
5
28
46
88
33
-
25
6
3
88
18
46
92
-

 

6. Automating Dynamic Programming:
The main concept of dynamic programming is to reduce the amount of computation needed to solve a problem by carefully arranging the order in which values are computed, and storing them in a table for reuse. The usual approach is to develop an algorithm that begins at the end of a series of computations and work backwards, storing values as it progresses. This contradicts somewhat the approach of developing a recursive solution to a problem -- whereas a recursive solution can be elegant, it will typically start at the beginning and work towards the end. We have seen that this can cause recalculation to occur at staggering rates.

Can top-down recursion coexist with bottom-up dynamic programming? Sure!

In class, we discussed calculation of the Fibonacci numbers with the following recursive function:


	int Fib(int n)
	{
	   // precondition: n>=0
		
	   if(n<=1)
	      return 1 ;
	   else
	      return Fib(n-1) + Fib(n-2) ;
	}

We saw that this was very inefficient, in that it requires recomputation of F(k-2) when calculating F(k-1) and when calculating F(k), for all values of k≥2. We also saw that this problem could be fixed simply in the following way:

See below:


	int Fibo(int n)
	{
	   // precondition: n>=0
		
	   if(n<=1)
	      return 1 ;
	   else if( undefined( f[n] ) )
	      f[n] = Fibo(n-1) + Fibo(n-2) ;
		
	   return f[n] ;	
	}
  1. verify that the functions Fib(n) and Fibo(n) return the same results and that Fibo(n) is more efficient. Count the number of recursive calls by each routine for various values of n.
  2. find a value of n for which calculation of Fib(n) requires at least one minute in your computing environment, and compare the time and number of recursive calls required by each.
  3. In class, we also discussed the "longest up-sequence" problem: determine the length of the longest subsequence of strictly increasing integers in a list, e.g., given the list L = {3, 1, 4, 1, 5, 9, 6, 2, 17, 14, 15, 9, 22, 16, 18}, the subsequence [4,5,9,17,22] is an up-sequence of L. It is not the longest up-sequence, however: the subsequence [3,4,5,6,14,15,16,18] is an up-sequence of length 8, which is the longest length. The following recursive function solves this problem, by observing that for each element L[i], the longest upsequence beginning with L[i] is one longer than the longest upsequence beginning with L[j], for some j>i with L[j]>L[i].
    
    	int LUP(int i, vector<int>& v)
    	// returns length of longest upsequence in list v[i],v[i+1],...,v[n-1]
    	// where v.size()==n .
    	{
    	   if( i==v.size()-1 )
    	      return 1 ;
    			
    	   int max = 0 ;
    	   int temp ;
    		
    	   for(int j=i+1; j<v.size(); j++ )
    	   {
    	      temp = LUP(j,v) ;
    	      if( v[i]<v[j] )
    	         temp = temp + 1 ;
    				
    	      if( temp > max )
    	         max = temp ;
    	   }
    		
    	   return max ;
    	}
    
    This function is horribly inefficient, however! Rewrite this function so that it maintains an array of results as in the Fib/Fibo example in parts (a)-(b) and returns the array value whenever it is defined, rather than generating further recursive calls.
  4. Repeat parts (a)-(b) for LUP and your rewritten function.