Python implementation of the BeCoMe (Best Compromise Mean) method for group decision-making under fuzzy uncertainty.
- Author: Ekaterina Kuzmina
- University: Czech University of Life Sciences Prague
- Faculty: Faculty of Economics and Management (Provozně ekonomická fakulta)
- Thesis Type: Bachelor Thesis
- Supervisor: doc. Ing. Jan Tyrychtr, Ph.D.
- Academic Year: 2025/2026
- Language: English
- Thesis Text: Will be published upon completion
Group decision-making under uncertainty is a critical challenge in many domains, including public policy, emergency management, and resource allocation. Traditional aggregation methods often fail to capture the inherent fuzziness and disagreement among expert opinions, particularly when dealing with interval estimates or subjective assessments.
This thesis presents a Python implementation of the BeCoMe (Best Compromise Mean) method, which addresses these limitations by combining arithmetic mean and statistical median approaches within a fuzzy triangular number framework. The method provides a robust mechanism for aggregating expert opinions expressed as fuzzy triangular numbers, producing a consensus estimate that balances central tendency with distributional robustness.
The implementation is validated against three real-world case studies from public policy domain: COVID-19 budget allocation (22 experts), flood prevention planning (13 experts with polarized views), and cross-border travel policy assessment (22 experts using Likert scale). Complete test coverage and comprehensive documentation ensure reproducibility and facilitate future research applications.
Expert-based decision-making faces several challenges:
-
Uncertainty representation: Experts often express opinions as ranges or intervals rather than point estimates, reflecting inherent uncertainty in their assessments.
-
Opinion aggregation: Combining multiple expert opinions requires methods that preserve information about uncertainty while producing actionable consensus estimates.
-
Robustness to outliers: Traditional mean-based aggregation is sensitive to extreme opinions, while median-based approaches may lose information about the overall distribution.
-
Practical applicability: Decision support tools must be accessible to practitioners without requiring deep mathematical expertise.
The BeCoMe method addresses these challenges by combining the strengths of arithmetic mean (preserving distributional information) and statistical median (providing robustness), while working within a fuzzy triangular number framework that naturally represents expert uncertainty.
This implementation makes the method accessible through a well-documented Python library with practical examples from public policy applications.
The BeCoMe method operates on expert opinions expressed as fuzzy triangular numbers A = (a, c, b), where:
- a = lower bound (pessimistic estimate)
- c = peak (most likely value)
- b = upper bound (optimistic estimate)
The algorithm proceeds through four steps:
- Arithmetic Mean (Γ): Calculate component-wise average of all expert opinions
- Median (Ω): Sort opinions by centroid values and compute median fuzzy number
- Best Compromise (ΓΩMean): Average the arithmetic mean and median
- Error Estimation (Δmax): Calculate maximum deviation as quality metric
Programming Language: Python 3.13+
Key Design Decisions:
- Object-oriented architecture with clear separation between data models and calculation logic
- Strategy pattern for median calculation (odd vs. even number of experts)
- Immutable value objects for fuzzy numbers using
dataclasses - Type safety enforced through
mypyin strict mode - Comprehensive unit and integration testing with 100% code coverage
Dependencies:
- Core: Python standard library only (no external dependencies for calculation logic)
- Development:
pytestfor testing,mypyfor type checking,rufffor linting - Visualization:
matplotlib,seaborn,jupyter(optional, for examples)
Validation:
- Implementation validated against Excel reference calculations from original research
- Three case studies with known expected results
- Numerical precision verified to 0.001 tolerance for all test cases
See Architecture Documentation for detailed design rationale.
The implementation includes three real-world datasets from Czech public policy domain:
- Domain: COVID-19 pandemic budget support
- Experts: 22 (government officials, emergency service leaders)
- Data Type: Interval estimates (0-100 billion CZK)
- Format: Fuzzy triangular numbers
- Characteristics: Even number of experts, moderate agreement
- Domain: Flood prevention - arable land reduction
- Experts: 13 (land owners, hydrologists, rescue services)
- Data Type: Percentage estimates (0-100%)
- Format: Fuzzy triangular numbers
- Characteristics: Odd number of experts, highly polarized opinions
- Domain: Cross-border travel policy during pandemic
- Experts: 22 (public health officials, border services)
- Data Type: Likert scale ratings (0, 25, 50, 75, 100)
- Format: Crisp values (special case of fuzzy numbers where a = c = b)
- Characteristics: Even number of experts, ordinal scale data
All datasets are stored in human-readable text format in examples/data/:
CASE: CaseName
DESCRIPTION: Case description
EXPERTS: N
# Format: ExpertID | Lower | Peak | Upper
Expert1 | 10.0 | 15.0 | 20.0
Expert2 | 12.0 | 18.0 | 25.0
...
- Location:
examples/data/directory in this repository - License: Academic use only (part of bachelor thesis)
- Access: Public (GitHub repository)
- Python 3.13 or higher
uvpackage manager (recommended) orpip
This project uses uv for dependency management:
# Clone the repository
git clone <repository-url>
cd BeCoMe
# Install dependencies using uv
uv sync
# Activate virtual environment
source .venv/bin/activate # On macOS/Linux
# or
.venv\Scripts\activate # On WindowsAlternatively, with pip:
pip install -e ".[dev]"The easiest way to understand the BeCoMe method is to run one of the case study analyses:
# COVID-19 budget support case (22 experts, even number)
uv run python -m examples.analyze_budget_case
# Flood prevention case (13 experts, odd number)
uv run python -m examples.analyze_floods_case
# Cross-border travel policy case (22 experts, Likert scale)
uv run python -m examples.analyze_pendlers_caseEach example provides step-by-step calculations with detailed explanations of the mathematical operations.
from src.calculators.become_calculator import BeCoMeCalculator
from src.models.expert_opinion import ExpertOpinion
from src.models.fuzzy_number import FuzzyTriangleNumber
# Create expert opinions as fuzzy triangular numbers
experts = [
ExpertOpinion("Expert 1", FuzzyTriangleNumber(5.0, 10.0, 15.0)),
ExpertOpinion("Expert 2", FuzzyTriangleNumber(8.0, 12.0, 18.0)),
ExpertOpinion("Expert 3", FuzzyTriangleNumber(6.0, 11.0, 16.0)),
]
# Calculate best compromise
calculator = BeCoMeCalculator()
result = calculator.calculate_compromise(experts)
# Access results
print(f"Best Compromise: {result.best_compromise}")
print(f"Arithmetic Mean: {result.arithmetic_mean}")
print(f"Median: {result.median}")
print(f"Max Error: {result.max_error}")
print(f"Number of Experts: {result.num_experts}")See API Reference for complete documentation of all classes and methods.
BeCoMe/
├── src/ # Source code
│ ├── models/ # Data models
│ │ ├── fuzzy_number.py # Fuzzy triangular number
│ │ ├── expert_opinion.py # Expert opinion representation
│ │ └── become_result.py # Result model
│ ├── calculators/ # Calculation logic
│ │ ├── become_calculator.py # Main BeCoMe calculator
│ │ ├── base_calculator.py # Abstract base calculator
│ │ └── median_strategies.py # Median calculation strategies
│ ├── interpreters/ # Result interpretation
│ │ └── likert_interpreter.py # Likert scale decision interpreter
│ └── exceptions.py # Custom exceptions
├── tests/ # Test suite
│ ├── unit/ # Unit tests
│ │ ├── models/ # Model tests
│ │ ├── calculators/ # Calculator tests
│ │ ├── interpreters/ # Interpreter tests
│ │ └── utilities/ # Utility function tests
│ ├── integration/ # Integration tests
│ │ ├── test_excel_reference.py # Excel validation tests
│ │ └── test_data_loading.py # Data loading tests
│ └── reference/ # Reference test data
│ ├── budget_case.py # Budget case expected results
│ ├── floods_case.py # Floods case expected results
│ └── pendlers_case.py # Pendlers case expected results
├── examples/ # Practical examples
│ ├── data/ # Case study data files
│ │ ├── README.md # Dataset documentation
│ │ ├── budget_case.txt # COVID-19 budget case
│ │ ├── floods_case.txt # Flood prevention case
│ │ └── pendlers_case.txt # Cross-border travel case
│ ├── utils/ # Example utilities
│ │ ├── data_loading.py # Data file parser
│ │ ├── display.py # Step-by-step display
│ │ ├── formatting.py # Output formatting
│ │ └── analysis.py # Agreement analysis
│ ├── analyze_budget_case.py # Budget case analysis
│ ├── analyze_floods_case.py # Floods case analysis
│ └── analyze_pendlers_case.py # Pendlers case analysis
├── docs/ # Documentation
│ ├── README.md # Documentation navigation
│ ├── method-description.md # Mathematical foundation
│ ├── api-reference.md # Complete API documentation
│ ├── architecture.md # Design decisions
│ ├── uml-diagrams.md # Visual architecture
│ ├── quality-report.md # Quality metrics
│ ├── references.md # Bibliography
│ └── uml-diagrams/ # UML diagram sources and images
├── supplementary/ # Reference materials
└── README.md # This file
The implementation includes comprehensive test coverage:
# Run all tests
uv run pytest
# Run with coverage report
uv run pytest --cov=src --cov-report=term-missing
# Run specific test categories
uv run pytest tests/unit/ # Unit tests only
uv run pytest tests/integration/ # Integration tests only
uv run pytest tests/unit/models/ # Model tests onlyCurrent test coverage: 100% (all source code lines covered)
Test suite includes:
- 173 unit tests covering all models, calculators, and interpreters
- 29 integration tests validating against Excel reference implementation
- Property-based tests for fuzzy number operations
- Edge case coverage (single expert, identical opinions, extreme values)
See Quality Report for detailed test coverage metrics.
The project maintains strict code quality standards:
# Type checking with mypy (strict mode)
uv run mypy src/ examples/
# Linting with ruff
uv run ruff check .
# Code formatting
uv run ruff format .
# Run all quality checks
uv run mypy src/ examples/ && uv run ruff check . && uv run pytest --cov=srcQuality metrics:
- Type safety: 100% (mypy strict mode, no type: ignore comments)
- Code style: 100% (ruff compliance)
- Test coverage: 100%
- Documentation: Complete docstrings for all public APIs
Comprehensive documentation is available in the docs/ directory:
| Document | Description |
|---|---|
| Method Description | Mathematical foundation with formulas and worked examples |
| API Reference | Complete API documentation for all classes and methods |
| UML Diagrams | Visual architecture (class, sequence, activity diagrams) |
| Architecture | Design decisions, patterns, and trade-offs |
| Quality Report | Code quality metrics and test coverage details |
| References | Bibliography and academic sources cited in thesis |
See docs/README.md for complete documentation navigation and recommended reading order.
Recommended reading order:
- Method Description - Understand the mathematical foundation
- Architecture - Learn the design decisions
- API Reference - Explore the implementation
- UML Diagrams - Visualize the structure
The implementation follows object-oriented design principles with clear separation of concerns:
Complete architecture with sequence and activity diagrams available in UML Documentation
- Value Object:
FuzzyTriangleNumberis immutable and validated on construction - Strategy Pattern: Different median calculation strategies for odd/even expert counts
- Template Method:
BaseAggregationCalculatordefines calculation skeleton - Data Transfer Object:
BeCoMeResultencapsulates all calculation outputs
See Architecture Documentation for detailed design rationale.
The examples/ directory contains three real-world case studies demonstrating the method:
Scenario: COVID-19 pandemic budget support estimation (0-100 billion CZK) Participants: Government officials and emergency service leaders Key Feature: Demonstrates median calculation with even number of experts
Scenario: Flood prevention - recommended percentage of arable land reduction Participants: Land owners, hydrologists, rescue service coordinators Key Feature: Demonstrates median calculation with odd number of experts and highly polarized opinions
Scenario: Cross-border travel policy during pandemic Participants: Public health officials and border service representatives Key Feature: Demonstrates handling of Likert scale data (crisp values as special case of fuzzy numbers)
Each example:
- Loads data from text files in
examples/data/ - Shows all calculation steps with mathematical formulas
- Displays intermediate results (arithmetic mean, median, sorting process)
- Provides interpretation of final consensus estimate
See examples/README.md for detailed documentation of example structure and usage.
This implementation is part of a bachelor thesis at the Faculty of Economics and Management, Czech University of Life Sciences Prague.
Academic Use: This code is provided for academic and research purposes. If you use this implementation in academic work, please cite the thesis (full citation will be added upon publication).
Copyright: © 2025-2026 Ekaterina Kuzmina
For questions or collaboration inquiries:
- Author: Ekaterina Kuzmina
- Email: xkuze010@studenti.czu.cz
- University: Czech University of Life Sciences Prague
Full thesis text will be available after publication and defense.
The BeCoMe method was developed by I. Vrana, J. Tyrychtr, and M. Pelikán at the Faculty of Economics and Management, Czech University of Life Sciences Prague.
Key reference:
- Vrana, I., Tyrychtr, J., & Pelikán, M. (2021). BeCoMe: Easy-to-implement optimized method for best-compromise group decision making: Flood-prevention and COVID-19 case studies. Environmental Modelling & Software, 136, 104953. https://doi.org/10.1016/j.envsoft.2020.104953
See docs/references.md for complete bibliography including fuzzy logic foundations (Zadeh 1965, Bellman & Zadeh 1970), software engineering references, and all sources cited in the thesis.
All case study datasets are included in this repository under examples/data/:
budget_case.txt- COVID-19 budget allocation scenario (22 experts, even)floods_case.txt- Flood prevention planning scenario (13 experts, odd, polarized)pendlers_case.txt- Cross-border travel policy (22 experts, Likert scale)
See examples/data/README.md for complete dataset documentation, including file format specifications, data provenance, and ethical considerations.
This work was supervised by doc. Ing. Jan Tyrychtr, Ph.D., at the Faculty of Economics and Management, Czech University of Life Sciences Prague.