Utilities#
List of Functions#
Normalize WCNF-like inputs to PySAT WCNF when needed. |
Module Description#
Hermax supports PySAT WCNF formulas natively and can optionally accept OptiLog WCNF formulas when OptiLog is installed [1] [2].
The function hermax.core.utils.normalize_wcnf_formula() provides the
central conversion path used by solver constructors:
PySAT
WCNF/WCNFPlusinputs are passed through unchangedOptiLog
WCNFinputs are converted into PySATWCNFNoneis preserved.
This keeps solver wrappers simple and ensures consistent behavior across all Hermax backends.
Optional OptiLog Compatibility#
Install with OptiLog support using:
pip install "hermax[optilog]"
OptiLog support is optional because OptiLog has its own licensing model. PySAT remains a required dependency of Hermax.
Based on OptiLog’s documented WCNF API (hard_clauses and
soft_clauses), Hermax converts:
each item in
hard_clausesinto a hard clause in PySATWCNFeach pair
(weight, clause)insoft_clausesinto a PySAT soft clause with that weight.
API Details#
- hermax.core.utils.normalize_wcnf_formula(formula)#
Normalize WCNF-like inputs to PySAT WCNF when needed.
Returns
Noneunchanged. Returns PySATWCNF/WCNFPlusunchanged. Converts OptiLogWCNFinto PySATWCNF. Returns any other object unchanged, so existing wrapper-specific best-effort loaders can still handle custom WCNF-like objects.- Parameters:
formula (Any)
- Return type:
Any