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 4

2 CSCI5240 Tutorial 4 Assignment 2

3 Question 1 Give simple and valid examples A CSP (𝑍,𝐷,𝐢) consists of:
Set of variables (𝑍) Set of domains (𝐷) Set of constraints (𝐢)

4 Question 2 Variables: 𝑦 1 ,…, 𝑦 𝑛 Domains: 1, …, 𝑛 Constraints:
𝑑𝑖𝑠𝑑𝑖𝑛𝑐𝑑 𝑦 1 ,…, 𝑦 𝑛 , |𝑦 𝑖 βˆ’ 𝑦 𝑗 |β‰ |π‘–βˆ’π‘—| for 𝑖≠𝑗 and 𝑖,π‘—βˆˆ 1, …, 𝑛 1 2 3 4 1 2 3 4

5 There are no queens on a particular row.
Question 2 Variables: 𝑦 1βˆ’π‘› ,…, 𝑦 π‘›βˆ’1 Domains: 𝑖 +1, 𝑖 +3,…,2π‘›βˆ’ 𝑖 βˆ’1 βˆͺ{0} for π‘–βˆˆ[1βˆ’π‘›,…,π‘›βˆ’1] There are no queens on a particular row.

6 Question 2 Variables: 𝑦 1βˆ’π‘› ,…, 𝑦 π‘›βˆ’1 Domains:
𝑖 +1, 𝑖 +3,…,2π‘›βˆ’ 𝑖 βˆ’1 βˆͺ{0} for π‘–βˆˆ[1βˆ’π‘›,…,π‘›βˆ’1] Constraints:

7 Question 2 Variables: 𝑦 1βˆ’π‘› ,…, 𝑦 π‘›βˆ’1 Domains:
𝑖 +1, 𝑖 +3,…,2π‘›βˆ’ 𝑖 βˆ’1 βˆͺ{0} for π‘–βˆˆ[1βˆ’π‘›,…,π‘›βˆ’1] Constraints:

8 Question 2 Variables: 𝑦 1βˆ’π‘› ,…, 𝑦 π‘›βˆ’1 Domains:
𝑖 +1, 𝑖 +3,…,2π‘›βˆ’ 𝑖 βˆ’1 βˆͺ{0} for π‘–βˆˆ[1βˆ’π‘›,…,π‘›βˆ’1] Constraints:

9 Question 2 Variables: 𝑦 1βˆ’π‘› ,…, 𝑦 π‘›βˆ’1 Domains:
𝑖 +1, 𝑖 +3,…,2π‘›βˆ’ 𝑖 βˆ’1 βˆͺ{0} for π‘–βˆˆ[1βˆ’π‘›,…,π‘›βˆ’1] Constraints:

10 Question 2 Variables: 𝑦 1βˆ’π‘› ,…, 𝑦 π‘›βˆ’1 Domains:
𝑖 +1, 𝑖 +3,…,2π‘›βˆ’ 𝑖 βˆ’1 βˆͺ{βˆ’π‘›} for π‘–βˆˆ[1βˆ’π‘›,…,π‘›βˆ’1] Constraints:

11 Question 2 Implement the third constraint using following 3 ways:
Arithmetic constraint Tuple sets DFA (show the DFA graph) Usage: queens -model mod 𝑛 E.g. queens –model 1 5 (arithmetic constraint) Do not hardcode! How to get 𝑛?

12 SizeOptions Accepts an unsigned integer as the last value on the commandline. The value can be retrieved or set by member functions size(). A virtual print function that accepts a standard output stream as argument.

13 SizeOptions Options -> SizeOptions
class SendMoreMoney : public Script { protected: IntVarArray l; const Options& opt; public: enum { MODEL_ONE, MODEL_TWO }; SendMoreMoney(const Options& _opt) : opt(_opt), l(*this,8,0,9) { … switch (opt.model()) { case MODEL_ONE: break; case MODEL_TWO: } // search support // print solution A virtual print function that accepts a standard output stream as argument. Options -> SizeOptions

14 SizeOptions Options -> SizeOptions
int main(int argc, char* argv[]) { // commandline options Options opt(β€œSEND + MORE = MONEY”); opt.model(SendMoreMoney::MODEL_ONE, β€œone”, β€œuse the first model”); opt.model(SendMoreMoney::MODEL_TWO, β€œtwo”, β€œuse the second model”); opt.model(SendMoreMoney::MODEL_ONE);// default model opt.solutions(0);// print all solutions opt.size(4);// default value opt.parse(argc,argv); // run script Script::run<SendMoreMoney, DFS, Options>(opt); return 0; } Options -> SizeOptions

15 Question 3 Extend your program in Assignment 1 Usage:
Generalized to have a grid of 𝑛×𝑛 letters Add extra version 3 for model in 3(a) Add extra version 4 for model in 3(b) Usage: abc_path -model mod 𝑛 E.g. Using model in Asg2 3(a) and 𝑛=4 abc_path –model 3 4 Note that only letter A is initially put on the top left corner cell!

16 Question 4 Hint 1 Hint 2 Hint 3
β€œHidden variable transformation” or β€œHidden transformation” Hint 2 β€œDual graph transformation” Hint 3 β€œOn the Conversion between Non-Binary and Binary Constraint Satisfaction Problems” Pages , AAAI 1998

17 Question 4 Compare the size of the new and old CSPs
Number of variables Domain size of each variables Number of constraints

18 Written part Submit your softcopy (PDF file) to me
Write a few statements comparing the performance Question 1 You need to write down the examples. Question 2 You need to give the DFA graph and write down the comparisons. Question 3 You need to write down the constraints and objective function in Part(a) and the comparisons in Part(b). Question 4 You need to write down the problem transformation techniques and the comparisons.

19 Program Submission Instructions
Programming Part: Follow the format of the commands used to run your program Add proper comments to source files Show sample outputs/your answers enclosed as comments at the end of the source files Attach 2 cpp files and 1 pdf file and send to with the subject: CSC5240 Asg2 [studentID] e.g. CSC5240 Asg Write down your name and student ID in each of your file!

20 Assignment 2 deadline 11 November :59pm

21 END


Download ppt "CSCI5240 Combinatorial Search and Optimization with Constraints"

Similar presentations


Ads by Google