Download presentation
Presentation is loading. Please wait.
Published byVictor Chase Modified over 6 years ago
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.