Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:dydaktyka:csp:lab2 [2019/03/12 18:43]
msl [Channeling]
en:dydaktyka:csp:lab2 [2020/03/13 13:48] (current)
msl
Line 3: Line 3:
 ===== Symmetry Breaking =====  ===== Symmetry Breaking ===== 
  
-The problem is said to contain symmetry if there exist classes of equivalent solutions --- solutions, which are called symmetrical because there exist a simple mechanical procedure to obtain one from another. Graph Coloring Problem has a very obvious symmetry --- in every solution we can freely swap colors, e.g. every red node repaint as blue, and every blue node repaint as red. Solutions of this kind aren't bad, just redundant, leading to much bigger search space. Symmetry breaking prunes the search space by removing symmetries from the problem.+The problem is said to contain symmetry if there exist classes of equivalent solutions --- solutions, which are called symmetrical because there exists ​a simple mechanical procedure to obtain one from another. Graph Coloring Problem has a very obvious symmetry --- in every solution we can freely swap colors, e.g. every red node repaint as blue, and every blue node repaint as red. Solutions of this kind aren't bad, just redundant, leading to much bigger search space. Symmetry breaking prunes the search space by removing symmetries from the problem
 + 
 +All files required to solve the assignments are available via [[https://​gitlab.com/​agh-krr/​2019-2020/​labs/​|the repository]],​ so clone it first.
  
 ==== Graph Coloring ==== ==== Graph Coloring ====
   * Problem: Same as [[http://​ai.ia.agh.edu.pl/​wiki/​en:​dydaktyka:​csp:​lab1#​graph_coloring|before]]   * Problem: Same as [[http://​ai.ia.agh.edu.pl/​wiki/​en:​dydaktyka:​csp:​lab1#​graph_coloring|before]]
   * Assignment:   * Assignment:
-    ​- Download and extract {{:​en:​dydaktyka:​csp:​csp_coloring.zip|archive}}. +    - Look at and comprehend ''​lab3/​graph_coloring/​graph_coloring.mzn''​ model. ​    
-    ​- Look at and comprehend ''​csp_coloring.mzn''​ model. ​    +    - Try to solve the ''​basic_data.dzn''​ instance. 
-    - Try to solve the ''​csp_coloring_data.dzn''​ instance. +      * You can use the model created during previous classes 
-      * You can use model created during previous classes +      * There is a chance, that problem would too difficult to be solved in a reasonable time. 
-      * There is a chance, that problem would to difficult to be solved in a reasonable time. +    - File ''​data_with_clique.dzn''​ includes info about the largest clique in the graph
-    - File ''​csp_coloring_data2.dzn''​ includes info about the largest clique in the graph+
       * ''​minColorsNumber''​ - size of the largest clique       * ''​minColorsNumber''​ - size of the largest clique
       * ''​maxClique''​ - indexes of the vertices forming the largest clique       * ''​maxClique''​ - indexes of the vertices forming the largest clique
Line 23: Line 24:
   * Assignment:   * Assignment:
     - Find a symmetry in the problem.     - Find a symmetry in the problem.
-    ​- Download and extract {{:​en:​dydaktyka:​csp:​csp_n_knapsack.zip|the archive}} +    - Look at and comprehend ''​lab3/​multi_knapsack/​multi_knapsack.mzn''​.
-    ​- Look at and comprehend ''​csp_n_knapsack.mzn''​.+
       * Note :!:: this model is not an example of good constraint model; it's just used to show a common technique to break symmetries       * Note :!:: this model is not an example of good constraint model; it's just used to show a common technique to break symmetries
       * Note use of the ''​at_most''​ global constraint.       * Note use of the ''​at_most''​ global constraint.
-      * There is a defined predicate named ''​knapsack''​ -> it's the first example of user defined predicate+      * There is a defined predicate named ''​knapsack''​ -> it's the first example of user-defined predicate
     - Run model with the associated data file:     - Run model with the associated data file:
-      * The problem may be to hard for the solver +      * The problem may be too hard for the solver 
-    - Break symmetry using [[http://​www.minizinc.org/​doc-lib/doc-globals-lexicographic.html#Ipredicate-lex_less-po-array-bo-int-bc-of-var-set-of-int-cl-x-cm-array-bo-int-bc-of-var-set-of-int-cl-y-pc|''​lex_less''​ global constraint]]. +    - Break symmetry using [[https://​www.minizinc.org/​doc-2.4.2/en/lib-globals.html#​lexicographic-constraints|''​lex_less_eq''​ global constraint]]. 
-    - Run new model with the same data file+    - Run the new model with the same data file
  
 ===== Redundant Constraints ===== ===== Redundant Constraints =====
  
-There is a good chance the problem can be defined in more than one way. Also you may find a set of constraints that is sufficient to define the problem. That's cool, however there can exist so called "​redundant constraints";​ redundant because they do not have impact on the number or quality of the solutions. The only reason to include them into the model is that they may contain additional info about the structure of the problem, therefore giving solver an opportunity to prune the search space (most of the solver prune the search space by propagating constraints,​ redundant constraint may boost this process).+There is a good chance the problem can be defined in more than one way. Also you may find a set of constraints that is sufficient to define the problem. That's cool, however there can exist so called "​redundant constraints";​ redundant because they do not have an impact on the number or quality of the solutions. The only reason to include them in the model is that they may contain additional info about the structure of the problem, therefore giving solver an opportunity to prune the search space (most of the solver prune the search space by propagating constraints, ​redundant constraint may boost this process).
 ==== Magic Sequence ===== ==== Magic Sequence =====
   * Definition: Same as [[http://​ai.ia.agh.edu.pl/​wiki/​en:​dydaktyka:​csp:​lab1#​magic_sequence|before]]   * Definition: Same as [[http://​ai.ia.agh.edu.pl/​wiki/​en:​dydaktyka:​csp:​lab1#​magic_sequence|before]]
   * Assignment:   * Assignment:
-    - Download, extract, ​comprehend ​{{:​en:​dydaktyka:​csp:​csp_magic_series.zip|the model}}+    - Look at and comprehend ​''​lab3/​magic_series/​magic_series.mzn''​
     - Add redundant constraints,​ hints:     - Add redundant constraints,​ hints:
       * what should be equal the sum of the magic sequence?       * what should be equal the sum of the magic sequence?
Line 52: Line 52:
   * Problem: [[http://​ai.ia.agh.edu.pl/​wiki/​en:​dydaktyka:​csp:​lab1#​n-queens|N-Queens]] again   * Problem: [[http://​ai.ia.agh.edu.pl/​wiki/​en:​dydaktyka:​csp:​lab1#​n-queens|N-Queens]] again
   * Assignment:   * Assignment:
-    - Download, extract ​and comprehend ​{{:​en:​dydaktyka:​csp:​csp_n_queens.zip|the model}} (or use your own)+    - Look at and comprehend ​''​lab3/​n_queens/​n_queens.mzn''​
     - Add another model of the problem     - Add another model of the problem
       * try to use the boolean array of variables ''​array[1..n,​ 1..n] of var bool: qb;''​ (queen boolean)       * try to use the boolean array of variables ''​array[1..n,​ 1..n] of var bool: qb;''​ (queen boolean)
Line 82: Line 82:
   * Problem: There are two classes of objects (men and women, for example) that have to be matched according to their preferences. We say that a matching (marriage) is unstable if both spouses would prefer to be with somebody else. You can read more about this problem on [[https://​en.wikipedia.org/​wiki/​Stable_marriage_problem|wikipedia]].   * Problem: There are two classes of objects (men and women, for example) that have to be matched according to their preferences. We say that a matching (marriage) is unstable if both spouses would prefer to be with somebody else. You can read more about this problem on [[https://​en.wikipedia.org/​wiki/​Stable_marriage_problem|wikipedia]].
   * Assignment:   * Assignment:
-    - Download, extract, ​comprehend ​{{ :​en:​dydaktyka:​csp:​stable_marriage.zip |the model}}+    - Look at and comprehend ​''​lab3/​stable-marriage/​stable-marriage.mzn''​
     - Add missing variables, constraints     - Add missing variables, constraints
     - Give a high-five to your teacher :)     - Give a high-five to your teacher :)
  
  
en/dydaktyka/csp/lab2.1552412620.txt.gz · Last modified: 2019/06/27 16:00 (external edit)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0