If you want to use SAT4J, you need to convert your CNF format.
First you need to convert these text variables to integer.
1 = staff_1 2 = staff_2 3 = doctor_1 4 = physician_2 5 = ward_2 6 = clinic_2 7 = admission_record_2 8 = hospital_2 9 = department_2
Then here are the rules and syntaxes you need to know in order to convert your problem to CNF format.
Syntax: OR = a space AND = a newline NOT = - Rules from De Morgan laws: A <=> B = (A => B) AND (B => A) A => B = NOT(A) OR B NOT(A AND B) = NOT(A) OR NOT(B) NOT(A OR B) = NOT(A) AND NOT(B)
And here is your example problem, formatted, as it should be read by SAT4J.
(see DIMACS to learn more about this format).
c you can put comment here. c Formatted by StackOverFlow. p cnf 9 12 -1 2 0 -2 1 0 -3 4 0 -4 3 0 1 0 3 0 -5 -4 0 -6 -4 0 -7 -4 0 -8 -4 0 -9 -4 0 -2 -4 0
I will let you run SAT4J in this small example,
and he will give you the solution SATISFIABLE xor UNSATISFIABLE .
A little summation of what you need to do to use SAT4J:
* Transform your `text_n` into a number. * Use the rule that I gave you to transform your problem into CNF. * Write the definition of your problem `p cnf nbVariables nbClauses` * Write everything in a FILE and run SAT4J on this file.
I hope this step-by-step example helps few people.
source share