This repository provides support for transforming feature models (FM) into category theory.
It offers the following functionality:
- Generation of feature's attributes for an FM.
- Generation of sample of configurations from an FM.
- Generation of variant-wise attributes for configurations.
- Transformation from FM and configurations to category theory.
- Linux
- Python 3.9+
- Flama
-
Install Python 3.9+
-
Clone this repository:
git clone https://github.com/CAOSD-group/cat-transf.git -
Create a virtual environment and activate it:
python -m venv env. env/bin/activate -
Install the dependencies:
pip install -r requirements.txt
-
Go to the project folder:
cd cat-transf -
Run the appropriate script according to the required functionality. Normally, you should follow these steps:
-
Step 1: Generate feature attribute: Given an FM, it generates an attribute for each feature in the model with random values in a domain.
- Execution:
python gen_feat_attr.py fm attribute_name -r ranges -e elements (-l) - Inputs:
fmspecifies the file path of the FM in UVL format (.uvl).attribute_nameis the name of the new attribute.- The domain can be specified with one or both of the following parameters:
rangesspecifies the domain for the values as a list of ranges with the following format:'[[1, 10], [90, 100]]'generates values from 1 to 10 and from 90 to 100.elementsspecifies the domain for the values as a list of elements with the following format:'[True, False]'for a Boolean attribute;'["Low", "Medium", "High"]'for a string enumeration;'[1, 10.0, 100]'for specific integer or real values.
-lis an optional parameters indicating that the attribute will be only generated for the leaf features in the model.
- Outputs:
- A FM file in UVL format with the new attribute created in each feature. The output file is named as the original one ending with
_X.uvlwhereXis the new attribute name.
- A FM file in UVL format with the new attribute created in each feature. The output file is named as the original one ending with
- Example:
python gen_feat_attr.py Pizzas.uvl Price -r '[[1, 10]]' -l - Note: If there is a feature with an already existing attribute with the same name, the attribute will not be created for that feature.
- Execution:
-
Step 2: Generate configurations: Given an FM, it generates a sample of configurations.
- Execution:
python gen_configs.py fm -s size - Inputs:
fmspecifies the file path of the FM in UVL format (.uvl).sizeis the number of configuration to be generated.
- Outputs:
- A csv file with the configurations. The output file is named as the original FM with
_S.csvwhereSis the number of configurations.
- A csv file with the configurations. The output file is named as the original FM with
- Example:
python gen_configs.py Pizzas.uvl -s 10
- Execution:
-
Step 3: Generate variant-wise attribute: Given the configurations of an FM in a csv file, it generates an attribute for each configuration with random values in a domain.
- Execution:
python gen_config_attr.py csv attribute_name -r ranges -e elements (-l) - Inputs:
csvspecifies the file path of the csv with the configurations.attribute_nameis the name of the new attribute.- The domain can be specified with one or both of the following parameters:
rangesspecifies the domain for the values as a list of ranges with the following format:'[[1, 10], [90, 100]]'generates values from 1 to 10 and from 90 to 100.elementsspecifies the domain for the values as a list of elements with the following format:'[True, False]'for a Boolean attribute;'["Low", "Medium", "High"]'for a string enumeration;'[1, 10.0, 100]'for specific integer or real values.
- Outputs:
- A csv file with the configurations and a new attribute created for each configuration. The output file is named as the original one ending with
_X.csvwhereXis the new attribute name.
- A csv file with the configurations and a new attribute created for each configuration. The output file is named as the original one ending with
- Example:
python gen_config_attr.py Pizzas.csv Vegan -e '[True, False]'
- Execution:
-
Step 4: Transform to category theory: Given an FM and a sample of configurations, it generates the category theory model (.cql).
- Execution:
python fm2cql.py fm csv - Inputs:
fmspecifies the file path of the FM in UVL format (.uvl).csvspecifies the file path of the csv with the configurations.
- Outputs:
- A cql file with the category theory model. The output file is named as the original FM with with
.cqlextension.
- A cql file with the category theory model. The output file is named as the original FM with with
- Example:
python fm2cql.py Pizzas.uvl Pizzas.csv
- Execution: