PageRenderTime 26ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/ComputerAlgebra/Satisfiability/Lisp/ConstraintProblems/plans/Generators.hpp

https://github.com/exp04shy/oklibrary
C++ Header | 141 lines | 0 code | 2 blank | 139 comment | 0 complexity | 904a177097388369fc6f6cad3579a13f MD5 | raw file
  1. // Oliver Kullmann, 8.6.2008 (Swansea)
  2. /* Copyright 2008, 2009 Oliver Kullmann
  3. This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
  4. it and/or modify it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation and included in this library; either version 3 of the
  6. License, or any later version. */
  7. /*!
  8. \file ComputerAlgebra/Satisfiability/Lisp/ConstraintProblems/plans/Generators.hpp
  9. \brief Plans regarding generators for constraint problems
  10. More precisely, for specific problems propagators and instances of the general backtracking algorithms are constructed.
  11. \todo Write tests
  12. \todo Concept of a "propagator"
  13. <ul>
  14. <li> The concept is specified in
  15. ComputerAlgebra/Satisfiability/Lisp/Backtracking/ConstraintSatisfaction.mac
  16. </li>
  17. <li> Compare it with the literature. </li>
  18. <li> Write docus. </li>
  19. <li> Perhaps we create a new sub-module "Propagators.mac" here, and we
  20. leave only the solvers etc. in Backtracking/ConstraintSatisfaction.mac.
  21. </li>
  22. </ul>
  23. \todo "n Queens"
  24. <ul>
  25. <li> See Configurations/NQueens/plans/general.hpp. </li>
  26. <li> Write a generator for boolean CNF (perhaps also in this module). </li>
  27. <li> Write a checker for the solutions. </li>
  28. <li> Especially when all solutions are to be determined, symmetry
  29. considerations seem necessary. </li>
  30. <li> Application of "constraint_backtracking" (from
  31. ComputerAlgebra/Satisfiability/Lisp/Backtracking/ConstraintSatisfaction.mac)
  32. seems rather successful (at least regarding the number of nodes;
  33. the following shows n -> #nodes):
  34. <ol>
  35. <li> 1,2,3 -> 1 </li>
  36. <li> 4 -> 2 </li>
  37. <li> 5 -> 3 </li>
  38. <li> 6 -> 2 </li>
  39. <li> 7 -> 3 </li>
  40. <li> 8 -> 5 </li>
  41. <li> 9 -> 6 </li>
  42. <li> 10 -> 6 </li>
  43. <li> 11 -> 6 </li>
  44. <li> 12 -> 8 </li>
  45. <li> 20 -> 15 </li>
  46. <li> 30 -> 25 </li>
  47. </ol>
  48. (This table should be filled out, and linear regression performed.)
  49. </li>
  50. <li> Could one show that we have actually a polytime procedure ?
  51. (It seems that a solution exists if n <> 2,3). </li>
  52. <li> With a C++ implementation one could investigate larger n. </li>
  53. <li> What is the performance of constraint solvers on this problem? </li>
  54. <li> The above good performance of "constraint_backtracking" is likely
  55. just due to the look-ahead and the ordering heuristics. (One should
  56. have a look at the trees: How much branching is there?). This will
  57. likely break down when finding (or counting) all solutions. </li>
  58. <li> Results of "constraint_backtracking_counting" (from
  59. ComputerAlgebra/Satisfiability/Lisp/Backtracking/ConstraintSatisfaction.mac)
  60. (the number of solutions and the number of nodes):
  61. <ol>
  62. <li> 1 -> [1, 1] </li>
  63. <li> 2,3 -> [0, 1] </li>
  64. <li> 4 -> [2, 3] </li>
  65. <li> 5 -> [10, 16] </li>
  66. <li> 6 -> [4, 7] </li>
  67. <li> 7 -> [40, 48] </li>
  68. <li> 8 -> [92, 143] </li>
  69. <li> 9 -> [352, 632] </li>
  70. </ol>
  71. (This problem has only total solutions, and thus the weakness of the
  72. general approach, that only total assignments can be taken into
  73. account, is irrelevant here.)
  74. </li>
  75. <li> Of course, one could go here for optimal splitting trees. </li>
  76. </ul>
  77. \todo Hitting clause-sets
  78. <ul>
  79. <li> Here we look at the problem of searching for (special) hitting
  80. clause-sets. </li>
  81. <li> The fundamental propagator "hittingcls_propagator(n,L)",
  82. where n is the number of boolean variables in the hitting-cls, and
  83. L is the list of (precise) clause-lengths, is composed of constraints
  84. imposing the clause-lengths and imposing the conflicts. </li>
  85. <li> The constraint variables correspond to the literal occurrences,
  86. and have value-set {-1,0,+1}. </li>
  87. <li> Constraints for exact clause-lengths:
  88. <ol>
  89. <li> Given the list L of constraint-variables and the clause-length m,
  90. the constraint is that exactly m of them have values <> 0. </li>
  91. <li> Let l be the length of L. </li>
  92. <li> Unsatisfiability iff more than m non-zeros exist, or more than
  93. l - m zeros exist. </li>
  94. <li> So we need the number za of zero-assignments, and the number nza
  95. of non-zero assignments. </li>
  96. <li> A total solution has nza = m and za = l - m. </li>
  97. <li> If za = l - m, then value zero is to be removed from the other
  98. variables. </li>
  99. <li> If nza = m, then all other variables have to be set to zero. </li>
  100. <li> That's it, or? </li>
  101. <li> Of course, these are special cases of more general constraints;
  102. but perhaps we first postpone them. </li>
  103. </ol>
  104. </li>
  105. <li> Constraints for the hitting property:
  106. <ol>
  107. <li> Given two clauses "C" and "D", a constraint specifies that we
  108. have at least one conflict. </li>
  109. <li> The clauses are given by their list of constraint-variables
  110. (specifying the literal occurrences). </li>
  111. <li> One needs to compute then the list of common boolean-variables. </li>
  112. <li> The constraint is unsatisfiable iff for all these boolean variables
  113. the domains of their constraint-variables do not contain a clash
  114. anymore. </li>
  115. <li> And the constraint is satisfied iff there exists a conflict. </li>
  116. <li> So we need to compute the value c of conflicts and the value
  117. p of open potential conflicts, the number of boolean variables for which
  118. the constraint-variables have still the possibility to clash (but don't
  119. do yet). </li>
  120. <li> The constraint is satisfied iff c >= 1. </li>
  121. <li> And the constraint is unsatisfiable iff p = 0 (and c = 0). </li>
  122. <li> A domain propagation happens iff p = 1 (and c = 0), in which
  123. case zero needs to be removed from the domains of the two
  124. constraint-variables involved; potentially then we have a conflict
  125. or both have value-set {-1,+1}. </li>
  126. </ol>
  127. </li>
  128. </ul>
  129. */