Class: Ravensat::DimacsDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/ravensat/dimacs/dimacs_decoder.rb

Instance Method Summary collapse

Instance Method Details

#decode(model, cnf) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/ravensat/dimacs/dimacs_decoder.rb', line 3

def decode(model, cnf)
  prop_vars = cnf.vars
  case model.first
  when "SAT"
    model.last.split.each_with_index do |e,i|
      break if e == '0'
      var = prop_vars[i]
      var.value = !(e[0] == '-')
    end
    true
  when "UNSAT"
    false
  end
end