Exemplo n.º 1
0
    def update(self, k, current_state, next_state):
        """ updates the discounted total cost and health utility
        :param k: simulation time step
        :param current_state: current health state
        :param next_state: next health state
        """

        # update cost
        cost = (self.params.annualTotalCosts[current_state.value] +
                self.params.annualTotalCosts[next_state.value])
        # # update utility
        # utility = 0.5 * (self.params.annualTotalUtility[current_state.value] +
        #                  self.params.annualTotalUtility[next_state.value])

        # add the cost of treatment
        if current_state == P.HealthStates.ACTIVE_TB and next_state == P.HealthStates.ACTIVE_TB:
            cost += 1 * self.params.annualTreatmentCost
        elif current_state == P.HealthStates.ACTIVE_TB and next_state == P.HealthStates.CURED or P.HealthStates.INCOMPLETE:
            cost += 0.5 * self.params.annualTreatmentCost

        # update total discounted cost and utility (corrected for the half-cycle effect)
        self.totalDiscountedCost += Econ.pv_single_payment(
            payment=cost,
            discount_rate=self.params.discountRate,
            discount_period=k + 1)
    def update(self, time, current_state, next_state):
        """ updates the discounted total cost and health utility
        :param time: simulation time
        :param current_state: current health state
        :param next_state: next health state
        """

        # cost and utility (per unit of time) during the period since the last recording until now
        cost = self.params.weeklyStateCosts[current_state.value]
        single_cost = self.params.singleCosts[current_state.value]

        # utility = self.params.weeklyStateUtilities[current_state.value]

        # discounted cost and utility (continuously compounded)
        discounted_cost = Econ.pv_continuous_payment(
            payment=cost,
            discount_rate=self.params.discountRate,
            discount_period=(self.tLastRecorded, time))
        # discounted_utility = Econ.pv_continuous_payment(payment=utility,
        #                                                 discount_rate=self.params.discountRate,
        #                                                 discount_period=(self.tLastRecorded, time))

        # discounted cost (single payment)
        discounted_cost += Econ.pv_single_payment(
            payment=single_cost,
            discount_rate=self.params.discountRate,
            discount_period=time,
            discount_continuously=True)

        # update total discounted cost and utility
        self.totalDiscountedCost += discounted_cost
        # self.totalDiscountedUtility += discounted_utility

        # update the time since last recording to the current time
        self.tLastRecorded = time
    def update(self, k, current_state, next_state):
        """ updates the discounted total cost and health utility
        :param k: simulation time step
        :param current_state: current health state
        :param next_state: next health state
        """

        # update cost
        cost = 0.5 * (self.params.annualStateCosts[current_state.value] +
                      self.params.annualStateCosts[next_state.value])
        # update utility
        # utility = 0.5 * (self.params.annualStateUtilities[current_state.value] +
        #                  self.params.annualStateUtilities[next_state.value])

        # add the cost of treatment
        # if Chron's death will occur, add the cost for half-year of treatment
        if next_state == P.HealthStates.DEATH:
            cost += 0.5 * self.params.annualTreatmentCost
        else:
            cost += 1 * self.params.annualTreatmentCost

        # update total discounted cost and utility (corrected for the half-cycle effect)
        self.totalDiscountedCost += Econ.pv_single_payment(
            payment=cost,
            discount_rate=self.params.discountRate / 2,
            discount_period=2 * k + 1)
Exemplo n.º 4
0
import SimPy.EconEvalClasses as Econ

print('Present value of $10 collected in year 20 at discount rate 5%:')
print(
    Econ.pv_single_payment(payment=10, discount_rate=0.05, discount_period=20))

print(
    '\nPresent value of $10 collected in year 20 at discount rate 5% (discounted continuously):'
)
print('These 2 numbers should be almost the same:')
print(
    Econ.pv_single_payment(payment=10,
                           discount_rate=0.05,
                           discount_period=20,
                           discount_continuously=True))
print(
    Econ.pv_single_payment(payment=10,
                           discount_rate=0.05 / 100,
                           discount_period=20 * 100,
                           discount_continuously=False))

print(
    '\nPresent value of a continuous payment of $10 over the period [10, 20] at discount rate 5%:'
)
print(
    Econ.pv_continuous_payment(payment=10,
                               discount_rate=0.05,
                               discount_period=(10, 20)))
print(
    '\nPresent value of a continuous payment of $10 over the period [10, 20] at discount rate 0%:'
)