Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI5240 Combinatorial Search and Optimization with Constraints

Similar presentations


Presentation on theme: "CSCI5240 Combinatorial Search and Optimization with Constraints"— Presentation transcript:

1 CSCI5240 Combinatorial Search and Optimization with Constraints
Tutorial Notes 6

2 CSCI5240 Tutorial 6 Assignment 1 Feedback User-defined constraints
Course Project

3 Assignment 1 Feedback Question 1 Prove that C is equivalent to:
Hints: Propositional logic Transform to Conjunctive Normal Form (CNF) Resolution Rule Prove the disequality x != y is equivalent to : Hints: Use result from part (a) Divide into cases

4 Assignment 1 Feedback Question 2 3 solutions Question 3 Payoff is 7

5 Assignment 1 Feedback Write your model with mathematical notation
you have to state what the variables and domains stand for can have some text to explain the notations refer to the model given in Problem 3a) give the objective function

6 ABC Path A letter touches previous letter either horizontally, vertically or diagonally A locates in one of these 8 cells. A locates in one of these 3 cells.

7 Assignment 1 Feedback Different model vs Different implementation
implementing the same model in a different way is not considered as a different model Programming Style proper comments and indentations Always include your name in source file Strictly follow the file naming and argument rules

8 User-defined Constraints
Inherits from the class Propagator Define events on when to propagate Define domain reduction rules Handle How to post and initialize it, how to dispose it, how to copy it during cloning for search, and when to execute it

9 Write a user-defined constraint for “less”.
Main Program Problem Variables: x, y Domains: D(x) = {1,2,3,4,5}, D(y) = {3} Constraint: x < y IntVar x(home, 1, 5); IntVar y(home, 3, 3); rel(home, x, IRT_LE, y); Write a user-defined constraint for “less”.

10 Example: less constraints
Objective Create a user-defined constraint less less(home, x, y)  rel(home, x, IRT_RE, y)

11 Example: less constraints
Domain Reduction Rules: less :

12 Recall From Lecture... ac_revise(c, D)
Page. 69 ac_revise(c, D) if |vars(c)| = 2 then return D Removes values which are not arc consistent with c CSC Finite Constraint Domains

13 used by propagator and brancher
Implementation Class class Less : public Propagator { protected: Int::IntView x0, x1; public: // posting // disposal // copying // cost computation // propagation }; void less(Space& home, IntVar x0, IntVar x1) { // constraint post function } used by propagator and brancher

14 Constructor Initialize data member
Less(Space& home, Int::IntView y0, Int::IntView y1) : Propagator(home), x0(y0), x1(y1) { x0.subscribe(home,*this,Int::PC_INT_DOM); x1.subscribe(home,*this,Int::PC_INT_DOM); } static ExecStatus post(Space& home, Int::IntView x0, Int::IntView x1) { (void) new (home) Less(home,x0,x1); return ES_OK; propagation condition allocates memory from home

15 Propagation Condition
Modification of a variable’s domain triggers a propagation event: 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

16 Propagation Events X x = ? D(x) = { 1 , 2 , 3 , 4 } Int::PC_INT_DOM
Remove 2 from domain ... x = ? X D(x) = { 1 , 2 , 3 , 4 } Int::PC_INT_DOM

17 Propagation Events X X x = ? D(x) = { 1 , 2 , 3 , 4 } Int::PC_INT_DOM
Remove 4 from domain ... x = ? X X D(x) = { 1 , 2 , 3 , 4 } Int::PC_INT_DOM Int::PC_INT_BND

18 Propagation Events X X X x = 3 x = ? D(x) = { 1 , 2 , 3 , 4 }
Remove 1 from domain ... x = ? x = 3 X X X D(x) = { 1 , 2 , 3 , 4 } Int::PC_INT_DOM Int::PC_INT_BND Int::PC_INT_VAL

19 if both are assigned, the propagator are subsumed
Propagate Implement domain reduction rules virtual ExecStatus propagate(Space& home, const ModEventDelta&) { if (x0.le(home,x1.max()) == Int::ME_INT_FAILED) return ES_FAILED; if (x1.gr(home,x0.min()) == Int::ME_INT_FAILED) if (x0.assigned() && x1.assigned()) return home.ES_SUBSUMED(*this); else return ES_NOFIX; } less if both are assigned, the propagator are subsumed the propagator will be scheduled if one of its views have been modified.

20 Recall From Lecture... arc_consistent_3(C,D) W := D
Page. 71 arc_consistent_3(C,D) Q := the set of primitive constraints from C while (Q not empty) do W := D remove a primitive constraint c from Q if ((D := ac_revise(c,D))  W) then Q := Q  {c’| vars(c)  vars(c’)  } endwhile return D CSC Finite Constraint Domains

21 Domain Accessors and Modifiers
in(int) min() max() size() assigned() val() Domain Modifiers nq(home,int) eq(home,int) le(home,int) lq(home,int) gr(home,int) gq(home,int) Use val() only when the variable is bound! For more details, refer to the reference doc...

22 cancel the subscriptions if the propagator are subsumed
Disposal virtual size_t dispose(Space& home) { x0.cancel(home,*this,Int::PC_INT_DOM); x1.cancel(home,*this,Int::PC_INT_DOM); (void) Propagator::dispose(home); return sizeof(*this); } cancel the subscriptions if the propagator are subsumed

23 an approximation of the real cost of the execution
Cost Computation virtual PropCost cost(const Space&, const ModEventDelta&) const { return PropCost::binary(PropCost::LO); } an approximation of the real cost of the execution unary binary ternary

24 Constraint Post Function
void less(Space& home, IntVar x0, IntVar x1) { // constraint post function Int::IntView y0(x0), y1(x1); if (Less::post(home,y0,y1) != ES_OK) home.fail(); } create integer variable views call the static propagator post function

25 Matching less constraint function
Main Program IntVar x(home, 1, 5); IntVar y(home, 3, 3); less(home, x, y); Matching less constraint function

26 Course Project Free Topic in Constraint Programming
Submit Project Proposal to Jimmy Before 7 Nov, 2013 (Thu) One page proposal with project title, your name and student ID and description Submit a Project Report Give a Presentation

27 Course Project: Performance Comparison
Run time CPU time (UNIX) versus elapsed time (WINDOWS) For stochastic algorithm, you have to run the same problem instance for several times and show statistics Scalability Using different sizes of the problem Completeness First solution versus all solutions “Good” solution versus proof of optimality

28 Course Project: Performance Comparison
Other measures (Approach Specific) Tree search algorithms: number of fails/backtracks/nodes Consistency algorithms: number of constraint checks Stochastic algorithms: e.g. number of flips (SAT solvers) Example: Strategy size = 20 size = 50 fails sec(s) 1 2

29 Course Project: Performance Comparison
Important Issues: FAIR comparison across different strategies Same platform/machine across experiments Same search time limit across strategies Perform experiments which are non-trivial and meaningful Example of trivial experiment: 3-Queens problem.

30 Course Project Past 5 Years ( ) full papers at major conferences Principles and Practice of Constraint Programming (CP) International Joint Conference on Artificial Intelligence (IJCAI) National Conference on Artificial Intelligence (AAAI) European Conference on Artificial Intelligence (ECAI) Journal paper is allowed but not suggested.

31 Course Project CP full papers are around 15 pages.
For IJCAI, AAAI, and ECAI, look for full papers (around 5-6 papers, double columns) under the section Constraints, Constraint Satisfaction, Search, and Satisfiability Read the abstract when choosing papers If you do not know something mentioned in the current reading paper, try to read the papers that are cited by the paper you are reading

32 Course Project CP proceedings(2008 – 2013) are available online through CUHK machines / VPN ( You can also search for “Principles and Practice of Constraint Programming” in our CUHK library system. If you are outside CUHK network, please login the library system first

33

34 Course Project IJCAI proceedings (2009,2011,2013) are available online ( )

35

36 Course Project AAAI proceedings are available online 2013 2012 2011
2012 2011 2010 2008

37 Course Project ECAI proceedings are available online 2012 2010 2008
2010 2008

38 Assignment 2 deadline 11 November :59pm

39 END


Download ppt "CSCI5240 Combinatorial Search and Optimization with Constraints"

Similar presentations


Ads by Google