CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

22
CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th , 2004 Kerem Kacel

Transcript of CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Page 1: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

CONSTRAINT PROGRAMMING

Computer Science Seminar

April 9th, 2004

Kerem Kacel

Page 2: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

OUTLINE

Introduction History The Method Constraint Logic Programming Applications Pros/Cons Discussion

Page 3: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

What is Constraint Programming?

Software technologyDescribe and solve large,

combinatorial problems 2 steps

State the constraints of the problemFind a solution satisfying all of the

constraints

Page 4: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

What is a Constraint?

Defined on a set of variables A relation on their domains

e.g. “The circle is inside the square”Does NOT necessarily specify valuesDoes restrict values

Page 5: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Properties of Constraints

Express partial informationX > 0

HeterogeneousY = ABS(X)

Non-directionalX = Y+1 also means Y = X-1

Page 6: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Properties of Constraints (2)

AdditiveX<4, X>1 also means X>1, X<4

Declarative“The pen is on the table”

Usually dependentX + Y = 5, X * Y = 6

Page 7: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

OUTLINE

Introduction History The Method Constraint Logic Programming Applications Pros/Cons Discussion

Page 8: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Some History

Constraint Satisfaction Problems (CSPs) were formalized in early 70s

Constraint Logic Programming (CLP) emerged in early 80s, named by IBM

Prolog II was the first Later

CHIP (Constraints Handling in Prolog)Prolog III

Page 9: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Some History

CosytecFounder of “Global Constraints”

• Helped solve a large class of problems• Planning, scheduling, sequencing

ILOG SOLVERConstraint programming classes for

C++, Java

Page 10: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

OUTLINE

Introduction History The Method Constraint Logic Programming Applications Pros/Cons Discussion

Page 11: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

METHOD

Define the problem as a CSP (Constraint Satisfaction Problem)

Solve the CSP

Page 12: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

What is a CSP?

Constraint Satisfaction ProblemSet of variables X = {x1,…,xn}

Domains Di for each variableSet of constraints

An example CSPA::{1,2}, B::{1,2}, C::{1,2}A = B, A ≠ C, B > C

Page 13: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Solving a CSP

Example CSPA::{1,2}, B::{1,2}, C::{1,2}A = B, A ≠ C, B > C

Generate & TestFor every value assignment in the

domains, check if constraint is mete.g. A = 2, B = 2, C = 1

Page 14: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Solving a CSP

Example CSPA::{1,2}, B::{1,2}, C::{1,2}A = B, A ≠ C, B > C

Back-TrackingStart with a specific assignmentChange values one by one until a

solution is reached

Page 15: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Solving a CSP

Problem: These methods are inefficient

Other methods are being researched to optimize

Page 16: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

OUTLINE

Introduction History The Method Constraint Logic Programming Applications Pros/Cons Discussion

Page 17: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

Constraint Logic Programming

Constraints + LP = CLP

Platforms:CHIPECLiPSe

Page 18: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

OUTLINE

Introduction History The Method Constraint Logic Programming Applications Pros/Cons Discussion

Page 19: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

APPLICATIONS

Assignment problemsPersonnel assignment

Scheduling problemsClass schedules in schoolsProduction planning

Database SystemsEnsure consistency of data

Page 20: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

APPLICATIONS

Natural Language ProcessingConstruction of efficient parsers

Electrical EngineeringLocating faults in circuits

Molecular BiologyDNA sequences

Page 21: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

PROS/CONS

+ DeclarativeDescribe the problem, not solution

+ SemanticsClean, elegant languages

- UnpredictableWe don’t know how efficient

Page 22: CONSTRAINT PROGRAMMING Computer Science Seminar April 9 th, 2004 Kerem Kacel.

DISCUSSION

“Were you to ask me which programming paradigm is likely to gain most in commercial significance over the next 5 years I’d have to pick Constraint Logic Programming, even though it’s perhaps currently one of the least known and understood.”

Dick Pountain, BYTE, February 1995