+ All Categories
Home > Documents > CSCI5240 - Combinatorial Search and Optimization with...

CSCI5240 - Combinatorial Search and Optimization with...

Date post: 05-Mar-2018
Category:
Upload: ngonga
View: 218 times
Download: 3 times
Share this document with a friend
31
CSCI5240 - Combinatorial Search and Optimization with Constraints Tutorial 11
Transcript
Page 1: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

CSCI5240 - Combinatorial Search and Optimization with Constraints

Tutorial 11

Page 2: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Today covers

• Asg 10

• Propagator

• Submission Format

Page 3: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Knight’s Tour

move(x, y, n)?x

y

nreturns whether (x, y)

is a legal move on a n*n chessboard

Page 4: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Today covers

• Asg 10

• Propagator

• Submission Format

Page 5: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

A class to process a constraint to a particular level (of consistency). It checks and “updates” a constraint as needed

Posting a constraint is essentially posting relevant propagators

Page 6: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator of less

less(home, x, y);

rel(home, x, IRT_LE, y);

Propagator

Constraint

Page 7: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

Page 8: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

Page 9: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

PostingEvents to trigger propagation

Subscription: when particular events of variable happened, the propagator is called

Use IntView

Page 10: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

View

x

IntVar x

IntVar s(x)

IntArgs t[0] = x

IntView v(x)

variable implementation

different interfaces

Page 11: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Access or Modifier domain through view

Accessor Modifier

x.in(int)

x.min()

x.max()

x.val()

x.size()

x.assigned()

x.eq(home, int)

x.nq(home, int)

x.le(home, int)

x.lq(home, int)

x.gr(home, int)

x.gq(home, int)

Page 12: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

• Int::PC_INT_VAL: a value has been assigned to the variable, that is the variable is bounded

• Int::PC_INT_BND : the minimum (maximum) of the domain of the variable has increased (decreased)

• Int::PC_INT_DOM : the domain of the variable has been modified

Events

Page 13: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Modifying the domain

D(x) = {1, 2, 3, 4}

x.le(home, 4)

D(x) = {1, 2, 3}

Events triggered

D(x) = {2, 3}

D(x) = {2}

x.gr(home, 1)

x.nq(home, 3)Int::PC_INT_VAL

Int::PC_INT_DOMInt::PC_INT_BND

Int::PC_INT_DOMInt::PC_INT_BND

Int::PC_INT_DOMInt::PC_INT_BND

Page 14: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

Page 15: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Disposal

Cancel the subscriptions

Page 16: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

Page 17: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Copying

Page 18: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

not necessary

Page 19: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagator

related to a particular consistency level

Page 20: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

AC_revise

Page 21: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

AC Propagation on less

Domain Reduction

equivalently

Page 22: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Propagation

further propagation needed

propagation failure

x0.le() removes all values in variable x0 that are larger than x1.max()

no more propagations

needed

Page 23: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Used as constraint less

Outside the propagator class Less

now the function less() behaves as a constraint

Page 24: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Write your own propagator• Determine a consistency notion (e.g., AC)

• Link the propagator with events that may make the constraint “inconsistent” (e.g., Int::PC_INT_BND)

• Implement the propagate() function

examine whether a support exists for each domain value

remove unsupported domain values accordingly (x.le(), x.nq(), …)

• Modify those basic necessary components accordingly: constructor, dispose(), copy function, post()

Page 25: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Today covers

• Asg 10

• Propagator

• Submission Format

Page 26: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Submission Format

• Q1

• File: knight.cpp

• Command: ./knight

output all solutions, each in a line

Page 27: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Submission Format• Q2

• File: nqueen.cpp

• Command: ./nqueen -search 1 n (first-fail, mimum-domain-value)

./nqueen -search 2 n (first-fail, median-domain-value)

output the first solution

runtime and numbers of failures are recorded in tables

Page 28: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Submission Format• Q2

• File: nqueen_min.mzn

• Command: mzn-gecode nqueen_min.mzn -D “n=xxx;”

• Output: Output the first solution of the n-Queens problem using the first-fail, minimum-domain-value heuristic

• File: nqueen_med.mzn

• Command: mzn-gecode nqueen_med.mzn -D “n=xxx;”

• Output: Output the first solution of the n-Queens problem using the first-fail, median-domain-value heuristic

Page 29: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Submission Format

• Q2

• File: comparison.txt

contains all tables for comparison

Page 30: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Submission• 2 cpp files, 2 mzn files, and 1 txt file (result comparison)

• Strictly follow the naming rules for filenames, option values and running commands

• Include compiling and linking commands as comments at the bottom of your program file (if applicable)

• Compress all files into one

• Send to [email protected]

• Subject: CSCI5240-Asg9-sid

• Due: Dec 11

Page 31: CSCI5240 - Combinatorial Search and Optimization with ...jlee/courses/csc5240/tutorials/16F/2016CSCI... · Propagator A class to process a constraint to a particular level (of consistency).

Grading• Modelling

Clearness (variables and domains, what do they stand for)

Correctness (size and bounds)

• Programming

Correctness (the constraint specified, running results)

Readability (use comment, delete unused code)

Programming style (good block structure)


Recommended