Está en la página 1de 4

Option Explicit

Dim comision(1 To 4), penalf(1 To 4), penale(1 To 4), prob(1 To 4, 1 To 8), precio(1 To 4), p1(1 To 3), p2(1
To 3), p3(1 To 3), demanda(1 To 8), p11(1 To 8)

Dim p12(1 To 8), p13(1 To 8)

Sub Preliminary_Definitions()

Call fillarray(comision, "{8,6,7}", 1)

Call fillarray(penalf, "{15,16,15}", 1)

Call fillarray(penale, "{25,22,20}", 1)

Call fillarray(prob,
"{{0,0.1,0.15,0.18,0.22,0.17,0.12,0.06},{0.05,0.12,0.16,0.20,0.25,0.15,0.07,0},{0.02,0.08,0.12,0.18,0.22,0.
15,0.12,0.11}}", 1, 1)

Call fillarray(precio, "{75,60,65}", 1)

Call fillarray(p1, "{0.0,0.05,0.02}", 1)

Call fillarray(p2, "{0.1,0.12,0.08}", 1)

Call fillarray(p3, "{0.15,0.16,0.12}", 1)

Call fillarray(demanda, "{0, 50, 100, 150, 200, 250, 300, 350}", 1)

Call fillarray(p11, "{0.0,0.1,0.15,0.18,0.22,0.17,0.12,0.06}", 1)

Call fillarray(p12, "{0.05,0.12,0.16,0.2,0.25,0.15,0.07,0}", 1)

Call fillarray(p13, "{0.02,0.08,0.12,0.18,0.22,0.15,0.12,0.11}", 1)

End Sub

Sub Model_Structure()

NSV = 2

NCT = 2

End Sub

Sub Starting_State()

s1 = 1
s2 = 600

End Sub

Sub Decision_Set()

DS = ivalset(0, 600, 100)

End Sub

Sub Transition_Function()

sn1 = s1 + 1

sn2 = s2 - d

End Sub

Sub State_Constraints()

Ct1 = sn1 <= 4

Ct2 = sn2 >= 0

End Sub

Sub Economic_Return()

ad(s) = 0

If s1 = 1 Then

If d <= demanda(s1) Then

ad(s) = ad(s) + ((-20 * d - comision(s1)) * d - penalf(s1) * (d - demanda(s1)) + precio(s1)) * p11(s1)

Else

ad(s) = ad(s) + ((-20 * d - comision(s1)) * d - penale(s1) * (-d + demanda(s1)) + precio(s1)) * p11(s1)

End If

End If

If s1 = 2 Then

If d <= demanda(s1) Then


ad(s) = ad(s) + ((-20 * d - comision(s1)) * d - penalf(s1) * (d - demanda(s1)) + precio(s1)) * p12(s1)

Else

ad(s) = ad(s) + ((-20 * d - comision(s1)) * d - penale(s1) * (-d + demanda(s1)) + precio(s1)) * p12(s1)

End If

End If

If s1 = 3 Then

If d <= demanda(s1) Then

ad(s) = ad(s) + ((-20 * d - comision(s1)) * d - penalf(s1) * (d - demanda(s1)) + precio(s1)) * p13(s1)

Else

ad(s) = ad(s) + ((-20 * d - comision(s1)) * d - penale(s1) * (-d + demanda(s1)) + precio(s1)) * p13(s1)

End If

End If

'ad(s) = definition of the economic return

End Sub

Sub Return_Function()

Rd(s) = ad(s) + f(sn)

End Sub

Sub Recursive_Equation()

f(s) = maxim(Rd(s))

End Sub

Sub Boundary_Conditions()

'p(s) = definition of the optimal policy in the boundary


'f(s) = definition of the optimal value function in the boundary

End Sub

También podría gustarte