Knowledge Bases
v1.3.9-alpha-54
- groupID
- at.tugraz.ist.ase
- artifactID
- choco-kb-v2
CA-CDR-V2 allows to represent knowledge bases as Constraint Satisfaction Problems. choco-kb-v2 provides classes managing a (Choco) CSP representation of a knowlege base.
Feature model is a type of knowledge represention. For more details related to what CA-CDR-V2 supports for feature models, we refer to Feature models.
Table of Contents
Features
choco-kb-v2 provides the following features:
- An abstract
KB
class managing variables (Variable
), variable domains (Domain
), and constraints (Constraint
) of a knowledge base/feature model. - Two types of variables:
- Integer variables (
IntVariable
) - Boolean variables (
BoolVariable
)
- Integer variables (
- Two interfaces specifying the behaviors of the knowledge base:
IIntVarKB
returns Choco’sIntVar
IBoolVarKB
returns Choco’sBoolVar
Constraint
manages corresponding Choco constraints, as well as their negation.- Two utility builder
IntVarConstraintBuilder
andBoolVarConstraintBuilder
help to build aConstraint
object from a list of Choco constraints. - Already encoded knowledge bases:
FMKB
- an implementation for a CSP representation of a feature model. The input ofFMKB
is aFeatureModel
object. So you can useFMKB
for any feature models you have, i.e., no need to implement a specificKB
class for an individual feature model.FMKB
usesBoolVariable
s, and conformsIBoolVarKB
.FMKB
usesBoolVarConstraintBuilder
to build constraints.PCKB
- an implementation of PC Configuration Knowledge Base.PCKB
usesIntVariable
s, and conformsIIntVarKB
.PCKB
usesIntVarConstraintBuilder
to build constraints.RenaultKB
- an implementation of Renault Configuration Knowledge Base.RenaultKB
usesIntVariable
s, and conformsIIntVarKB
.RenaultKB
usesIntVarConstraintBuilder
to build constraints.CameraKB
- an implementation of Camera Configuration Knowledge Base.CameraKB
usesIntVariable
s, and conformsIIntVarKB
.CameraKB
usesIntVarConstraintBuilder
to build constraints.
Assignment
class represents an assignment of a value to a variable. It could represent a CSP assignment or a SAT clause, e.g.,F1 = true
. Besides, it could represent a preference of a user requirement, e.g.,Modell = limousine
.- Two interfaces
IAssignmentsTranslatable
andILogOpCreatable
specifying the behaviors of a translator from an assignment to Choco constraints.FMAssignmentsTranslator
is a specific translator for feature model’s assignments. - Utility functions for variables (
VariableUtils
) and constraints (ConstraitUtils
)
Negative constraints are used in the algorithms WipeOutR_T, WipeOutR_FM.
How tos
Encoding your own knowledge base
You can implement your knowledge base by inheriting the KB
class.
Examples
Creating a FMKB
object for a feature model readed from a file
The following code shows how to create a FMKB
object for a feature model which is parsed from a file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
File fileFM = new File("src/test/resources/smartwatch.sxfm");
// create a parser for the given file
@Cleanup("dispose")
FeatureModelParser<Feature, AbstractRelationship<Feature>, CTConstraint>
parser = FMParserFactory.getInstance().getParser(fileFM.getName());
// parse the feature model file
FeatureModel<Feature, AbstractRelationship<Feature>, CTConstraint>
fm = parser.parse(fileFM);
// create a FMKB object with the given feature model and requires to generate also the negative constraints
FMKB<Feature, AbstractRelationship<Feature>, CTConstraint>
kb = new FMKB<>(fm, true);
For more examples related to feature models, we refer to [Feature model].
Creating and using an object of FMKB
, PCKB
, RenaultKB
, and CameraKB
Examples
KBStatistics
, FMKBTests, PCKBTest, RenaultKBTest, and CameraKBTest
Implementing a new assignment translator
Example
How to for Utility functions
TBD