Simulated Annealing and the Knapsack Problem

Similar documents
SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

Lesson 17 Pearson s Correlation Coefficient

5 Boolean Decision Trees (February 11)

Section 11.3: The Integral Test


Determining the sample size

Modified Line Search Method for Global Optimization

Soving Recurrence Relations

CHAPTER 3 THE TIME VALUE OF MONEY

.04. This means $1000 is multiplied by 1.02 five times, once for each of the remaining sixmonth

I. Chi-squared Distributions

In nite Sequences. Dr. Philippe B. Laval Kennesaw State University. October 9, 2008

where: T = number of years of cash flow in investment's life n = the year in which the cash flow X n i = IRR = the internal rate of return

THE ARITHMETIC OF INTEGERS. - multiplication, exponentiation, division, addition, and subtraction

5.4 Amortization. Question 1: How do you find the present value of an annuity? Question 2: How is a loan amortized?

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 13

A probabilistic proof of a binomial identity

CHAPTER 11 Financial mathematics

Mann-Whitney U 2 Sample Test (a.k.a. Wilcoxon Rank Sum Test)

Now here is the important step

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Exam 3. Instructor: Cynthia Rudin TA: Dimitrios Bisias. November 22, 2011

CS103X: Discrete Structures Homework 4 Solutions

Overview of some probability distributions.

Lecture 2: Karger s Min Cut Algorithm

CS103A Handout 23 Winter 2002 February 22, 2002 Solving Recurrence Relations

THE REGRESSION MODEL IN MATRIX FORM. For simple linear regression, meaning one predictor, the model is. for i = 1, 2, 3,, n

PSYCHOLOGICAL STATISTICS

Confidence Intervals. CI for a population mean (σ is known and n > 30 or the variable is normally distributed in the.

Elementary Theory of Russian Roulette

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies ( 3.1.1) Limitations of Experiments. Pseudocode ( 3.1.2) Theoretical Analysis

Building Blocks Problem Related to Harmonic Series

Definition. A variable X that takes on values X 1, X 2, X 3,...X k with respective frequencies f 1, f 2, f 3,...f k has mean

Properties of MLE: consistency, asymptotic normality. Fisher information.

The Stable Marriage Problem

Multiplexers and Demultiplexers

Analyzing Longitudinal Data from Complex Surveys Using SUDAAN

Chapter 5: Inner Product Spaces

ODBC. Getting Started With Sage Timberline Office ODBC

Listing terms of a finite sequence List all of the terms of each finite sequence. a) a n n 2 for 1 n 5 1 b) a n for 1 n 4 n 2

Taking DCOP to the Real World: Efficient Complete Solutions for Distributed Multi-Event Scheduling

hp calculators HP 12C Statistics - average and standard deviation Average and standard deviation concepts HP12C average and standard deviation

3. Greatest Common Divisor - Least Common Multiple

*The most important feature of MRP as compared with ordinary inventory control analysis is its time phasing feature.

1. C. The formula for the confidence interval for a population mean is: x t, which was

Measures of Spread and Boxplots Discrete Math, Section 9.4

TO: Users of the ACTEX Review Seminar on DVD for SOA Exam FM/CAS Exam 2

NEW HIGH PERFORMANCE COMPUTATIONAL METHODS FOR MORTGAGES AND ANNUITIES. Yuri Shestopaloff,

Chapter 10 Computer Design Basics

Present Value Factor To bring one dollar in the future back to present, one uses the Present Value Factor (PVF): Concept 9: Present Value

Output Analysis (2, Chapters 10 &11 Law)

CHAPTER 3 DIGITAL CODING OF SIGNALS

5: Introduction to Estimation

Confidence Intervals for One Mean

Incremental calculation of weighted mean and variance

Trigonometric Form of a Complex Number. The Complex Plane. axis. ( 2, 1) or 2 i FIGURE The absolute value of the complex number z a bi is

INVESTMENT PERFORMANCE COUNCIL (IPC)

Case Study. Normal and t Distributions. Density Plot. Normal Distributions

Vladimir N. Burkov, Dmitri A. Novikov MODELS AND METHODS OF MULTIPROJECTS MANAGEMENT

Basic Elements of Arithmetic Sequences and Series

Your organization has a Class B IP address of Before you implement subnetting, the Network ID and Host ID are divided as follows:

A Guide to the Pricing Conventions of SFE Interest Rate Products

Research Article Sign Data Derivative Recovery

(VCP-310)

Lecture 4: Cauchy sequences, Bolzano-Weierstrass, and the Squeeze theorem

Convexity, Inequalities, and Norms

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 8

Hypergeometric Distributions

3 Basic Definitions of Probability Theory

Lesson 15 ANOVA (analysis of variance)

Chair for Network Architectures and Services Institute of Informatics TU München Prof. Carle. Network Security. Chapter 2 Basics

FM4 CREDIT AND BORROWING

LECTURE 13: Cross-validation

Theorems About Power Series

4.3. The Integral and Comparison Tests

Solving Logarithms and Exponential Equations

Quadrat Sampling in Population Ecology

Maximum Likelihood Estimators.

Sole trader financial statements

Hypothesis testing. Null and alternative hypotheses

Asymptotic Growth of Functions

Project Deliverables. CS 361, Lecture 28. Outline. Project Deliverables. Administrative. Project Comments

Partial Di erential Equations

, a Wishart distribution with n -1 degrees of freedom and scale matrix.

Institute of Actuaries of India Subject CT1 Financial Mathematics

The analysis of the Cournot oligopoly model considering the subjective motive in the strategy selection

1. MATHEMATICAL INDUCTION

Domain 1: Designing a SQL Server Instance and a Database Solution

Solving equations. Pre-test. Warm-up

Sequences and Series

Systems Design Project: Indoor Location of Wireless Devices

CHAPTER 7: Central Limit Theorem: CLT for Averages (Means)

Chatpun Khamyat Department of Industrial Engineering, Kasetsart University, Bangkok, Thailand

Desktop Management. Desktop Management Tools

Chapter 7: Confidence Interval and Sample Size

NATIONAL SENIOR CERTIFICATE GRADE 12

BINOMIAL EXPANSIONS In this section. Some Examples. Obtaining the Coefficients

Transcription:

Simulated Aealig ad the Kapsack Problem Bejami Misch December 19, 2012 1 The Kapsack Problem The kapsack problem is a classic ad widely studied computatioal problem i combiatorial optimizatio. We are give objects deoted by x i (i =1, 2,...,) each with correspodig weight w i. We ca imagie a perso carryig a backpack who has access to each of these objects. Ufortuately, this perso ca oly hold some maximum weight W i his backpack. The problem follows: what is the optimal assortmet of objects such that the perso maximizes the value of objects i his pack with the costrait of weight W? The applicatios of this simple problem ca be foud i may fields. I ecoomics, the kapsack problem is aalogous to a simple cosumptio model give a budget costrait. I other words, we choose from a list of objects to buy, each with a certai utility, subject to the budget costrait. Because the kapsack problem is a very geeral problem i combiatorial optimizatio, it has applicatios i almost every field. Oe of the most iterestig applicatios is i solvig the so-called Orego Trail problem. 2 Orego Trail Problem The Orego Trail game, a staple of elemetary school educatio i the 1990s, ivolves a player as a pioeer attemptig to travel from Missouri to the West coast i the 1848 while keepig his family safe ad alive. The game takes place i two stages. First, the player chooses his load out before headig out oto the Orego Trail, ad secod, the player the goes o the trail. The kapsack problem applies to the first part. Give several thousad dollars, the player first chooses a size of wago. Each wago ca carry a certai amout of weight. From here, i additio the budget costrait, we have a weight costrait. Next, we pick two travelig compaios from a large assortmet (icludig a baker, a chef, a fisherma, etc.); each choice is uique with a certai amout of weight, moey, ad utility value. The we choose which supplies to take. This process icludes food, weapos, medicie, comforts, ad more. The problem is to choose from all of these combiatios i order to maximize your chace of survivig to the West coast. This is a combiatorial optimizatio problem subject to multiple costraits ad may specific utility fuctios with regard to each item. Clearly this problem is a very advaced ad complicated versio of the kapsack problem, but I thik it paits a good picture as to how the simple kapsack problem ca be exted to somethig of very high complexity. 1

3 The 0-1 Kapsack Problem We will focus o the most basic ad commo versio of the kapsack problem. This versio limits each object to a umber of copies of 0 or 1. We ca mathematically formulate the problem as follows: Let there be items, x 1 to x where each x i has a value v i ad weight w i. The maximum weight that we ca carry i the bag is W. It is commo to assume that all values ad weights are greater tha zero. Maximize: 1 if the item is i the bag v i x i x i = 0 otherwise (1) subject to the costrait w i x i W, x i 0, 1 (2) Maximize the sum of the values of the items i the kapsack so that the sum of the weights must be less tha the kapsack s capacity. We ca approach this problem i two ways: a simple determiistic model ad a simulated aealig model. 4 Algorithm The algorithm solvig the Kapsack Problem is as follows. Imagie you are a thief lootig a house. You see several items aroud the house that you would like to steal, but you ca oly carry a certai amout of weight or you will be caught ruig away. You start with zero weight i your bag. 0. Record your curret assortmet of objects. We will call this ξ 1. ξ = {x 1,x 2,...,x }, x i 0, 1 1. You pick a item at radom with equal probability. 2. Holdig it i your had, you assess whether to add it to your backpack. If addig this ew object ito your bag pushes you over the weight limit, you select a item at radom with equal probability from those i your bag ad the oe from your had. You drop that item. You repeat this process util the objects i your bag are below the weight limit. Otherwise, add the item to your bag. Record the outcome as a trial assortmet. We will call this ξ 1. 3. Compare the value of the trial assortmet with the origial. These values are V 1 ad V 1,respectively. V (ξ) = v i x i, i =1, 2,...,. With some probability P, we accept the ew trial assortmet as the ew assortmet (We will aalyze two methods for determiig this probability). I other words, ξ 2 = ξ 1. Otherwise, we discard the trial assortmet ad set the origial assortmet as the ew assortmet. ξ 2 = ξ 1. 2

Method 1: The Determiistic Model. If the differece betwee the trial ad the origial is greater tha zero, set the trial assortmet as the ew assortmet. I other words, if V1 V 1 > 0, set P(Accept)=1, else set P(Accept)=0. This model does ot coverge to ay sigle optimum; rather it alterates betwee several local optima. Method 2: Simulated Aealig Model. For the theory behid Simulated Aealig, I refer the reader to Homework 10 ad 11. I quick review, simulated aealig ivolves a coolig schedule determied by β ad a statioary probability π β (ξ) = 1 Z(β) e βv (ξ). If we cool slowly eough, we ca avoid gettig trapped i local optima. We determie the probability P by mi{1, e (β ) } where = V1 V 1. β is determied more or less by trial ad error. 5 MATLAB Simulatio Now that we have the theory, we ca test it o a example. Let s assume that you have the followig objects. Our backpack ca oly carry a total weight of 20 kg. v w x 1 $50 5 kg x 2 $40 4 kg x 3 $30 6 kg x 4 $50 3 kg x 5 $30 2 kg x 6 $24 6 kg x 7 $36 7 kg The code for simulated aealig is as follows. This code ca be reappropriated easily for the determiistic model. ----------------------------------------------------------------------------------------- value=[50 40 30 50 30 24 36]; weight=[5 4 6 3 2 6 7]; TotalWeight=20; beta=0:.01:1; =1000; Kapsack( value, weight, TotalWeight, beta, ) fuctio X = Kapsack( value, weight, TotalWeight, beta, ) % Iput: value = array of values associated with object i. % weight = array of weights associated with object i. % TotalWeight = the total weight oe ca carry i the kapsack. % beta = vector of beta values for simulated aealig. % = umber of simulatios per beta value. % Output: FialValue = maximum value of objects i the kapsack. % FialItems = list of objects carried i the kapsack. % Etries i the vector correspod to object i % beig preset i the kapsack. 3

v=legth(value); W=zeros(1,v); Value=0; VW=0; a=legth(beta); =*oes(1,a); for :a b=beta(i); for j=2:(i) m=0; while m==0 c=ceil(rad*v); if W(c)==0 m=1; TrialW=W; TrialW(c)=1; while sum(trialw.*weight)>totalweight e=0; while e==0 d=ceil(rad*v); if TrialW(d)==1 e=1; TrialW(d)=0; f=sum(trialw.*value)-sum(w.*value); g=mi([1 exp(b*f)]); accept=(rad<=g); %Determiistic Model %if f>=0 if accept W=TrialW; VW(j)=sum(W.*value); else VW(j)=VW(j-1); Value=[Value VW(2:legth(VW))]; FialValue=Value(legth(Value)) x=0; for k=1:legth(w) if W(k)==1 x=[x k]; FialItems=x(2:legth(x)) 4

It is a good exercise to try ad solve this problem by had first. The fial solutio is $200 with objects 1, 2, 3, 4, 5. The simulated aealig code solved this correctly i every oe of my trials, but the determiistic model would sometimes get stuck at $176 with objects 1, 2, 4, 7. 6 Compariso of Models I theory the simulated aealig model should give us the correct optimum far more ofte tha the determiistic model. To test this hypothesis, we ca compare the two with a paired t-test. I this case, the ull hypothesis is that the differece betwee the two models is zero. I order to gather the data for the test, we ca ru each simulatio may times ad compare the two. I modified my code slightly to ru each simulatio 100 times. I the catalogued the FialValue for each model. I the used MATLAB to ru the paired t-test. [h,p,ci,stats]=ttest(fvsa,fvdet,left) FVSA correspods to the fial values of the simulated aealig, ad FVDet to those of the determiistic model. I received the followig output: h = 1 p = 1.4834e-09 ci = 5.2265 9.6535 stats = tstat: 6.6692 df: 99 sd: 11.1558 This shows that there is a sigificat differece betwee the two models. Because this is a oe-tailed test, we see that the simulated aealig model is sigificatly greater tha the determiistic model, meaig that the simulated aealig model provides us with a higher value o average. 5