{"id":22158607,"url":"https://github.com/danylevych/momo","last_synced_at":"2026-02-12T07:31:54.923Z","repository":{"id":255139355,"uuid":"848656596","full_name":"danylevych/MoMo","owner":"danylevych","description":"MoMo is a module that does Morphological Modeling","archived":false,"fork":false,"pushed_at":"2025-02-01T12:57:13.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T02:42:08.434Z","etag":null,"topics":["morphological-analysis","pypl","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/momo-morphological-modeling/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danylevych.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-28T06:53:37.000Z","updated_at":"2025-02-01T12:57:16.000Z","dependencies_parsed_at":"2025-06-08T00:04:15.794Z","dependency_job_id":"3f05d67b-e1ef-4756-b1af-29c1e736709d","html_url":"https://github.com/danylevych/MoMo","commit_stats":null,"previous_names":["danylevych/momo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danylevych/MoMo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FMoMo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FMoMo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FMoMo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FMoMo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danylevych","download_url":"https://codeload.github.com/danylevych/MoMo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danylevych%2FMoMo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29361457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T01:03:07.613Z","status":"online","status_checked_at":"2026-02-12T02:00:06.911Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["morphological-analysis","pypl","python"],"created_at":"2024-12-02T03:34:40.246Z","updated_at":"2026-02-12T07:31:54.909Z","avatar_url":"https://github.com/danylevych.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanylevych%2Fmomo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanylevych%2Fmomo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanylevych%2Fmomo/lists"}