public class RuleSet extends Object
| Constructor | Description |
|---|---|
RuleSet() |
| Modifier and Type | Method | Description |
|---|---|---|
static <K> Expression<K> |
assign(Expression<K> root,
Map<K,Boolean> values) |
|
static <K> Expression<K> |
assign(Expression<K> root,
Map<K,Boolean> values,
ExprOptions<K> options) |
|
static <K> Expression<K> |
simplify(Expression<K> root) |
|
static <K> Expression<K> |
simplify(Expression<K> root,
ExprOptions<K> options) |
|
static <K> Expression<K> |
toCNF(Expression<K> root) |
|
static <K> Expression<K> |
toCNF(Expression<K> root,
ExprOptions<K> options) |
More formal name for product-of-sums
|
static <K> Expression<K> |
toDNF(Expression<K> root) |
|
static <K> Expression<K> |
toDNF(Expression<K> root,
ExprOptions<K> options) |
More formal name for sum-of-products
|
static <K> Expression<K> |
toDNFViaQMC(Expression<K> root,
ExprOptions<K> options) |
This method transforms an expression to DNF, but at a variable cardinality less than 9, switches to the QuineMcCluskey algorithm.
|
static <K> Expression<K> |
toPos(Expression<K> root) |
|
static <K> Expression<K> |
toPos(Expression<K> root,
ExprOptions<K> options) |
|
static <K> Expression<K> |
toSop(Expression<K> root) |
|
static <K> Expression<K> |
toSop(Expression<K> root,
ExprOptions<K> options) |
public static <K> Expression<K> simplify(Expression<K> root)
public static <K> Expression<K> simplify(Expression<K> root, ExprOptions<K> options)
public static <K> Expression<K> toDNFViaQMC(Expression<K> root, ExprOptions<K> options)
The problem with using the switch globally is that QMC can be considerably slower than "naiive" simplification on really simple expressions. For example, (A | B | C | D | E | F | G) takes 15ms using the standard toSop rules, but 120ms using QMC. But QMC is dramatically faster on some larger expressions with the same number of variables -- see https://github.com/bpodgursky/jbool_expressions/issues/29 for an example.
So for now, I'm going to add a new method instead of potentially introducing a performance regression on the old method. If there's a smarter way to "guess" which method would be faster on a given expression, I'm happy to use it, but nothing comes to mind.
public static <K> Expression<K> toSop(Expression<K> root)
public static <K> Expression<K> toSop(Expression<K> root, ExprOptions<K> options)
public static <K> Expression<K> toPos(Expression<K> root)
public static <K> Expression<K> toPos(Expression<K> root, ExprOptions<K> options)
public static <K> Expression<K> assign(Expression<K> root, Map<K,Boolean> values)
public static <K> Expression<K> assign(Expression<K> root, Map<K,Boolean> values, ExprOptions<K> options)
public static <K> Expression<K> toDNF(Expression<K> root, ExprOptions<K> options)
public static <K> Expression<K> toDNF(Expression<K> root)
public static <K> Expression<K> toCNF(Expression<K> root, ExprOptions<K> options)
public static <K> Expression<K> toCNF(Expression<K> root)
Copyright © 2019. All rights reserved.