Standalone Tools and Verification
Relevant source files
The following files were used as context for generating this wiki page:The project includes a suite of standalone Python scripts that complement the main interactive dashboard. These tools are designed for data processing, offline analysis, report generation, and calculation verification. They operate on a common CSV data source and produce various outputs, including richly formatted Excel workbooks and detailed analysis reports.
A key function of these tools, particularly the Excel generators, is to provide a transparent and verifiable model of the TOPSIS calculation. By embedding Excel formulas directly into the spreadsheets, the results from the Python-based backend can be cross-referenced and validated, ensuring the integrity of the decision support system.
Data Source and Pre-processing
All standalone scripts utilize a common input file, No-Vendor-NamaPaketPlan-CPU-RAM-DiskIOSpeed-HargaBulanUSD.csv, for the initial set of alternatives. The scripts contain functions to parse and standardize the data from this file.
The data processing flow is as follows:
This diagram shows the common data pre-processing pipeline in the standalone scripts.
Sources: topsis_spk.py:31-56, generate_excel_level.py:8-29
A notable piece of logic is the extraction and conversion of the Disk I/O Speed value, which handles different units (Gbps/Mbps) and converts them to a standard MB/s measurement.
# Source: topsis_spk.py:40-50
def extract_disk_io(val):
# Ekstrak kapasitas disk dan kecepatan bandwidth
disk = int(re.search(r'(\d+)\s*GB', val).group(1))
speed_match = re.search(r'(\d+(?:\.\d+)?)\s*(Gbps|Mbps)', val)
if speed_match:
speed = float(speed_match.group(1))
if 'Gbps' in speed_match.group(2):
speed *= 1000 # Convert Gbps to Mbps
else:
speed = 100 # Default 100 Mbps
# Estimasi Disk I/O Speed dalam MB/s (bandwidth / 8)
return speed / 8
Sources: topsis_spk.py:40-50, generate_excel_formula.py:14-24, generate_excel_topsis.py:14-24
Excel Generation Scripts
The project includes three distinct scripts for generating different types of Excel workbooks, each serving a unique purpose from data entry simplification to calculation verification.
generate_excel_level.py
This script produces TOPSIS_Input_Level.xlsx, an Excel file designed to simplify data input by abstracting raw values into a 1-5 level system. The spreadsheet contains embedded Excel formulas to automatically convert the user-provided levels back into the standard numerical values required for the TOPSIS calculation.
The key feature is the use of the CHOOSE formula in the 2. Konversi ke Nilai sheet to map levels to values.
// Source: generate_excel_level.py:237
=CHOOSE('1. Input Level'!D{row},2,4,6,8,10) // CPU conversion
Generated Sheets:
| Sheet Name | Purpose |
|---|---|
0. Panduan Level | Provides a guide for the 1-5 level system for each criterion. |
1. Input Level | The main input sheet where users can edit the level for each alternative. |
2. Konversi ke Nilai | Automatically converts levels from the input sheet into actual values using formulas. |
3. Bobot & Kriteria | Defines criterion weights and types (BENEFIT/COST). |
4. Normalisasi | Calculates the normalized matrix using Excel formulas. |
5. Normalisasi Terbobot | Calculates the weighted normalized matrix using Excel formulas. |
6. Solusi Ideal | Determines the Ideal Positive (A+) and Ideal Negative (A-) solutions. |
7. Hasil TOPSIS | Calculates the final distances (D+, D-), scores, and ranks. |
| Sources: generate_excel_level.py |
generate_excel_formula.py
This script creates TOPSIS_Rumus_Otomatis.xlsx, a fully transparent and automated TOPSIS calculator within a single Excel file. Users can modify the raw criteria values in the 1. Data Input sheet, and all subsequent calculation steps in other sheets will update automatically via linked Excel formulas. This workbook serves as a primary tool for verifying the logic of the Python-based calculations.
The data flow within the generated Excel file is as follows:
This diagram illustrates how sheets in the generated Excel file are interconnected with formulas.
Sources: generate_excel_formula.py
Generated Sheets:
| Sheet Name | Purpose |
|---|---|
1. Data Input | Users can edit raw criteria values (CPU cores, RAM GB, etc.). |
2. Bobot & Kriteria | Defines and allows editing of criterion weights. |
3. Normalisasi | Calculates the normalized matrix from the input data. |
4. Normalisasi Terbobot | Applies weights to the normalized matrix. |
5. Solusi Ideal | Determines A+ and A- solutions. |
6. Hasil TOPSIS | Displays the final scores and ranks. |
| Sources: generate_excel_formula.py |
generate_excel_topsis.py
This script generates TOPSIS_Perhitungan_Lengkap.xlsx, which acts as a static report of a single TOPSIS analysis performed in Python. Unlike the other generated Excel files, this one contains the results of the calculations (i.e., the numerical values) rather than the formulas themselves. It provides a step-by-step snapshot of the entire calculation process for documentation and review.
Generated Sheets:
| Sheet Name | Purpose |
|---|---|
1. Data Asli | Shows the original raw data and their assigned levels. |
2. Matriks Keputusan | The initial decision matrix (X) used for the calculation. |
3. Normalisasi | The calculated normalized matrix (R). |
4. Normalisasi Terbobot | The calculated weighted normalized matrix (Y). |
5. Solusi Ideal | The calculated A+ and A- solutions. |
6. Jarak & Score TOPSIS | The final calculated distances, scores, and ranks. |
| Sources: generate_excel_topsis.py |
Standalone TOPSIS Analyzer (topsis_spk.py)
This script is a command-line application that performs a complete TOPSIS analysis from start to finish. It encapsulates the entire process within the TOPSISAnalyzer class, reading the input CSV, performing calculations, and generating multiple output files.
TOPSISAnalyzer Class
This class is the core of the script, managing the analysis workflow.
This diagram shows the structure of the TOPSISAnalyzer class and its main methods.
Sources: topsis_spk.py:8-20, backend/topsis_service.py:7-26
Execution Flow
The main function in the script orchestrates the analysis by calling methods on the TOPSISAnalyzer instance in a specific order.
This flowchart shows the sequence of operations when topsis_spk.py is executed.
Sources: topsis_spk.py:321-332
Outputs
Running topsis_spk.py produces the following artifacts:
- Console Report: A formatted summary of the top 10 rankings and the best recommendation printed to the standard output.
hasil_visualisasi_topsis.png: A comprehensive plot including bar charts, a radar chart, a scatter plot, and a heatmap.hasil_topsis_lengkap.csv: A CSV file containing the full ranked list of all alternatives with their scores.rekomendasi_top5.txt: A text file with detailed information about the top 5 recommended alternatives.
Sources: topsis_spk.py:311-319
Calculation Verification
The project ensures the correctness of its TOPSIS implementation by enabling verification between the Python scripts and the formula-driven Excel models. The TOPSIS_Rumus_Otomatis.xlsx file, generated by generate_excel_formula.py, is central to this process. Because its calculations are based entirely on standard Excel formulas, it acts as an independent ground truth.
The verification process can be visualized as follows:
This diagram shows that results from the Python execution (topsis_spk.py) can be compared against the results from the formula-based Excel sheet to ensure they match.
Sources: generate_excel_formula.py, topsis_spk.py, README.md (mention of VERIFIKASI_INTEGRASI.md)