Knowledge Bases
v1.0
- groupID
- at.tugraz.ist.ase.hiconfit
- artifactID
- kb
hiconfit-core allows to represent knowledge bases as Constraint Satisfaction Problems. kb provides classes managing a (Choco) CSP representation of a knowledge base. Besides, it also offers two core classes representing user requirements and solutions of a configurator.
Feature model is a type of knowledge representation. For more details related to what hiconfit-core supports for feature models, we refer to Feature models.
TBD
Table of Contents
What kb provides
kb provides the following features:
- An abstract
KBclass 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:
IIntVarKBreturns Choco’sIntVarIBoolVarKBreturns Choco’sBoolVar
Constraintmanages corresponding Choco constraints, as well as their negation.- Two utility builders
IntVarConstraintBuilderandBoolVarConstraintBuilderhelp to build aConstraintobject from a list of Choco constraints. - Already encoded knowledge bases:
FMKB- an implementation for a CSP representation of a feature model. The input ofFMKBis aFeatureModelobject. So you can useFMKBfor any feature models you have, i.e., no need to implement a specificKBclass for an individual feature model.FMKBusesBoolVariables, and conformsIBoolVarKB.FMKBusesBoolVarConstraintBuilderto build constraints.PCKB- an implementation of PC Configuration Knowledge Base.PCKBusesIntVariables, and conformsIIntVarKB.PCKBusesIntVarConstraintBuilderto build constraints.RenaultKB- an implementation of Renault Configuration Knowledge Base.RenaultKBusesIntVariables, and conformsIIntVarKB.RenaultKBusesIntVarConstraintBuilderto build constraints.CameraKB- an implementation of Camera Configuration Knowledge Base.CameraKBusesIntVariables, and conformsIIntVarKB.CameraKBusesIntVarConstraintBuilderto build constraints.
Assignmentclass 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
IAssignmentsTranslatableandILogOpCreatablespecifying the behaviors of a translator from an assignment to Choco constraints.FMAssignmentsTranslatoris 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 read 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 an 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, ‘FMKBTest’s, ‘PCKBTest’, ‘RenaultKBTest’, and ‘CameraKBTest’
Implementing a new assignment translator
Example
How to for Utility functions
TBD