Body: <p>I've just started learning CSP and I find it quite exciting. Now I'm facing a nonogram solving problem and I want to solve it using backtracking with CSP.</p>
  <p>The first problem that I face is that I cannot quite figure out what such variables, domains, and constraints could be. My first thought was to make every field(those squares) a variable with such domain: <span class="math-container">$D_i = \{1,0\}$</span>, where 1 means that a certain field has been colored black and 0 white.</p>
  <p>So far I've been mostly learning binary constraints, and I was thinking of using the AC-3 or forward checking algorithm for propagation during the backtracking algorithm.</p>
  <p>As far I know constraints of all arity can be represented as a set of binary constraints, so that would enable me to use the algorithms I mentioned. But that leads me to the problem of defining constraints. If every field was a variable then each line and column would be a constraint, based on how certain lines should be colored(numbers defining line for example 2,3,2).</p>
  <p>But it's all new and quite hard for me to imagine and come up with. I've been reading some articles and papers on that but they were too advanced for me.</p>
  <p>So, does anybody have an idea how can I formulate a nonogram problem as a constraint satisfaction problem?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-03-31T16:35:31.900Z
Comments.Text: You are trying to both learn to formulate the problem and write a solver at the same time. Have you tried formulating the problem in an existing solver (eg Minion)? This way you get practice formulating problems before you work on implementing solvers.
Comments.UserDisplayName: Nathan S.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-01T22:50:17.060Z
Comments.Text: I try to implement a simple solver to understand algorithms and heuristics behind. That gave me better understanding how it all works.
Comments.UserDisplayName: Karol
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-01T22:52:32.623Z
Comments.Text: But after all, I decided that, a variable will be a single row or column and their domains are every possible combination od that linę. Not very powerful but you have to start somewhere.
Comments.UserDisplayName: Karol
Tags: <search><constraint-satisfaction-problems>
Title: How can I formulate a nonogram problem as a constraint satisfaction problem?
UserDisplayName: Karol
ThreadText: # How can I formulate a nonogram problem as a constraint satisfaction problem?
  
  (Asked by: username_0 on 2020-03-27)
  
  I've just started learning CSP and I find it quite exciting. Now I'm facing a nonogram solving problem and I want to solve it using backtracking with CSP.
  
  The first problem that I face is that I cannot quite figure out what such variables, domains, and constraints could be. My first thought was to make every field(those squares) a variable with such domain: $D\_i = \{1,0\}$, where 1 means that a certain field has been colored black and 0 white.
  
  So far I've been mostly learning binary constraints, and I was thinking of using the AC-3 or forward checking algorithm for propagation during the backtracking algorithm.
  
  As far I know constraints of all arity can be represented as a set of binary constraints, so that would enable me to use the algorithms I mentioned. But that leads me to the problem of defining constraints. If every field was a variable then each line and column would be a constraint, based on how certain lines should be colored(numbers defining line for example 2,3,2).
  
  But it's all new and quite hard for me to imagine and come up with. I've been reading some articles and papers on that but they were too advanced for me.
  
  So, does anybody have an idea how can I formulate a nonogram problem as a constraint satisfaction problem?
  
  **Tags:** search, constraint-satisfaction-problems
  
  > **Comments:**
  > **username_1**: You are trying to both learn to formulate the problem and write a solver at the same time. Have you tried formulating the problem in an existing solver (eg Minion)? This way you get practice formulating problems before you work on implementing solvers.  
  > **username_0**: I try to implement a simple solver to understand algorithms and heuristics behind. That gave me better understanding how it all works.  
  > **username_0**: But after all, I decided that, a variable will be a single row or column and their domains are every possible combination od that linę. Not very powerful but you have to start somewhere.  
  
  ---
  
  ## 0 answers
  
  