- java.lang.Object
-
- org.logicng.pseudobooleans.PBEncoder
-
public class PBEncoder extends Object
An encoder for pseudo-Boolean constraints.- Since:
- 1.0
- Version:
- 2.3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected PBAdderNetworksadderNetworksprotected CCEncoderccEncoderprotected PBConfigconfigprotected FormulaFactoryfprotected PBSWCswc
-
Constructor Summary
Constructors Constructor Description PBEncoder(FormulaFactory f)Constructs a new pseudo-Boolean encoder which uses the configuration of the formula factory.PBEncoder(FormulaFactory f, PBConfig pbConfig)Constructs a new pseudo-Boolean encoder with a given configuration.PBEncoder(FormulaFactory f, PBConfig pbConfig, CCConfig ccConfig)Constructs a new pseudo-Boolean encoder with given configurations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PBConfigconfig()Returns the current configuration of this encoder.protected List<Formula>encode(Literal[] lits, int[] coeffs, int rhs)Builds a pseudo Boolean constraint of the formc_1 * lit_1 + c_2 * lit_2 + ... + c_n * lit_n >= k.List<Formula>encode(PBConstraint constraint)Encodes a pseudo-Boolean constraint and returns its CNF encoding.
-
-
-
Field Detail
-
f
protected final FormulaFactory f
-
config
protected final PBConfig config
-
ccEncoder
protected final CCEncoder ccEncoder
-
swc
protected PBSWC swc
-
adderNetworks
protected PBAdderNetworks adderNetworks
-
-
Constructor Detail
-
PBEncoder
public PBEncoder(FormulaFactory f, PBConfig pbConfig, CCConfig ccConfig)
Constructs a new pseudo-Boolean encoder with given configurations.- Parameters:
f- the formula factorypbConfig- the pseudo-Boolean encoder configurationccConfig- the cardinality constraints encoder configuration
-
PBEncoder
public PBEncoder(FormulaFactory f, PBConfig pbConfig)
Constructs a new pseudo-Boolean encoder with a given configuration.- Parameters:
f- the formula factorypbConfig- the pseudo-Boolean encoder configuration
-
PBEncoder
public PBEncoder(FormulaFactory f)
Constructs a new pseudo-Boolean encoder which uses the configuration of the formula factory.- Parameters:
f- the formula factory
-
-
Method Detail
-
encode
public List<Formula> encode(PBConstraint constraint)
Encodes a pseudo-Boolean constraint and returns its CNF encoding.- Parameters:
constraint- the pseudo-Boolean constraint- Returns:
- the CNF encoding of the pseudo-Boolean constraint
-
config
public PBConfig config()
Returns the current configuration of this encoder. If the encoder was constructed with a given configuration, this configuration will always be used. Otherwise, the current configuration from the formula factory is used.- Returns:
- the current configuration of
-
encode
protected List<Formula> encode(Literal[] lits, int[] coeffs, int rhs)
Builds a pseudo Boolean constraint of the formc_1 * lit_1 + c_2 * lit_2 + ... + c_n * lit_n >= k.- Parameters:
lits- the literalslit_1 ... lit_ncoeffs- the coefficientsc_1 ... c_nrhs- the right-hand sidekof the constraint- Returns:
- the CNF encoding of the pseudo Boolean constraint
- Throws:
IllegalArgumentException- if the right-hand side of the cardinality constraint is negative or larger than the number of literals
-
-