Explorations in artificial intelligence
This presentation is the property of its rightful owner.
Sponsored Links
1 / 75

Explorations in Artificial Intelligence PowerPoint PPT Presentation


  • 48 Views
  • Uploaded on
  • Presentation posted in: General

Explorations in Artificial Intelligence. Prof. Carla P. Gomes [email protected] Module 4-1 Constraint Programming. Constraint Programming. Constraint programming is a research area for declarative description and effective solving of large, particularly combinatorial;

Download Presentation

Explorations in Artificial Intelligence

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Explorations in artificial intelligence

Explorations in Artificial Intelligence

Prof. Carla P. Gomes

[email protected]

Module 4-1

Constraint Programming


Constraint programming

Constraint Programming

  • Constraint programming is a research area for declarative description

  • and effective solving of large, particularly combinatorial;

  • Combines different fields:

    • Artificial Intelligence;

    • Programming Languages;

    • Symbolic Computing;

    • Computational Logic;

    • Operations Research;

Very competitive and even outperforming other approaches for solving hard combinatorial problems

Recent years there have been several successful applications it is now part of standard OR books.


Explorations in artificial intelligence

  • Began in 1980s from AI world

    • Prolog III (Marseilles, France)

    • CLP(R)

    • CHIP (ECRC, Germany)

  • Application areas

    • Image processing, Scheduling, sequencing, resource and personnel allocation, etc. etc.

  • Active research area

    • Specialized conferences (CP, CP/AI-OR, )

    • Journal (Constraints)

    • Companies (Ilog and others)


Constraint programming1

Constraint Programming

  • Two main contributions

    • A new approach to combinatorial optimization

      • Orthogonal and complementary to standard OR methods

      • Combinatorial versus numerical

    • A new language for combinatorial optimization

      • Rich language for constraints

      • Language for search procedures


Modeling in constraint programming

Modeling in Constraint Programming

  • A rich constraint language

    • Arithmetic, higher-order, logical constraints

    • Global constraints for natural substructures

  • Specification of a search procedure

    • Definition of search tree to explore

    • Specification of search strategy

Satisfiability is a particular case of a constraint programming language.


Constraint programming2

Constraint Programming

  • 1- Problem Formulation:

  • A problem is a finite set of constraints involving a finite set of variables.

    • Constraint Satisfaction Problems (CSP) feasibility problem only and --- SAT is a particular case of CSP;

    • Constraint Optimization Problems (COP) if in addition the solution is required to maximize an objective function

  • 2- Problem Solution:

    • Domain specific methods

    • General Solution Methods


Explorations in artificial intelligence

  • Constraint programming is the study of computational systems based on constraints.

  • A constraint

  • Logical relation among several unknowns (or variables), each taking a value in a given domain. A constraint thus restricts the possible values that variables can take, it represents some partial information about the variables of interest.

  • Very general framework. Very expressive;


Constraint satisfaction problems

Constraint Satisfaction Problems

  • A Constraint Satisfaction Problem (P) consists of:

    • A set of variables, X1,,Xn ;

    • For each variable Xi, a domain of possible values, Dom(Xi).

    • A set of constraintsC1,,Cm .

    • A constraint Ci on k variables Xci1,,Xcik is a relation R(Xci1,,Xcik)Dci1xxDcik that specifies the valid combinations of values for the variables involved.

    • A (feasible) solution to a CSP is an assignment of values to all the variables, one value per variable, satisfying all the constraints.

Why is Satisfiability a particular case of CSP?


Explorations in artificial intelligence

  • A variable V can be assigned a value v (V v) if and only if v Dom(V).

  • A consistent set of assignments is a set of assignments {V1 v1, , Vk vk}, such that all the constraints are satisfied, and each of the Vi is unique;

  • A (feasible) solution is a complete consistent set of assignments, i.e., one consistent set of assignments in which the number of variables in the set is equal to the number of variables in the problem (n).


Explorations in artificial intelligence

  • Any subset of a (feasible) solution is consistent;

  • We might be interested in finding:

    • Any (feasible) solution

    • Enumerating or counting all the (feasible) solutions or all optimal solutions

    • Finding the optimal solution --- i.e., (feasible) solution(s) that optimize(s) an objective function


Constraint programming at a glance modeling

Constraint Programming At a Glance: Modeling

Graph Coloring Problem:

Can we color the regions of the map of Australia,

using three colors red, green, and blue - such that adjacent regions have

different colors?

Source: AIMA Russell and Norvig


Constraint programming at a glance modeling1

Constraint Programming At a Glance: Modeling

1 Modeling

Rich language

Different Models (Binary, N-ary, Global Constraints,etc)

Source: AIMA Russell and Norvig


The constraint graph

The Constraint Graph


Planar graphs

Planar Graphs

  • Special type of graphs planar graphs.

  • Planar Graph is a graph that can be drawn (mathematicians say "can be embedded

  • in the plane") so that no edges intersect. A nonplanar graph cannot be drawn without

  • edge intersections.

The graph representation of a map (each region corresponds to a node; edges

link neighbor regions) is a planar graph.

B

C

G

B

G

D

A

C

D

F

F

A

E

E


Planar vs nonplanar graphs

Yes

Planar graph?

Planar vs. NonPlanar Graphs

Planar graph

K5

K3,3

NonPlanar graph

NonPlanar graph


Explorations in artificial intelligence

A subdivision of a graph results from inserting vertices into edges (for example, changing an edge to ) and repeating this zero or more times.

Example of a subdivision of K3,3.

Planar Graph - A finite graph is planar iff it does not contain a subgraph that is a subdivision of K5 (the complete graph on five vertices) or K3,3 (complete bipartite graph on six vertices, three of which connect to each of the other three).


Four color theorem

Four Color Theorem

  • The chromatic number of a graph is the least number of colors

  • that are required to color a graph.

  • The Four Color Theorem the chromatic number of a planar graph

  • is no greater than four.

  • Proof: Appel and Haken 1976; careful case analysis performed by computer; proof

  • reduced the infinitude of possible maps to 1,936 reducible configurations (later

  • reduced to 1,476) which had to be checked one by one by computer. This

  • reducibility part of the work was independently double checked with different

  • programs and computers. The computer program ran for hundreds of hours.

Four color map.


Graph coloring for arbitrary graphs

Graph Coloring for Arbitrary Graphs

  • Four Color Theorem only applies to planar graphs;

  • For an arbitrary graph

  • finding the chromatic number of an arbitrary graph takes exponential time (in the worst-case);

  • even finding an approximation to the chromatic number up to a factor of 2 (i.e., a bound which is no more than double the chromatic number) is hard if we found a polynomial time approximation algorithm with less than a factor of 2, then we would also find a polynomial time algorithm for finding the excat chromatic number of the graph.


Application of graph coloring

1

1

7

7

2

2

6

6

3

3

5

5

4

4

Application of Graph Coloring

  • Lots of applications involving scheduling and assignments.

  • Scheduling of final exams nodes represent finals, edges between finals

  • denote that both finals have common students (and therefore they have to

  • have different colors, or different periods).

Time Period courses

I (red) 1,6

II (blue)2

III (green)3,5

IV (black)

Graph of finals for 7 courses


Constraint programming at a glance search

Constraint Programming At a Glance: Search

  • 2 Search

  • Different variants of backtrack search (Depth First Search; Breadth-First Search; Iterative Deepening; branch and bound, etc)

  • core of AI technology

  • Deterministic vs. Randomized backtrack search


Standard search formulation incremental

Standard search formulation (incremental)

  • Let's start with the straightforward approach, then fix it

  • States are defined by the values assigned so far

  • Initial state: the empty assignment { }

  • Successor function: assign a value to an unassigned variable that does not conflict with current assignment

    fail if no legal assignments

  • Goal test: the current assignment is complete

  • This is the same for all CSPs

  • Every solution appears at depth n (or less than n) with n variables use depth-first search


Backtracking search

Backtracking search

  • Variable assignments are commutative}, i.e.,

  • [ WA = red then NT = green ] same as [ NT = green then WA = red ]

  • Only need to consider assignments to a single variable at each node

    b = d and there are $d^n$ leaves

  • Depth-first search for CSPs with single-variable assignments is called backtracking search

  • Backtracking search is the basic uninformed algorithm for CSPs


Backtracking search1

Backtracking search


Backtracking example

Backtracking example


Backtracking example1

Backtracking example


Backtracking example2

Backtracking example


Backtracking example3

Backtracking example


Improving backtracking efficiency

Improving backtracking efficiency

  • General-purpose methods can give huge gains in speed:

    • Which variable should be assigned next?

    • In what order should its values be tried?

    • Can we detect inevitable failure early?


Most constrained variable

Most constrained variable

  • Most constrained variable:

    choose the variable with the fewest legal values

  • a.k.a. minimum remaining values (MRV) heuristic


Most constraining variable

Most constraining variable

  • Tie-breaker among most constrained variables

  • Most constraining variable:

    • choose the variable with the most constraints on remaining variables


Least constraining value

Least constraining value

  • Given a variable, choose the least constraining value:

    • the one that rules out the fewest values in the remaining variables

  • Combining these heuristics makes 1000 queens feasible


Constraint programming at a glance consistency

More advanced

Constraint Programming At a Glance: Consistency

  • 3 Consistency

  • Key concept in Constraint Programming idea: remove inconsistent values from variables domains;

  • Different notions of consistency:

  • Node consistency (1 variable at a time)

  • Arc consistency (2 variables at a time)

  • Forward checking (simple version of arc consistency;

  • 2 variables at a time)

  • Hyper-arc consistency (k>2 variables at a time)

  • Global Constraints


Node consistency

Node Consistency

  • The simplest form of consistency technique; Lets G=(V,C) denote the constraint

  • graph of a binary CSP:

  • Node Consistency

  • The node representing a variable V in the constraint graph is node consistent if for every value x in the current domain of V, each unary constraint on V is satisfied.

  • Node consistency achieved by simply removing values from the domain D of each variable V that do not satisfy unary constraints on V.


Forward checking

Forward checking

  • Idea:

    • Keep track of remaining legal values for unassigned variables

    • Terminate search when any variable has no legal values


Forward checking1

Forward checking

  • Idea:

    • Keep track of remaining legal values for unassigned variables

    • Terminate search when any variable has no legal values


Forward checking2

Forward checking

  • Idea:

    • Keep track of remaining legal values for unassigned variables

    • Terminate search when any variable has no legal values


Forward checking3

Forward checking

  • Idea:

    • Keep track of remaining legal values for unassigned variables

    • Terminate search when any variable has no legal values


Constraint propagation

Constraint propagation

  • Forward checking propagates information from assigned to unassigned variables, but doesn't provide early detection for all failures:

  • NT and SA cannot both be blue!

  • Constraint propagation repeatedly enforces constraints locally


Arc consistency

T

Arc consistency

  • Simplest form of propagation makes each arc consistent

  • X Y is consistent iff

    for every value x of X there is some allowed y


Arc consistency1

T

Arc consistency

  • Simplest form of propagation makes each arc consistent

  • X Y is consistent iff

    for every value x of X there is some allowed y


Arc consistency2

T

Arc consistency

  • Simplest form of propagation makes each arc consistent

  • X Y is consistent iff

    for every value x of X there is some allowed y

  • If X loses a value, neighbors of X need to be rechecked


Arc consistency3

T

Arc consistency

  • Simplest form of propagation makes each arc consistent

  • X Y is consistent iff

    for every value x of X there is some allowed y

  • If X loses a value, neighbors of X need to be rechecked

  • Arc consistency detects failure earlier than forward checking

  • Can be run as a preprocessor or after each assignment


Arc consistency algorithm ac 3

Arc consistency algorithm AC-3

  • Time complexity: O(n2d3)


Constraint programming at a glance arc consistency

Constraint Programming At a Glance: Arc Consistency

If Xs domain is reduced, neighbors of X have to be rechecked.


Constraint programming at a glance integration of search consistency

look back

look ahead

Labelling order

Constraint Programming At a Glance: Integration of Search + Consistency

  • 4 Search + Consistency Constraint Propagation

  • Combination of search (backtracking) with consistency techniques methods:

    • look ahead (preventing conflicts)

    • forward checking, full look-ahead, etc

    • look back (learning from conflicts)

More advanced

R. Bartak 99


Examples of applications of graph coloring

Examples of Applications of Graph Coloring


Scheduling of final exams

Scheduling of Final Exams

  • How can the final exams at Cornell be scheduled so that no student nhas

  • two exams at the same time?

  • A vertex correspond to a course;

  • An edge between two vertices denotes that there is at least one common

  • Student in the courses they represent;

  • Each time slot for a final exam is represented by a different color.

  • A coloring of the graph corresponds to a valid schedule of the exams.


Scheduling of final exams1

1

Time

Period

I

II

III

IV

Courses

1,6

2

3,5

4,7

2

7

6

3

5

4

Scheduling of Final Exams

1

2

7

6

3

5

4

What are the constraints between courses?

Find a valid coloring


Frequency assignments

Frequency Assignments

  • T.V. channels 2 through 13 are assigned to stations in North

  • America so that no no two stations within 150 miles can operate on

  • the same channel. How can the assignment of channels be

  • modeled as a graph coloriong?

  • A vertex corresponds to one station;

  • There is a edge between two vertices if they are located within 150 miles

  • of each other

  • Coloring of graph --- corresponds to a valid assignment of channels;

  • each color represents a different channel.


Index registers

Index Registers

  • In efficient compilers the execution of loops can be speeded up by storing

  • frequently used variables temporarily in index registers in the central

  • processing unit, instead of the regular memory. Fopr a given loop, how

  • many index registers are needed?

  • Each vertex corresponds to a variable in the loop.

  • An edge between two vertices denotes the fact that the corresponding variables must be stored in index registers at the same time during the execution of the loop.

  • Chromatic number of the graph gives the number of index registers needed.


Other examples

Other examples


Crypto arithmetic puzzle

Crypto-arithmetic Puzzle

  • SEND9567

  • +MORE + 1085

  • ----------- ----------

  • MONEY 10652

Variables: S E N D M O R Y

Domains:

[1..9] for S and M

[0..9] for E N D O R Y


Crypto arithmetic puzzle constraints 1

Crypto-arithmetic Puzzle Constraints 1

  • 1 single constraint

1000 S + 100 E + 10 N + D +

1000 M + 100 O + 10 R + E

=

10000 M + 1000 O + 100 N + 10 E + y

Or

5 equality constraints, using carry variables C1, , C4 [0..9]

SEND

+MORE

-----------

MONEY

D + E = 10 C1 + Y;

C1 + N + R = 10 C2 + E;

C2 + E + O = 10 C3 + N;

C3 + S + M = 10 C4 + O;

C4 = M


Crypto arithmetic puzzle constraints 2

Crypto-arithmetic Puzzle Constraints 2

  • 28 not-equal constraints

  • X Y, X,Y {S E N D M O R Y}

  • Or

  • A single constraint

  • Alldifferent(S, E, N, D, M, O, R, Y)

Alldifferent(X1, , Xn) it states in a compact way that the variables

X1, , Xn have all different values assigned to them

Global constraint (it involves n-ary constraint)

Special procedures to handle this constraint


8 queens problem

8 Queens Problem

The standard 8 by 8 Queen's problem asks how to place 8 queens

on an ordinary chess board so that they dont attack each other


Analysis of polyhedral scenes

Analysis of Polyhedral Scenes

  • Origins of constraint satisfaction problems

  • researchers in computer vision in the 60s-70s were interested in developing a procedure to assign 3- dimensional interpretations to scenes;

  • They identified

  • Four types of junctions

  • Three types of edges


Edge types

Edge Types

  • Hidden if one of its planes cannot be seen

  • represented with arrows:

  • or

  • Convex from the viewers perspective

  • represented with

  • +

  • Concave from the viewers perspective

  • represented with

  • -


Types of junctions

Types of Junctions

Type of junction: L Fork T Arrow


Csp model

CSP Model

  • Variables Edges;

  • Domains {+,-,,}

  • Constraints:

  • 1- The different type junctions define constraints:

  • L, Fork, T, Arrow;

  • L = {(, ) , ( , ), (+, ), (,+), (-, ), (,-)}

  • Fork = { (+,+,+), (-,-,-), (,,-), (,-,),(-,,)}

L(A,B) the pair of values assigned to variables A,B

has to belong in the set L;

Fork(A,B,C) the trio of values assigned to variables A,B,C

has to belong in the set Fork;


Csp model1

CSP Model

  • T = {(, , ) , ( ,,), (,,+), (,-)}

  • Arrow = { (,,+), (+,+,-), (-,-,+)}

T(A,B,C) the trio of values assigned to variables A,B,C

has to belong in the set T;

Arrow(A,B,C) the trio of values assigned to variables A,B,C

has to belong in the set Arrow;

2- For each edge XY its reverse YX has a compatible value

Edge = { +,+), (-,-), (,),(,)}

Edge(A,B) the pair of values assigned to variables A,B

has to belong in the set Edge;


Csp model cube

E

F

A

B

G

C

D

CSP Model - Cube

How to label the cube?


Csp model2

E

F

A

B

G

C

D

CSP Model

  • Variables: Edges: AB, BA,AC,CA,AE,EA,CD,

  • DC,BD,DB,DG,GD,GF,FG,EF,FE,AE,EA;

  • Domains {+,-,,}

  • Constraints:

  • L(AC,CD); L(AE,EF); L(DG,GF);

  • Arrow(AC,AE,AB); Arrow(EF,FG,BF); Arrow(CD,DG,DB);

  • Fork(AB,BF,BD);

  • Edge(AB,BA); Edge(AC,CA); Edge(AE,EA);

  • Edge(EF,FE); Edge(BF,FB); Edge(FG,GF);

  • Edge(CD,DC); Edge(BD,DB); Edge(DG,GD);


Csp model3

E

F

A

B

G

C

D

CSP Model

  • Variables: Edges: AB, BA,AC,CA,AE,EA,CD,

  • DC,BD,DB,DG,GD,GF,FG,EF,FE,AE,EA;

  • Domains {+,-,,}

  • Constraints:

  • L(AC,CD); L(AE,EF); L(DG,GF);

  • Arrow(AC,AE,AB); Arrow(EF,FG,BF); Arrow(CD,DG,DB);

  • Fork(AB,BF,BD);

  • Edge(AB,BA); Edge(AC,CA); Edge(AE,EA);

  • Edge(EF,FE); Edge(BF,FB); Edge(FG,GF);

  • Edge(CD,DC); Edge(BD,DB); Edge(DG,GD);

+

+

+


Csp model4

E

F

A

B

G

C

D

CSP Model

+

+

+

One (out of four) possible labelings


Escher waterfall 1961

Escher:Waterfall, 1961


Escher belvedere may 1958

Escher:Belvedere, May 1958


Escher ascending and descending 1960

Escher:Ascending and Descending, 1960


The impossible objects is escher s worlds

The Impossible Objects is Eschers Worlds

Penrose & Penrose Stairs

Penrose Triangle


Impossible objects no labeling

Impossible Objects:No labeling!


Real world applications

Real-World Applications

  • Hardware and Software Configuration

  • Hardware and Software Verification

  • Timetabling

  • Sport Scheduling

  • Floor-Planning

  • Car Sequencing

  • Transporation scheduling


Varieties of csps

Varieties of CSPs


Variety of constraints

Variety of Constraints


Binary csp

Binary CSP

  • Restrict form of CSP with only

  • Unary constraints

  • Binary contraints

  • Constraint graph

  • Note: unary constraints can be satisfied by reducing the domain of the constrained variable (node consistency)


Further reading

Further reading

  • Algorithms for Constraint Satisfaction

  • Problems: A Survey, Vipin Kumar, in AI Magazine

  • 13(1):32-44,1992 (available online).


  • Login