Sustainable multi-objective portfolio optimization with intuitionistic fuzzy linear programming (IIFLP).
Project description
Portfolio Optimization Package (PROPTO)
Overview
The PROPTO package is designed for optimizing investment portfolios within a trapezoidal intuitionistic fuzzy framework. This package provides tools to determine optimal investment proportions in risky assets, considering multiple objectives and constraints.
Package Contents
1. preliminaries
Functions for manipulating trapezoidal intuitionistic fuzzy numbers (TIFNs).
satisfaction_degree(A): Computes the satisfaction degree of an intuitionistic fuzzy set (IFS).validate_tifn(A): Validates the input trapezoidal intuitionistic fuzzy number (TIFN).tifn_degrees(x, A): Calculates membership and non-membership degrees for a TIFN.add_tifns(A1, A2): Adds two TIFNs.subtract_tifns(A1, A2): Subtracts one TIFN from another.multiply_tifns(A1, A2): Multiplies two TIFNs.divide_tifns(A1, A2): Divides one TIFN by another.scale_tifn(A, lambda_): Scales a TIFN by a given factor.scale_tifn_exponentially(A, lambda_): Applies exponential scaling to a TIFN.negate_tifn(A): Negates a TIFN.reciprocal_tifn(A): Computes the reciprocal of a TIFN.aggregate_tifns(tifns): Aggregates a collection of TIFNs into a single TIFN.weighted_aggregate_tifns(tifns, weights): Aggregates TIFNs with weights.expected_value(A): Calculates the expected value of a TIFN.score_function(A): Computes the score function for a TIFN.accuracy_function(A): Determines the accuracy function for a TIFN.sort_tifns(tifns): Sorts a list of TIFNs.min_tifns(tifns): Identifies the minimum TIFN from a list.max_tifns(tifns): Identifies the maximum TIFN from a list.hamming_distance(A1, A2): Calculates the Hamming distance between two TIFNs.euclidean_distance(A1, A2): Computes the Euclidean distance between two TIFNs.alpha_cut(A, alpha=None): Determines the α-cut set of a TIFN.beta_cut(A, beta=None): Determines the β-cut set of a TIFN.membership_mean(A): Computes the mean of the membership function for a TIFN.nonmembership_mean(A): Computes the mean of the non-membership function for a TIFN.membership_variance(A): Computes the variance of the membership function for a TIFN.nonmembership_variance(A): Computes the variance of the non-membership function for a TIFN.membership_covariance(A1, A2): Computes the covariance of the membership function between two TIFNs.nonmembership_covariance(A1, A2): Computes the covariance of the non-membership function between two TIFNs.credibility_measure(x, A): Computes the credibility measure for a TIFN.membership_entropy(A): Computes the entropy of the membership function for a TIFN.nonmembership_entropy(A): Computes the entropy of the non-membership function for a TIFN.
2. sustainability_evaluation
Functions for aggregating and evaluating sustainability decision matrices.
linguistic_scale(term): Converts a linguistic term into its corresponding trapezoidal intuitionistic fuzzy scale.experts_weights(linguistic_importance): Computes decision-makers' weights based on their linguistic importance.validate_decision_matrices(file_path): Validates the format of decision matrices in an Excel file.aggregate_decision_matrices(file_path, experts_importance): Aggregates decision matrices from an Excel file.extract_decision_matrix(aggregated_decision_matrix, sustainability_dimensions, investment_mode): Extracts and adjusts the aggregated decision matrix.shannon_entropy(extracted_decision_matrix): Calculates criteria weights using Shannon entropy.sustainability_scores(extracted_decision_matrix, criteria_weights): Computes sustainability scores for each alternative.sustainability_scores_mean(sustainability_scores_data): Computes the mean of sustainability scores.
3. return_evaluation
Tools for evaluating financial returns.
read_returns_data(file_path): Reads and formats return data from an Excel file.validate_return_matrix(returns_data, aggregated_decision_matrix): Validates return data format and bounds.returns_mean(returns_data): Computes the mean of return data.returns_variance(returns_data): Computes the variance of return data.returns_covariance(returns_data): Computes the covariance matrix of returns.returns_entropy(returns_data): Computes the entropy of returns.
4. portfolio_optimization
Functions for optimizing portfolios using Pyomo and visualizing results.
min_operator(sustainability_scores_data, returns_data, selected_assets, gamma): Optimizes investment dimensions for multiple objectives and extracts results.max_operator(sustainability_scores_data, returns_data, selected_assets, gamma): Similar tomin_operator, but focuses on maximizing objectives.mean_variance_entropy_model(sustainability_scores_data, returns_data, selected_assets, gamma, min_operator_values, max_operator_values): Optimizes based on mean, variance, and entropy.optimal_solution_analyzer(optimal_solution_df, model_type): Analyzes optimal solutions and calculates objective values.uniform_buy_and__analyzer(min_operator_values, max_operator_values, model_type): Analyzes the portfolio using a Uniform Buy and Hold Strategy.
Installation
-
Install required packages:
pip install numpy pandas scipy matplotlib pyomo amplpy --upgrade python -m amplpy.modules install coin
-
Import necessary libraries:
import math import scipy.integrate as integrate import os import warnings import logging import ast import numpy as np import pandas as pd import pyomo.environ as pyo import matplotlib.pyplot as plt from pyomo.opt import SolverFactory
Usage Instructions
For comprehensive guidance on how to use the POROPTO package, follow the commands below and please refer to the individual function documentation within each module.
-
Define the linguistic importance of the decision-makers:
experts_importance = ('a tuple including the linguistic importance of the decision-makers')
-
Specify the number of criteria for each sustainability dimension:
sustainability_dimensions = { 'social': 'number of social criteria', 'environmental': 'number of environmental criteria', 'economic': 'number of economic criteria' }
-
Aggregate decision matrices from a file:
aggregated_decision_matrix = aggregate_decision_matrices( file_path='the file path of the decision-makers', experts_importance=experts_importance )
-
Extract and adjust the decision matrix:
extracted_decision_matrix = extract_decision_matrix( aggregated_decision_matrix, sustainability_dimensions=sustainability_dimensions, investment_mode='define investment mode' )
-
Calculate criteria weights using Shannon entropy:
criteria_weights = shannon_entropy( extracted_decision_matrix )
-
Compute sustainability scores for each alternative:
sustainability_scores_data = sustainability_scores( extracted_decision_matrix, criteria_weights )
-
Read return data from a file:
returns_data = read_returns_data( file_path='the file path of the return\'s data' )
-
Optimize using the minimum operator:
min_operator_values = min_operator( sustainability_scores_data, returns_data, selected_assets='a tuple including the lower and upper investment bounds', gamma='define the sustainability interval value' )
-
Optimize using the maximum operator:
max_operator_values = max_operator( sustainability_scores_data, returns_data, selected_assets='a tuple including the lower and upper investment bounds', gamma='define the sustainability interval value' )
-
Analyze the optimal solution using the mean-variance-entropy model:
optimal_solution_df = mean_variance_entropy_model( sustainability_scores_data, returns_data, selected_assets='a tuple including the lower and upper investment bounds', gamma='define the sustainability interval value', min_operator_values=min_operator_values, max_operator_values=max_operator_values )
-
Analyze the optimal solution results:
optimal_solution_analyzer( optimal_solution_df, model_type='define the model type' )
Examples
Example 1: Satisfaction Degree
x = {1}
A = (x, 0.3, 0.1)
print(round(satisfaction_degree(A), 2))
Example 2: Membership, Non-membership, and Hesitation Degrees of TIFN
A = [(1, 2, 4, 5), 0.2, 0.3]
x = 1.11
result = tifn_degrees(x, A)
print(tuple(round(value, 3) for value in result))
Example 3: Arithmetic Operators
A1 = [(1, 2, 4, 5), 0.6, 0.4]
A2 = [(1, 2, 3, 6), 0.3, 0.2]
add_result = add_tifns(A1, A2)
subtract_result = subtract_tifns(A1, A2)
multiply_result = multiply_tifns(A1, A2)
divide_result = divide_tifns(A1, A2)
scale_result = scale_tifn(A1, 0.5)
scale_exp_result = scale_tifn_exponentially(A1, 0.5)
negate_result = negate_tifn(A1)
reciprocal_result = reciprocal_tifn(A1)
# Function to round each element in the TIFN result
def round_tifn_result(result):
trapezoidal, mu, nu = result
rounded_trapezoidal = tuple(round(value, 3) for value in trapezoidal)
rounded_mu = round(mu, 3)
rounded_nu = round(nu, 3)
return [rounded_trapezoidal, rounded_mu, rounded_nu]
print(round_tifn_result(add_result))
print(round_tifn_result(subtract_result))
print(round_tifn_result(multiply_result))
print(round_tifn_result(divide_result))
print(round_tifn_result(scale_result))
print(round_tifn_result(scale_exp_result))
print(round_tifn_result(negate_result))
print(round_tifn_result(reciprocal_result))
Example 4: Aggregated Values
collection = [
[(1, 2, 3, 4), 0.6, 0.2],
[(2, 3, 4, 5), 0.7, 0.3],
]
weights = [0.5, 0.5]
aggregate_tifns_result = aggregate_tifns(collection)
weighted_aggregate_result = weighted_aggregate_tifns(collection, weights)
# Function to round each element in the TIFN result
def round_tifn_result(result):
trapezoidal, mu, nu = result
rounded_trapezoidal = tuple(round(value, 3) for value in trapezoidal)
rounded_mu = round(mu, 3)
rounded_nu = round(nu, 3)
return [rounded_trapezoidal, rounded_mu, rounded_nu]
print(round_tifn_result(aggregate_tifns_result))
print(round_tifn_result(weighted_aggregate_result))
Example 5: Expected Value, Score Function, and Accuracy Function
A = [(1, 2, 3, 4), 0.3, 0.2]
print(round(expected_value(A), 3))
print(round(score_function(A), 3))
print(round(accuracy_function(A), 3))
Example 6: Sort Trapezoidal Intuitionistic Fuzzy Numbers
collection = [
[(1, 2, 3, 4), 0.3, 0.2],
[(1, 2, 2.5, 4.5), 0.5, 0.1],
[(0, 1, 2, 3), 0.7, 0.3],
[(3, 4, 5, 6), 0.4, 0.3]
]
# Sort TIFNs
print(sort_tifns(collection))
# Get max and min TIFNs
print(min_tifns(collection))
print(max_tifns(collection))
Example 7: Hamming and Euclidean Distance
A1 = [(1, 2, 3, 4), 0.612, 0.2]
A2 = [(2, 3, 4, 5), 0.43, 0.3]
# Calculate Hamming distance
print(round(hamming_distance(A1, A2), 3))
# Calculate Euclidean distance
print(round(euclidean_distance(A1, A2), 3))
Example 8: α-cut and β-cut Intervals
A = [(1, 2, 3, 4), 0.6, 0.2]
print(alpha_cut(A))
print(beta_cut(A))
Example 9: α-cut and β-cut Values
A = [(1, 2, 3, 4), 0.6, 0.2]
alpha_result = alpha_cut(A, 0.5)
beta_result = beta_cut(A, 0.5)
print([round(value, 2) for value in alpha_result])
print([round(value, 2) for value in beta_result])
Example 10: Possibilistic Statistics
A1 = [(1, 2, 3, 4), 0.7, 0.2]
A2 = [(2, 3, 4, 5), 0.6, 0.3]
A3 = [(1.5, 2.5, 3.5, 4.5), 0.8, 0.1]
A4 = [(1, 2.5, 3.5, 4), 0.4, 0.2]
print(round(membership_mean(A1), 3))
print(round(nonmembership_mean(A1), 3))
print(round(membership_variance(A1), 3))
print(round(nonmembership_variance(A1), 3))
print(round(membership_covariance(A1, A2), 3))
print(round(nonmembership_covariance(A1, A2), 3))
Example 11: Credibilistic Statistics
A = [(1, 2, 4, 5), 0.6, 0.3]
x = 1.11
result = credibility_measure(x, A)
print(tuple(round(value, 3) for value in result))
print(round(membership_entropy(A), 3))
print(round(nonmembership_entropy(A), 3))
License
This project is licensed under the MIT License - see the MIT file for details.
Contact
For any inquiries, please contact:
- Nazanin Ghaemi-Zadeh at nghz.sut@gmail.com
Acknowledgments
Special thanks to contributors and developers who have supported the development of this package.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file poropto-0.1.0.tar.gz.
File metadata
- Download URL: poropto-0.1.0.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e61b2546b42e75e0849007718c0d0330bfb009789e81228aabcde34bbb27d4c
|
|
| MD5 |
99077e756ebb5633aa4d44115e412f12
|
|
| BLAKE2b-256 |
c6719790bb3dfe57fbc8a971387d5b3b03891d4fd6813bebfff732e3f0df817a
|
File details
Details for the file poropto-0.1.0-py3-none-any.whl.
File metadata
- Download URL: poropto-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71fe587d34a845568b3dde188f765ffb39f7b230580017117d867dc8f5fbfde6
|
|
| MD5 |
f152a90a695d2f74b721d8bd3bc95fef
|
|
| BLAKE2b-256 |
23863e2c85d4bd41e0f686cbede014133998f18a1aa205f56c914764bc459820
|