1D Bin Packing (or “CP? Who cares?”)

Slides:



Advertisements
Similar presentations
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Advertisements

Finding Optimal Solution of 15 puzzle B NTUCSIE Kai-Yung Chiang.
1 Branch-and-Price (Column Generation) Solving Integer Programs With a Huge Number of Variables CP-AI-OR02 School on Optimization Le Croisic, France March.
Math for Liberal Studies. There is a list of numbers called weights These numbers represent objects that need to be packed into bins with a particular.
Algorithm Design Methods (I) Fall 2003 CSE, POSTECH.
Algorithm Design Methods Spring 2007 CSE, POSTECH.
Bin Packing First fit decreasing algorithm
Bin Packing First fit algorithm
NP-Completeness.
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
 Review: The Greedy Method
CS223 Advanced Data Structures and Algorithms 1 Greedy Algorithms Neil Tang 4/8/2010.
But Shaun’s already proved P equals NP. Can’t we move onto quantified SAT? Woof!
Bowen Yu Programming Practice Midterm, 7/30/2013.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Discussion #33 Adjacency Matrices. Topics Adjacency matrix for a directed graph Reachability Algorithmic Complexity and Correctness –Big Oh –Proofs of.
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
NP-complete and NP-hard problems
Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)
Cardinality & Sorting Networks. Cardinality constraint Appears in many practical problems: scheduling, timetabling etc’. Also takes place in the Max-Sat.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
Artificial Intelligence Lecture 9. Outline Search in State Space State Space Graphs Decision Trees Backtracking in Decision Trees.
CSCE350 Algorithms and Data Structure
Scott Perryman Jordan Williams.  NP-completeness is a class of unsolved decision problems in Computer Science.  A decision problem is a YES or NO answer.
Approximation schemes Bin packing problem. Bin Packing problem Given n items with sizes a 1,…,a n  (0,1]. Find a packing in unit-sized bins that minimizes.
Optimal Scheduling of File Transfers with Divisible Sizes on Multiple Disjoint Paths Mugurel Ionut Andreica Polytechnic University of Bucharest Computer.
Design Techniques for Approximation Algorithms and Approximation Classes.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
Lesson Objective: Understand what an algorithm is and be able to use them to solve a simple problem.
© Ronaldo Menezes, Florida Tech Fundamentals of Algorithmic Problem Solving  Algorithms are not answers to problems  They are specific instructions for.
Topic 25 Dynamic Programming "Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it.
Operational Research & ManagementOperations Scheduling Economic Lot Scheduling 1.Summary Machine Scheduling 2.ELSP (one item, multiple items) 3.Arbitrary.
CSCI 2670 Introduction to Theory of Computing November 17, 2005.
The bin packing problem. For n objects with sizes s 1, …, s n where 0 < s i ≤1, find the smallest number of bins with capacity one, such that n objects.
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
Car Sequencing Problem Assessed exercise 2 15% 26/11/2010.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Approximation Algorithms Department of Mathematics and Computer Science Drexel University.
Errol Lloyd Design and Analysis of Algorithms Approximation Algorithms for NP-complete Problems Bin Packing Networks.
BIN SORTING Problem Pack the following items in bins of size Firstly, find the lower bound by summing the numbers to be packed.
The Theory of NP-Completeness
Chapter 10 NP-Complete Problems.
Mathematical Foundations of AI
Bin Packing First fit decreasing algorithm
Bin Packing First fit algorithm
Algorithm Design Methods
Design and Analysis of Algorithm
Bin Packing Optimization
Exam 2 LZW not on syllabus. 73% / 75%.
Bin Packing First fit decreasing algorithm
Bin packing – First fit algorithm
Number partitioning.
Bin Packing First fit decreasing algorithm
Bin Packing First fit decreasing algorithm
Algorithm Design Methods
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
Algorithm Design Methods
Bin Packing First fit algorithm
A Few Sample Reductions
Our old list of problems
Bin Packing Michael T. Goodrich Some slides adapted from slides from
Algorithm Design Methods
Presentation transcript:

1D Bin Packing (or “CP? Who cares?”) A case study

[SR1] BIN PACKING INSTANCE: Finite set U of items, a size s(u) in Z+ for each u in U, a positive integer bin capacity B, and a positive integer K. QUESTION: Is there a partition of U into disjoint sets U1, U2, …, Uk such that the sum of the sizes of the items in each Ui is B or less? Garey & Johnson “Computers and Intractability: A guide to the theory of NP-Completeness”

An example data = 42 63 67 57 93 90 38 36 45 42 n = 10 // 10 numbers m = 5 // 5 bins c = 150 // bin capacity of 150 Can we pack the above 10 numbers into 5 bins such that the sum of the numbers in each bin is less than or equal to 150? Note: the above 10 numbers sum to a total of 579 579/150 = 3.86

1st stab Typical constraint for one bin Read in the numbers into array called data Associate an array of constrained integer variables v with a bin vi is 1 if and only if the ith number is in that bin

More specifically The sum of the numbers in a bin is less than or equal to its capacity

load[i] is the sum of the numbers in the ith bin where load[i] is a constrained integer variable with domain [0 .. C]

Note 1 We have n.m 0/1 constrained integer variables Question: How big is the potential state space?

Only in one place at any one time! A number data[i] can only be in one bin at any one time! Therefore, the number of 1’s in any column must be exactly 1

If there are numbers in a bin then that bin is used. Is a bin used? If there are numbers in a bin then that bin is used. binUsed[i] = 1 iff and only if load[i] > 0 Where binUsed is 0/1 constrained integer variable

How many bins are used? Sum up the number of bins used and ensure that this is less than or equal to the number of bins that we have totBinsUsed is a constraint integer variable with domain [0..m]

Program has the following command line inputs fname The name of a file containing 100 or more numbers c The (uniform) capacity of each bin n The number of numbers to read from file fname m The number of bins Program finds first solution and displays number of nodes, and the solution

Remember … we will optimise via a sequence of decision problems Keep reducing the number of bins until no solution

It does nothing! What is it doing? What is search doing?

Decisions, decisions  What are the decision variables?!

It is so slow! Why is it so slow? What is search doing?

Value Ordering!

It’s still slow!

Is there a heuristic? 1st fit decreasing

93 90 69 67 57 45 42 42 38 36 sorted

Bin Packing First fit decreasing algorithm A B C D E F With the first fit decreasing algorithm we sort the blocks into descending order first. 6 5 4 3 3 3 2 2 1

Bin Packing First fit decreasing algorithm A B C D E F Now we use the first fit algorithm 6 5 4 3 3 3 2 2 1

Bin Packing First fit decreasing algorithm 6 A B C D E F Now we use the first fit algorithm 5 4 3 3 3 2 2 1

Bin Packing First fit decreasing algorithm 5 6 5 A B C D E F Now we use the first fit algorithm 4 3 3 3 2 2 1

Bin Packing First fit decreasing algorithm 4 4 6 5 4 A B C D E F Now we use the first fit algorithm 3 3 3 2 2 1

Bin Packing First fit decreasing algorithm 3 3 3 6 5 4 3 A B C D E F Now we use the first fit algorithm 3 3 2 2 1

Bin Packing First fit decreasing algorithm 3 3 3 6 3 5 4 3 A B C D E F Now we use the first fit algorithm 3 2 2 1

Bin Packing First fit decreasing algorithm 3 3 3 3 6 3 5 4 3 3 A B C D E F Now we use the first fit algorithm 2 2 1

Bin Packing First fit decreasing algorithm 2 2 6 2 3 5 4 3 3 A B C D E F Now we use the first fit algorithm 2 1

Bin Packing First fit decreasing algorithm 2 2 2 2 6 2 3 5 2 4 3 3 A B C D E F Now we use the first fit algorithm 1

Bin Packing First fit decreasing algorithm 1 6 1 2 3 5 2 4 3 3 A B C D E F Now we use the first fit algorithm We have packed them into 5 bins.

Slow proving optimality Don’t have a test that sum of numbers over capacity is less than or equal to the number of bins available!

Symmetries? Are there any symmetries that are slowing down search? Can we remove those symmetries? What are the symmetries in this problem?

Symmetries? Why not insist that load[i] >= load[i+1]? How about “lex” ordering between rows of inBin?

Is there another model? ?

An alternative (and it’s consequences)? Introduce an array of constrained integer variables loc[j] with domain [0..m] Consequences: Array loc is now decision variables No longer need to insist that sums of columns of inBin equal 1 Question: what’s the size of the state space now?

So? What have we learned? Identify the decision variables What is the size of the state space? What is the size of the model? What is value ordering doing to the search? Can we use any heuristics? Are there symmetries that we can break? Are there any simple/redundant tests/constraints overlooked? Is there an alternative model?

And let’s not forget the big question … 9. Why are we using constraint programming? Answers?