# Guide
- [Installation](#installation)
- [Modules](#modules)
- [model](#model)
- [prototype](#prototype)
- [system_models](#system_models)
- [Author](#author)
## Installation
To install the package, run the following command:
```bash
pip install momo-morphological-modeling
```
## Modules
The package contains the following modules:
- `model`: Contains the main classes for the morphological modeling `MoMoModel`.
- `prototype`: Contains the classes for the prototype of morphological modeling `Prototype`.
- `system_models`: Contains the classes for the system models `SystemModel` and `MultySystemModel`.
---
### model
The `model` module contains the main classes for the morphological modeling. The main class is `MoMoModel` which is used to create a morphological model and to perform the morphological analysis.
### MoMoModel
The `MoMoModel` class represents a **Multi-Object Multi-System Model** designed to manage multiple system models and a prototype for similarity calculations. It integrates the `Prototype` and `MultiSystemModel` classes, enabling users to perform operations on system models and calculate similarity measures between them.
#### Key Features
- Supports initialization with multiple system models and an optional prototype.
- Automatically generates a prototype based on the system models if not provided.
- Allows for similarity measure calculations between the prototype and combinations of system models.
- Built-in integration with `Prototype` and `MultiSystemModel`.
---
##### Initialization Parameters
| Parameter | Type | Description |
|-----------------|--------------------------------|----------------------------------------------------------------------------------------------|
| `system_models` | `MultiSystemModel`, `list`, `tuple`, `set` | The system models used in the `MoMoModel`. |
| `prototype` | `Prototype`, `None` (optional) | The prototype object to compare with system models. Defaults to `None`. |
---
##### Methods Overview
| Method | Description |
|---------------------------------------|----------------------------------------------------------------------------------------------|
| `get_prototype()` | Returns the current prototype. |
| `set_prototype(prototype)` | Sets a new prototype. |
| `prototype_` (property) | Gets or sets the prototype. |
| `get_system_models()` | Returns the current system models. |
| `set_system_models(system_models)` | Sets new system models and updates the prototype accordingly. |
| `system_models_` (property) | Gets or sets the system models. |
| `get_similarity_measures()` | Calculates similarity measures between the prototype and all combinations of system models. |
| `__str__()` | Returns a string representation of the `MoMoModel` object, including the prototype and system models. |
---
##### Example Usage
```python
from momo.model import MoMoModel
from momo.system_models.system_models import MultiSystemModel, SystemModel
# Create individual system models
dbms = SystemModel(
name="DBMS",
data=[
[1, 0, 1], # Security
[1, 1, 0], # Performance
[0, 1, 1], # Speed
],
features=["Security", "Performance", "Speed"],
alternatives=["MySQL", "PostgreSQL", "MongoDB"]
)
connector = SystemModel(
name="Connector",
data=[
[1, 0], # Flexibility
[1, 1], # Cost
],
features=["Flexibility", "Cost"],
alternatives=["Copper", "Aluminum"]
)
# Initialize a MultiSystemModel
multi_system = MultiSystemModel([dbms, connector])
# Initialize a MoMoModel
momo_model = MoMoModel(system_models=multi_system)
# Access the prototype
print("Prototype:")
print(momo_model.prototype)
# Calculate similarity measures
similarity_measures = momo_model.get_similarity_measures()
print("\nSimilarity Measures:")
for combination, measure in similarity_measures.items():
print(f"{combination}: {measure}")
# String representation
print("\nMoMoModel:")
print(momo_model)
```
**Output:**
```
Prototype:
DBMS Security 0
Performance 0
Speed 0
Connector Flexibility 0
Cost 0
dtype: int64
Similarity Measures:
('MySQL', 'Copper'): 0.5
('MySQL', 'Aluminum'): 1.3333333333333333
('PostgreSQL', 'Copper'): 0.5
('PostgreSQL', 'Aluminum'): 1.3333333333333333
('MongoDB', 'Copper'): 0.5
('MongoDB', 'Aluminum'): 1.3333333333333333
MoMoModel:
Prototype:
DBMS Security 0
Performance 0
Speed 0
Connector Flexibility 0
Cost 0
dtype: int64
System Models:
(MySQL, Copper) (MySQL, Aluminum) (PostgreSQL, Copper) (PostgreSQL, Aluminum) (MongoDB, Copper) (MongoDB, Aluminum)
DBMS Security 1 1 0 0 1 1
Performance 1 1 1 1 0 0
Speed 0 0 1 1 1 1
Connector Flexibility 1 0 1 0 1 0
Cost 1 1 1 1 1 1
```
---
### prototype
The `prototype` module contains the `Prototype` class, which is a subclass of `pandas.Series`. It is designed to store and manipulate hierarchical data using features and alternatives.
### Prototype
The `Prototype` class extends the functionality of `pandas.Series` by allowing hierarchical data representation with support for setting values via dictionaries or lists. **And its represnt the prototype of the morphological model.**
##### Key Features
- Directly inherits all functionality from `pandas.Series`.
- Supports setting values using hierarchical dictionaries or lists.
- Maintains compatibility with standard pandas operations.
---
##### Initialization Parameters
| Parameter | Type | Description |
|----------------|----------------------------|-----------------------------------------------------------------------------|
| `data` | `array-like`, `Iterable`, `dict`, `scalar` | The data to be stored in the `Prototype`. |
| `index` | `array-like` or `Index` | The index labels for the data. |
---
##### Methods Overview
| Method | Description |
|-----------------------------------|----------------------------------------------------------------------------------------------|
| `set_marks(marks_list)` | Sets values in the `Prototype` using a dictionary or list. |
| `_set_marks_dict(marks_dict)` | Sets values in the `Prototype` from a dictionary of hierarchical data. |
| `_set_marks_list(marks_list)` | Sets values in the `Prototype` from a list. |
---
##### Example Usage
```python
from momo.prototype import Prototype
# Initialize a prototype with hierarchical data
data = [0, 0, 0, 1]
index = [("System1", "Feature1"), ("System1", "Feature2"), ("System2", "Feature3"), ("System2", "Feature4")]
prototype = Prototype(data=data, index=index)
print("Initial Prototype:")
print(prototype)
# Set marks using a dictionary
prototype.set_marks({
"System1": {"Feature1": 1, "Feature2": 2},
"System2": {"Feature3": 3, "Feature4": 4}
})
print("\nPrototype after setting marks (dict):")
print(prototype)
# Set marks using a list
prototype.set_marks([10, 20, 30, 40])
print("\nPrototype after setting marks (list):")
print(prototype)
```
**Output:**
```
Initial Prototype:
(System1, Feature1) 0
(System1, Feature2) 0
(System2, Feature3) 0
(System2, Feature4) 1
dtype: int64
Prototype after setting marks (dict):
(System1, Feature1) 1
(System1, Feature2) 2
(System2, Feature3) 3
(System2, Feature4) 4
dtype: int64
Prototype after setting marks (list):
(System1, Feature1) 10
(System1, Feature2) 20
(System2, Feature3) 30
(System2, Feature4) 40
dtype: int64
```
---
### system_models
The `system_models` module contains the classes for the system models. The main classes are `SystemModel` and `MultySystemModel` which are used to create the system models.
#### `SystemModel`
The `SystemModel` class is a core component designed to represent and manipulate system models. It allows you to manage a structured representation of features and alternatives, supporting data storage, validation, and various manipulations.
##### Key Features
- Manage relationships between features and alternatives.
- Add, remove, and retrieve features and alternatives.
- Validate the consistency of data, features, and alternatives.
- Built-in support for `pandas.DataFrame` for structured data handling.
---
##### Initialization Parameters
| Parameter | Type | Description |
|----------------|--------------|---------------------------------------------------------------------------------------------------|
| `name` | `str` | The name of the system model. |
| `data` | `list`, `None` | The data matrix (rows: features, columns: alternatives) to initialize the system model. |
| `features` | `list`, `None` | The list of feature names. |
| `alternatives` | `list`, `None` | The list of alternative names.|
---
##### Methods Overview
| Method | Description |
|----------------------------|----------------------------------------------------------------------------------------------|
| `add_feature(feature_name, alternatives)` | Adds a new feature to the system model with its alternatives. |
| `add_alternative(alternative_name, features)` | Adds a new alternative to the system model with its features. |
| `remove_feature(feature_name)` | Removes a feature from the system model. |
| `remove_alternative(alternative_name)` | Removes an alternative from the system model. |
| `get_features()` | Returns a tuple of all features in the system model. |
| `get_alternatives()` | Returns a tuple of all alternatives in the system model. |
| `features` (property) | Returns the list of feature names as a pandas DataFrame index. |
| `alternatives` (property) | Returns the list of alternative names as a pandas DataFrame column index. |
| `loc` (property) | Provides access to pandas DataFrame `.loc` for advanced slicing and indexing. |
| `__getitem__(key)` | Retrieves a value from the underlying data using a key (row/column-based indexing). |
| `__setitem__(key, value)` | Sets a value in the underlying data using a key. |
| `__str__()` | Returns a string representation of the system model, including its name and the data matrix. |
---
##### Example Usage
```python
from momo.system_models.system_models import SystemModel
# Initialize a system model
model = SystemModel(
name="DBMS",
data=[
[1, 0, 1], # Security
[1, 1, 0], # Performance
[0, 1, 1], # Speed
],
features=["Security", "Performance", "Speed"],
alternatives=["MySQL", "PostgreSQL", "MongoDB"]
)
# Add a new feature
model.add_feature("Reliability", [1, 1, 1])
# Add a new alternative
model.add_alternative("SQLite", {"Security": 1, "Performance": 0, "Speed": 1, "Reliability": 1})
# Access features and alternatives
print("Features:", model.get_features())
print("Alternatives:", model.get_alternatives())
print()
# Remove a feature
model.remove_feature("Speed")
# String representation of the model
print(model)
```
**Output:**
```
Features: ('Security', 'Performance', 'Speed', 'Reliability')
Alternatives: ('MySQL', 'PostgreSQL', 'MongoDB', 'SQLite')
"DBMS"
MySQL PostgreSQL MongoDB SQLite
Security 1 0 1 1
Performance 1 1 0 0
Reliability 1 1 1 1
```
---
#### `MultiSystemModel`
The `MultiSystemModel` class is designed to represent and manipulate multiple system models. It supports operations like adding, removing, and combining data from multiple `SystemModel` instances into a unified structure.
##### Key Features
- Combine multiple system models into a unified structure.
- Add, remove, and retrieve system models by name.
- Generate combinations of alternatives across all systems.
- Retrieve features and alternatives for all systems collectively.
- Built-in support for `pandas.DataFrame` for data representation.
---
##### Initialization Parameters
| Parameter | Type | Description |
|--------------------|------------------------|-----------------------------------------------------------------------------|
| `system_models` | `list`, `tuple`, `set`, `None` | The list, tuple, or set of `SystemModel` instances to initialize the multi-system model. |
---
##### Methods Overview
| Method | Description |
|--------------------------------------|----------------------------------------------------------------------------------------------|
| `add_system(system_model)` | Adds a new system model to the multi-system model. |
| `add_systems(system_models)` | Adds multiple system models to the multi-system model. |
| `remove_system(system_name)` | Removes a system model by name. |
| `get_system_names()` | Returns a tuple of all system model names in the multi-system model. |
| `get_all_combinations()` | Generates all combinations of alternatives across all system models and returns a DataFrame. |
| `get_features_related_to_system()` | Returns a tuple of features associated with each system in the multi-system model. |
| `get_all_features()` | Returns a tuple of all features across all systems in the multi-system model. |
| `get_prototype()` | Creates and returns a `Prototype` instance based on the features of all system models. |
| `__str__()` | Returns a string representation of the multi-system model. |
---
##### Example Usage
```python
from momo.system_models.system_models import SystemModel, MultiSystemModel
# Create individual system models
dbms = SystemModel(
name="DBMS",
data=[
[1, 0, 1], # Security
[1, 1, 0], # Performance
[0, 1, 1], # Speed
],
features=["Security", "Performance", "Speed"],
alternatives=["MySQL", "PostgreSQL", "MongoDB"]
)
connector = SystemModel(
name="Connector",
data=[
[1, 0], # Flexibility
[1, 1], # Cost
],
features=["Flexibility", "Cost"],
alternatives=["Copper", "Aluminum"]
)
# Initialize a multi-system model
multi_system = MultiSystemModel([dbms, connector])
# Add a new system model
multi_system.add_system(
SystemModel(
name="Cache",
data=[
[1, 1], # Caching Speed
[0, 1], # Cost Efficiency
],
features=["Caching Speed", "Cost Efficiency"],
alternatives=["Redis", "Memcached"]
)
)
# Retrieve system names
print("System Names:", multi_system.get_system_names())
# Retrieve all combinations of alternatives across all systems
combinations = multi_system.get_all_combinations()
print("\nAll Combinations of Alternatives:")
print(combinations)
# Retrieve features related to each system
related_features = multi_system.get_features_related_to_system()
print("\nRelated Features:")
print(related_features)
# Get the prototype based on the multi-system model
prototype = multi_system.get_prototype()
print("\nPrototype:")
print(prototype)
```
**Output:**
```
System Names: ('DBMS', 'Connector', 'Cache')
All Combinations of Alternatives:
(MySQL, Copper, Redis) (MySQL, Copper, Memcached) (MySQL, Aluminum, Redis) ... (MongoDB, Copper, Memcached) (MongoDB, Aluminum, Redis) (MongoDB, Aluminum, Memcached)
DBMS Security 1 1 1 ... 1 1 1
Performance 1 1 1 ... 0 0 0
Speed 0 0 0 ... 1 1 1
Connector Flexibility 1 1 0 ... 1 0 0
Cost 1 1 1 ... 1 1 1
Cache Caching Speed 1 1 1 ... 1 1 1
Cost Efficiency 0 1 0 ... 1 0 1
[7 rows x 12 columns]
Related Features:
(('DBMS', 'Security'), ('DBMS', 'Performance'), ('DBMS', 'Speed'), ('Connector', 'Flexibility'), ('Connector', 'Cost'), ('Cache', 'Caching Speed'), ('Cache', 'Cost Efficiency'))
Prototype:
DBMS Security 0
Performance 0
Speed 0
Connector Flexibility 0
Cost 0
Cache Caching Speed 0
Cost Efficiency 0
dtype: int64
```
---
Raw data
{
"_id": null,
"home_page": "https://github.com/danylevych/MoMo",
"name": "momo-morphological-modeling",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Oleh Danylevych",
"author_email": "danylevych123@email.com",
"download_url": "https://files.pythonhosted.org/packages/30/82/0d80f6cb4698428f78bfb293665fad6f7667563d2588af0f5767a2021506/momo_morphological_modeling-1.3.0.tar.gz",
"platform": null,
"description": "# Guide\n\n- [Installation](#installation)\n- [Modules](#modules)\n - [model](#model)\n - [prototype](#prototype)\n - [system_models](#system_models)\n- [Author](#author)\n\n\n## Installation\n\nTo install the package, run the following command:\n\n```bash\npip install momo-morphological-modeling\n```\n\n## Modules\n\nThe package contains the following modules:\n\n- `model`: Contains the main classes for the morphological modeling `MoMoModel`.\n- `prototype`: Contains the classes for the prototype of morphological modeling `Prototype`.\n- `system_models`: Contains the classes for the system models `SystemModel` and `MultySystemModel`.\n\n---\n\n### model\n\nThe `model` module contains the main classes for the morphological modeling. The main class is `MoMoModel` which is used to create a morphological model and to perform the morphological analysis.\n\n### MoMoModel\n\nThe `MoMoModel` class represents a **Multi-Object Multi-System Model** designed to manage multiple system models and a prototype for similarity calculations. It integrates the `Prototype` and `MultiSystemModel` classes, enabling users to perform operations on system models and calculate similarity measures between them.\n\n#### Key Features\n- Supports initialization with multiple system models and an optional prototype.\n- Automatically generates a prototype based on the system models if not provided.\n- Allows for similarity measure calculations between the prototype and combinations of system models.\n- Built-in integration with `Prototype` and `MultiSystemModel`.\n\n---\n\n##### Initialization Parameters\n\n| Parameter | Type | Description |\n|-----------------|--------------------------------|----------------------------------------------------------------------------------------------|\n| `system_models` | `MultiSystemModel`, `list`, `tuple`, `set` | The system models used in the `MoMoModel`. |\n| `prototype` | `Prototype`, `None` (optional) | The prototype object to compare with system models. Defaults to `None`. |\n\n---\n\n##### Methods Overview\n\n| Method | Description |\n|---------------------------------------|----------------------------------------------------------------------------------------------|\n| `get_prototype()` | Returns the current prototype. |\n| `set_prototype(prototype)` | Sets a new prototype. |\n| `prototype_` (property) | Gets or sets the prototype. |\n| `get_system_models()` | Returns the current system models. |\n| `set_system_models(system_models)` | Sets new system models and updates the prototype accordingly. |\n| `system_models_` (property) | Gets or sets the system models. |\n| `get_similarity_measures()` | Calculates similarity measures between the prototype and all combinations of system models. |\n| `__str__()` | Returns a string representation of the `MoMoModel` object, including the prototype and system models. |\n\n---\n\n##### Example Usage\n\n```python\nfrom momo.model import MoMoModel\nfrom momo.system_models.system_models import MultiSystemModel, SystemModel\n\n\n# Create individual system models\ndbms = SystemModel(\n name=\"DBMS\",\n data=[\n [1, 0, 1], # Security\n [1, 1, 0], # Performance\n [0, 1, 1], # Speed\n ],\n features=[\"Security\", \"Performance\", \"Speed\"],\n alternatives=[\"MySQL\", \"PostgreSQL\", \"MongoDB\"]\n)\n\nconnector = SystemModel(\n name=\"Connector\",\n data=[\n [1, 0], # Flexibility\n [1, 1], # Cost\n ],\n features=[\"Flexibility\", \"Cost\"],\n alternatives=[\"Copper\", \"Aluminum\"]\n)\n\n# Initialize a MultiSystemModel\nmulti_system = MultiSystemModel([dbms, connector])\n\n# Initialize a MoMoModel\nmomo_model = MoMoModel(system_models=multi_system)\n\n# Access the prototype\nprint(\"Prototype:\")\nprint(momo_model.prototype)\n\n# Calculate similarity measures\nsimilarity_measures = momo_model.get_similarity_measures()\nprint(\"\\nSimilarity Measures:\")\nfor combination, measure in similarity_measures.items():\n print(f\"{combination}: {measure}\")\n\n# String representation\nprint(\"\\nMoMoModel:\")\nprint(momo_model)\n```\n\n**Output:**\n```\nPrototype:\nDBMS Security 0\n Performance 0\n Speed 0\nConnector Flexibility 0\n Cost 0\ndtype: int64\n\nSimilarity Measures:\n('MySQL', 'Copper'): 0.5\n('MySQL', 'Aluminum'): 1.3333333333333333\n('PostgreSQL', 'Copper'): 0.5\n('PostgreSQL', 'Aluminum'): 1.3333333333333333\n('MongoDB', 'Copper'): 0.5\n('MongoDB', 'Aluminum'): 1.3333333333333333\n\nMoMoModel:\nPrototype:\nDBMS Security 0\n Performance 0\n Speed 0\nConnector Flexibility 0\n Cost 0\ndtype: int64\n\nSystem Models:\n (MySQL, Copper) (MySQL, Aluminum) (PostgreSQL, Copper) (PostgreSQL, Aluminum) (MongoDB, Copper) (MongoDB, Aluminum)\nDBMS Security 1 1 0 0 1 1\n Performance 1 1 1 1 0 0\n Speed 0 0 1 1 1 1\nConnector Flexibility 1 0 1 0 1 0\n Cost 1 1 1 1 1 1\n```\n\n\n\n\n\n\n\n---\n\n### prototype\n\nThe `prototype` module contains the `Prototype` class, which is a subclass of `pandas.Series`. It is designed to store and manipulate hierarchical data using features and alternatives.\n\n### Prototype\n\nThe `Prototype` class extends the functionality of `pandas.Series` by allowing hierarchical data representation with support for setting values via dictionaries or lists. **And its represnt the prototype of the morphological model.**\n\n##### Key Features\n- Directly inherits all functionality from `pandas.Series`.\n- Supports setting values using hierarchical dictionaries or lists.\n- Maintains compatibility with standard pandas operations.\n\n---\n\n##### Initialization Parameters\n\n| Parameter | Type | Description |\n|----------------|----------------------------|-----------------------------------------------------------------------------|\n| `data` | `array-like`, `Iterable`, `dict`, `scalar` | The data to be stored in the `Prototype`. |\n| `index` | `array-like` or `Index` | The index labels for the data. |\n\n---\n\n##### Methods Overview\n\n| Method | Description |\n|-----------------------------------|----------------------------------------------------------------------------------------------|\n| `set_marks(marks_list)` | Sets values in the `Prototype` using a dictionary or list. |\n| `_set_marks_dict(marks_dict)` | Sets values in the `Prototype` from a dictionary of hierarchical data. |\n| `_set_marks_list(marks_list)` | Sets values in the `Prototype` from a list. |\n\n---\n\n##### Example Usage\n\n```python\nfrom momo.prototype import Prototype\n\n\n# Initialize a prototype with hierarchical data\ndata = [0, 0, 0, 1]\nindex = [(\"System1\", \"Feature1\"), (\"System1\", \"Feature2\"), (\"System2\", \"Feature3\"), (\"System2\", \"Feature4\")]\n\nprototype = Prototype(data=data, index=index)\n\nprint(\"Initial Prototype:\")\nprint(prototype)\n\n# Set marks using a dictionary\nprototype.set_marks({\n \"System1\": {\"Feature1\": 1, \"Feature2\": 2},\n \"System2\": {\"Feature3\": 3, \"Feature4\": 4}\n})\n\nprint(\"\\nPrototype after setting marks (dict):\")\nprint(prototype)\n\n# Set marks using a list\nprototype.set_marks([10, 20, 30, 40])\n\nprint(\"\\nPrototype after setting marks (list):\")\nprint(prototype)\n```\n\n**Output:**\n```\nInitial Prototype:\n(System1, Feature1) 0\n(System1, Feature2) 0\n(System2, Feature3) 0\n(System2, Feature4) 1\ndtype: int64\n\nPrototype after setting marks (dict):\n(System1, Feature1) 1\n(System1, Feature2) 2\n(System2, Feature3) 3\n(System2, Feature4) 4\ndtype: int64\n\nPrototype after setting marks (list):\n(System1, Feature1) 10\n(System1, Feature2) 20\n(System2, Feature3) 30\n(System2, Feature4) 40\ndtype: int64\n```\n\n\n---\n\n### system_models\n\nThe `system_models` module contains the classes for the system models. The main classes are `SystemModel` and `MultySystemModel` which are used to create the system models.\n\n#### `SystemModel`\n\nThe `SystemModel` class is a core component designed to represent and manipulate system models. It allows you to manage a structured representation of features and alternatives, supporting data storage, validation, and various manipulations.\n\n##### Key Features\n- Manage relationships between features and alternatives.\n- Add, remove, and retrieve features and alternatives.\n- Validate the consistency of data, features, and alternatives.\n- Built-in support for `pandas.DataFrame` for structured data handling.\n\n---\n\n##### Initialization Parameters\n\n| Parameter | Type | Description |\n|----------------|--------------|---------------------------------------------------------------------------------------------------|\n| `name` | `str` | The name of the system model. |\n| `data` | `list`, `None` | The data matrix (rows: features, columns: alternatives) to initialize the system model. |\n| `features` | `list`, `None` | The list of feature names. |\n| `alternatives` | `list`, `None` | The list of alternative names.|\n\n---\n\n##### Methods Overview\n\n| Method | Description |\n|----------------------------|----------------------------------------------------------------------------------------------|\n| `add_feature(feature_name, alternatives)` | Adds a new feature to the system model with its alternatives. |\n| `add_alternative(alternative_name, features)` | Adds a new alternative to the system model with its features. |\n| `remove_feature(feature_name)` | Removes a feature from the system model. |\n| `remove_alternative(alternative_name)` | Removes an alternative from the system model. |\n| `get_features()` | Returns a tuple of all features in the system model. |\n| `get_alternatives()` | Returns a tuple of all alternatives in the system model. |\n| `features` (property) | Returns the list of feature names as a pandas DataFrame index. |\n| `alternatives` (property) | Returns the list of alternative names as a pandas DataFrame column index. |\n| `loc` (property) | Provides access to pandas DataFrame `.loc` for advanced slicing and indexing. |\n| `__getitem__(key)` | Retrieves a value from the underlying data using a key (row/column-based indexing). |\n| `__setitem__(key, value)` | Sets a value in the underlying data using a key. |\n| `__str__()` | Returns a string representation of the system model, including its name and the data matrix. |\n\n---\n\n##### Example Usage\n\n```python\nfrom momo.system_models.system_models import SystemModel\n\n# Initialize a system model\nmodel = SystemModel(\n name=\"DBMS\",\n data=[\n [1, 0, 1], # Security\n [1, 1, 0], # Performance\n [0, 1, 1], # Speed\n ],\n features=[\"Security\", \"Performance\", \"Speed\"],\n alternatives=[\"MySQL\", \"PostgreSQL\", \"MongoDB\"]\n)\n\n# Add a new feature\nmodel.add_feature(\"Reliability\", [1, 1, 1])\n\n# Add a new alternative\nmodel.add_alternative(\"SQLite\", {\"Security\": 1, \"Performance\": 0, \"Speed\": 1, \"Reliability\": 1})\n\n# Access features and alternatives\nprint(\"Features:\", model.get_features())\nprint(\"Alternatives:\", model.get_alternatives())\nprint()\n\n# Remove a feature\nmodel.remove_feature(\"Speed\")\n\n# String representation of the model\nprint(model)\n```\n\n**Output:**\n```\nFeatures: ('Security', 'Performance', 'Speed', 'Reliability')\nAlternatives: ('MySQL', 'PostgreSQL', 'MongoDB', 'SQLite')\n\n\"DBMS\"\n MySQL PostgreSQL MongoDB SQLite\nSecurity 1 0 1 1\nPerformance 1 1 0 0\nReliability 1 1 1 1\n```\n\n---\n\n#### `MultiSystemModel`\n\nThe `MultiSystemModel` class is designed to represent and manipulate multiple system models. It supports operations like adding, removing, and combining data from multiple `SystemModel` instances into a unified structure.\n\n##### Key Features\n- Combine multiple system models into a unified structure.\n- Add, remove, and retrieve system models by name.\n- Generate combinations of alternatives across all systems.\n- Retrieve features and alternatives for all systems collectively.\n- Built-in support for `pandas.DataFrame` for data representation.\n\n---\n\n##### Initialization Parameters\n\n| Parameter | Type | Description |\n|--------------------|------------------------|-----------------------------------------------------------------------------|\n| `system_models` | `list`, `tuple`, `set`, `None` | The list, tuple, or set of `SystemModel` instances to initialize the multi-system model. |\n\n---\n\n##### Methods Overview\n\n| Method | Description |\n|--------------------------------------|----------------------------------------------------------------------------------------------|\n| `add_system(system_model)` | Adds a new system model to the multi-system model. |\n| `add_systems(system_models)` | Adds multiple system models to the multi-system model. |\n| `remove_system(system_name)` | Removes a system model by name. |\n| `get_system_names()` | Returns a tuple of all system model names in the multi-system model. |\n| `get_all_combinations()` | Generates all combinations of alternatives across all system models and returns a DataFrame. |\n| `get_features_related_to_system()` | Returns a tuple of features associated with each system in the multi-system model. |\n| `get_all_features()` | Returns a tuple of all features across all systems in the multi-system model. |\n| `get_prototype()` | Creates and returns a `Prototype` instance based on the features of all system models. |\n| `__str__()` | Returns a string representation of the multi-system model. |\n\n---\n\n##### Example Usage\n\n```python\nfrom momo.system_models.system_models import SystemModel, MultiSystemModel\n\n# Create individual system models\ndbms = SystemModel(\n name=\"DBMS\",\n data=[\n [1, 0, 1], # Security\n [1, 1, 0], # Performance\n [0, 1, 1], # Speed\n ],\n features=[\"Security\", \"Performance\", \"Speed\"],\n alternatives=[\"MySQL\", \"PostgreSQL\", \"MongoDB\"]\n)\n\nconnector = SystemModel(\n name=\"Connector\",\n data=[\n [1, 0], # Flexibility\n [1, 1], # Cost\n ],\n features=[\"Flexibility\", \"Cost\"],\n alternatives=[\"Copper\", \"Aluminum\"]\n)\n\n# Initialize a multi-system model\nmulti_system = MultiSystemModel([dbms, connector])\n\n# Add a new system model\nmulti_system.add_system(\n SystemModel(\n name=\"Cache\",\n data=[\n [1, 1], # Caching Speed\n [0, 1], # Cost Efficiency\n ],\n features=[\"Caching Speed\", \"Cost Efficiency\"],\n alternatives=[\"Redis\", \"Memcached\"]\n )\n)\n\n# Retrieve system names\nprint(\"System Names:\", multi_system.get_system_names())\n\n# Retrieve all combinations of alternatives across all systems\ncombinations = multi_system.get_all_combinations()\nprint(\"\\nAll Combinations of Alternatives:\")\nprint(combinations)\n\n# Retrieve features related to each system\nrelated_features = multi_system.get_features_related_to_system()\nprint(\"\\nRelated Features:\")\nprint(related_features)\n\n# Get the prototype based on the multi-system model\nprototype = multi_system.get_prototype()\nprint(\"\\nPrototype:\")\nprint(prototype)\n```\n\n\n**Output:**\n```\nSystem Names: ('DBMS', 'Connector', 'Cache')\n\nAll Combinations of Alternatives:\n (MySQL, Copper, Redis) (MySQL, Copper, Memcached) (MySQL, Aluminum, Redis) ... (MongoDB, Copper, Memcached) (MongoDB, Aluminum, Redis) (MongoDB, Aluminum, Memcached)\nDBMS Security 1 1 1 ... 1 1 1\n Performance 1 1 1 ... 0 0 0\n Speed 0 0 0 ... 1 1 1\nConnector Flexibility 1 1 0 ... 1 0 0\n Cost 1 1 1 ... 1 1 1\nCache Caching Speed 1 1 1 ... 1 1 1\n Cost Efficiency 0 1 0 ... 1 0 1\n\n[7 rows x 12 columns]\n\nRelated Features:\n(('DBMS', 'Security'), ('DBMS', 'Performance'), ('DBMS', 'Speed'), ('Connector', 'Flexibility'), ('Connector', 'Cost'), ('Cache', 'Caching Speed'), ('Cache', 'Cost Efficiency'))\n\nPrototype:\nDBMS Security 0\n Performance 0\n Speed 0\nConnector Flexibility 0\n Cost 0\nCache Caching Speed 0\n Cost Efficiency 0\ndtype: int64\n```\n\n\n---\n",
"bugtrack_url": null,
"license": null,
"summary": "MoMo is a module that does Morphological Modeling",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/danylevych/MoMo"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "71b4498823bcc176cbcaaf542b788b343acb6313cb38917bfca37c30772ecb55",
"md5": "eb968f4fc3832bc45cdced2630c782ed",
"sha256": "74c78fd6e6152f98189be8ddb23bef8dd43e0f954d919185d51a1dc71d661476"
},
"downloads": -1,
"filename": "momo_morphological_modeling-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb968f4fc3832bc45cdced2630c782ed",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 16462,
"upload_time": "2025-02-01T12:55:14",
"upload_time_iso_8601": "2025-02-01T12:55:14.439729Z",
"url": "https://files.pythonhosted.org/packages/71/b4/498823bcc176cbcaaf542b788b343acb6313cb38917bfca37c30772ecb55/momo_morphological_modeling-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "30820d80f6cb4698428f78bfb293665fad6f7667563d2588af0f5767a2021506",
"md5": "b64e6e03996ff8db02ff6ead7c589543",
"sha256": "c77f52d54d7fb4f9a9d9e61c75179df0130fb58eefa9809e28f816e3e6e7ef1b"
},
"downloads": -1,
"filename": "momo_morphological_modeling-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "b64e6e03996ff8db02ff6ead7c589543",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17427,
"upload_time": "2025-02-01T12:55:17",
"upload_time_iso_8601": "2025-02-01T12:55:17.102666Z",
"url": "https://files.pythonhosted.org/packages/30/82/0d80f6cb4698428f78bfb293665fad6f7667563d2588af0f5767a2021506/momo_morphological_modeling-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-01 12:55:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "danylevych",
"github_project": "MoMo",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "contourpy",
"specs": [
[
"==",
"1.3.1"
]
]
},
{
"name": "cycler",
"specs": [
[
"==",
"0.12.1"
]
]
},
{
"name": "fonttools",
"specs": [
[
"==",
"4.55.3"
]
]
},
{
"name": "kiwisolver",
"specs": [
[
"==",
"1.4.7"
]
]
},
{
"name": "matplotlib",
"specs": [
[
"==",
"3.9.3"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"2.2.0"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"24.2"
]
]
},
{
"name": "pandas",
"specs": [
[
"==",
"2.2.3"
]
]
},
{
"name": "pillow",
"specs": [
[
"==",
"11.0.0"
]
]
},
{
"name": "pyparsing",
"specs": [
[
"==",
"3.2.0"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "pytz",
"specs": [
[
"==",
"2024.2"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.17.0"
]
]
},
{
"name": "tzdata",
"specs": [
[
"==",
"2024.2"
]
]
}
],
"lcname": "momo-morphological-modeling"
}