PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Satisfiability/Interfaces/InputOutput/plans/Dimacs.hpp

https://github.com/exp04shy/oklibrary
C++ Header | 160 lines | 0 code | 2 blank | 158 comment | 0 complexity | 8ae4fde484e6f3f5c33073ca16fd079e MD5 | raw file
  1. // Oliver Kullmann, 10.11.2007 (Swansea)
  2. /* Copyright 2007, 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 Interfaces/InputOutput/plans/Dimacs.hpp
  9. \brief Plans for the sub-module on input/output in DIMACS format
  10. \todo Complete the doxygen-documentation.
  11. \todo Write docus.
  12. \todo Write demos.
  13. \todo Connections to other modules
  14. <ul>
  15. <li> See "Input and output" in
  16. ComputerAlgebra/Satisfiability/Lisp/ClauseSets/plans/general.hpp. </li>
  17. </ul>
  18. \todo What happens if the integers from the file are too big?
  19. <ul>
  20. <li> We cannot use the stream extractors, since they yield undefined
  21. behaviour, so it seems necessary to write special
  22. tools to read and check integers from streams. Or? </li>
  23. <li> (See my e-mail to Boost from 15/10/2005.) Perhaps the best
  24. solution here is to wrap int_type into a type with safe reading from
  25. istreams (setting the stream state accordingly). Or, perhaps better from
  26. a general design point of view, we should use a BigInteger class here for
  27. reading. </li>
  28. <li> Apparently all compilers actually catch the errors? </li>
  29. </ul>
  30. \todo It must also be tested, whether the integers can be safely negated.
  31. \todo Consider the code-comments regarding checking.
  32. \todo Improve class InputOutput::StandardDIMACSInput
  33. <ul>
  34. <li> The constructor of InputOutput::StandardDIMACSInput should take the
  35. following optional arguments:
  36. <ol>
  37. <li> comments require at least one space after "c" (default: no) </li>
  38. <li> in the parameter line after "p" either exactly one or at least one
  39. space is required (default: exactly one) </li>
  40. <li> non-space characters on the parameter line after the second
  41. parameter lead to an error (default: yes). </li>
  42. <li> Perhaps this is all packaged into a syntax-strategy-object. </li>
  43. <li> Compare below "Error handling". </li>
  44. </ol>
  45. </li>
  46. </ul>
  47. \todo Use Messages for messages.
  48. \todo Exceptions
  49. <ul>
  50. <li> The exception safety level must be specified. </li>
  51. <li> For throwing the exceptions a more structured approach should be used
  52. (so that the exceptions thrown become better testable). </li>
  53. </ul>
  54. \todo Improving class InputOutput::LiteralReadingExtended
  55. <ul>
  56. <li> Making a distinction between the two types of public member functions
  57. in InputOutput::LiteralReadingExtended:
  58. <ol>
  59. <li> One could make the policy an "inheritance policy", where "read"
  60. is a protected member function inherited by the Dimacs-parser, while
  61. the three accessor-functions are public. </li>
  62. </ol>
  63. </li>
  64. </ul>
  65. \todo Error handling
  66. <ul>
  67. <li> What about writing a generic DIMACS parser, starting with
  68. ::OKlib::DPv::ParserLiteral and ::OKlib::DPv::DimacsParser
  69. (located in Input_output.hpp in module DPv) ? </li>
  70. <li> InputOutput::StandardDIMACSInput does not perform many syntax checks;
  71. one should precisely define what it allows and what not. </li>
  72. </ul>
  73. \todo ListTransfer
  74. <ul>
  75. <li> Is this submodule really the right place? </li>
  76. <li> Once namespaces are updated, one should have a look whether
  77. the name "ListTransfer" is appropriate. </li>
  78. </ul>
  79. \todo Write extended Dimacs-parser for clause-sets with non-boolean
  80. variables
  81. <ul>
  82. <li> The parameter line now is of the form
  83. \verbatim
  84. p gcnf n c k
  85. \endverbatim
  86. where k specifies the set of possible values {0, ..., k-1}. </li>
  87. <li> Literals are of the form
  88. \verbatim
  89. n,v
  90. \endverbatim
  91. where n as usual is the variable (number), while v in {0, ..., k-1}. </li>
  92. <li> If k=2, then also "+n", "-n" and "n" are literals (so that ordinary
  93. Dimacs inputs are accepted). </li>
  94. </ul>
  95. \todo Write Dimacs-parser for weighted (partial) MaxSAT formats
  96. <ul>
  97. <li> The basic weighted Dimacs format for weighted partial
  98. MaxSAT problems is simply
  99. \verbatim
  100. c comment line
  101. p wcnf num_vars num_clauses maximum_weight
  102. weight l1 l2 l3 ...
  103. weight l4 l5 l6 ...
  104. \endverbatim
  105. where the standard Dimacs p-line has been extended to use the
  106. "wcnf" type and the maximum_weight parameter is the maximum weight
  107. that one will use as a clause-weight. Hard clauses have the maximum
  108. weight and soft clauses have a weight less than top. </li>
  109. <li> If one fails to specify a maximum_weight then you have a
  110. weighted MaxSAT problem. </li>
  111. <li> If one has the maximum weight but uses only the maximum weight
  112. and 1 for hard and soft clauses, then you have a partial MaxSAT
  113. problem. </li>
  114. <li> See http://www.maxsat.udl.cat/08/index.php?disp=requirements for
  115. more details. </li>
  116. <li> We need notions of how to handle this, and consideration of the
  117. way to store weights in datastructures. </li>
  118. </ul>
  119. \todo Write higher level modules
  120. <ul>
  121. <li> Like ReadClauseCollection<DimacsParser, ClauseCollection> and
  122. WriteClauseCollection<ClauseCollection, DimacsWriter>
  123. (likely this should go into a separate file). </li>
  124. </li>
  125. */