-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheconomic-service-life.py
66 lines (49 loc) · 1.79 KB
/
economic-service-life.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#This script is used to calculate the economic useful life of a assets
#Author: Osvaldo Fernández
#######################################################
#####################Factors Functions#################
#######################################################
def aGivenP(i: float, n: int) -> float:
return (i * (1 + i) ** n )/( (1 + i) ** n - 1 )
def aGivenF(i: float, n: int) -> float:
return i/( (1 + i) ** n - 1 )
def pGivenF(i: float, n: int) -> float:
return 1/( (1 + i) ** n )
#######################################################
#######################################################
#######################################################
#######################################################
#######################SCRIPT##########################
#######################################################
#Interest rate
interest = 0.10
#Initial Cost
P = 13000
#Commercial values
VC = [9000, 8000, 6000, 2000, 0]
#Annual cost of operation
CAO = [2500, 2700, 3000, 3500, 4500]
#Years of studies
N = len(VC)
#Anual values
VA = []
#Minimal anual value
minVA = -P
#Year with minimun anual value
utilLifeYears = 0
for k in range(N):
#Annual operating cost at year zero
VCAO = 0
for j in range(k + 1):
VCAO = VCAO + CAO[j] * pGivenF(interest, j + 1)
#Formula for VA
VAaux = -P * aGivenP(interest, k + 1) + VC[k] * aGivenF(interest, k + 1) - VCAO * aGivenP(interest, k + 1)
#Adding to annual values VA
VA.append(round(VAaux, 2))
#Checking if it is the year with the lowest VA (VUE)
if abs(VAaux) <= abs(minVA):
minVA = abs(VAaux)
utilLifeYears = k + 1
#Results
print("Anual values = " + str(VA))
print("Economic useful life = " + str(utilLifeYears) + " years")