I previously asked in How to bias Z3's (Python) SAT solving towards a criteria, such as 'preferring' to have more negated literals, whether there was a way in Z3 (Python) to 'bias' the SAT search towards a 'criteria'?
In that post, we learnt 'simple biases' such as I would like Z3 to obtain a model, but not any model: if possible, give me a model that has a great amount of negated literals.
This was performed using a new solver (Optimize
instead of Solver
) and soft constraints (add_soft
instead of add
). Concretely, for each literal lit_n
and an optimized solver o_solver
, this was added: o_solver.add_soft(Not(lit_n))
; or, equivalently: o_solver.add_soft(Or(Not(lit1), Not(lit2), ...)
.
However, I would like to express a 'little more complicated biases'. Concretely: if possible: I prefer models with the half of literals to True and the half to False.
Is there any way I can express this and similar 'biases' using the Optimize
tool?