Пример #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._param.get_annual_state_cost(
            current_state) * self._param.get_delta_t()
        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)
                         ) * self._param.get_delta_t()
        if current_state == P.HealthStats.CD4_200 and next_state != P.HealthStats.CD4_200:
            cost = cost + 600 + (36.73 + 49.11)
        if current_state == P.HealthStats.CD4_200to500:
            cost += 32.68
        # add the cost of treatment
        # if HIV death will occur
        if next_state in [P.HealthStats.DEATH]:
            cost += 0.5 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        else:
            cost += 1 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()

        # update total discounted cost and utility (corrected for the half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._param.get_adj_discount_rate() / 2, 2*k + 1)
        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._param.get_adj_discount_rate() / 2, 2*k + 1)
Пример #2
0
    def simulate(self, sim_length):
        """ simulate the patient over the specified simulation length """

        # random number generator for this patient
        self._rng = rndClasses.RNG(self._id)

        k = 0  # current time step

        # while the patient is alive and simulation length is not yet reached
        while (self.healthstat != 3
               or self.healthstat != 4) and k * delta_t < sim_length:
            # find the transition probabilities of the future states
            trans_probs = TRANS[self.THERAPY][self.healthstat]
            # create an empirical distribution
            empirical_dist = rndClasses.Empirical(trans_probs)
            # sample from the empirical distribution to get a new state
            # (returns an integer from {0, 1, 2, ...})
            new_state_index = empirical_dist.sample(self._rng)
            if self.healthstat == 1:
                self.STROKE += 1
            #caculate cost and utality
            cost = TRANS_COST[self.THERAPY][self.healthstat] * delta_t
            utility = TRANS_UTILITY[self.THERAPY][self.healthstat] * delta_t
            # update total discounted cost and utility (corrected for the half-cycle effect)
            self.totalDiscountCost += \
                EconCls.pv(cost, Discount_Rate*delta_t, k + 1)
            self.totalDiscountUtility += \
                EconCls.pv(utility, Discount_Rate*delta_t, k + 1)
            # update health state
            self.healthstat = new_state_index[0]
            # increment time step
            k += 1
        self.survival = k * delta_t
    def update(self, k, current_state, next_state):

        #update costs
        cost = 0.5*(self._param.get_annual_state_cost(current_state)+(self._param.get_annual_state_cost(next_state))) \
               * self._param.get_delta_t()
        #update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         (self._param.get_annual_state_utility(next_state))
                         ) * self._param.get_delta_t()

        #add the cost of treatment
        # if stroke death will occur
        if next_state in [P.HealthStats.DEATH, P.HealthStats.BACKGROUND_DEATH]:
            cost += 0.5 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        else:
            cost += 1 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()

        # update total discounted cost and utility (correct for the half-cycle effect)
        self._totalDiscountedCost += EconCls.pv(
            cost,
            self._param.get_adj_discount_rate() / 2, 2 * k + 1)
        self._totalDiscountedUtility += EconCls.pv(
            utility,
            self._param.get_adj_discount_rate() / 2, 2 * k + 1)
Пример #4
0
    def update(self, k, current_state, next_state):

        # update cost
        cost = 0.5 * (self._parameters.get_annual_state_cost(current_state) +
                      self._parameters.get_annual_state_cost(next_state)
                      ) * self._parameters.get_delta_t()

        # update utility
        utility = 0.5 * (
            self._parameters.get_annual_state_utility(current_state) +
            self._parameters.get_annual_state_utility(next_state)
        ) * self._parameters.get_delta_t()

        # add cost of treatment
        if next_state in [Parameters.HealthStates.DEAD]:
            cost += 0.5 * self._parameters.get_annual_treatment_cost(
            ) * self._parameters.get_delta_t()
        else:
            cost += 1 * self._parameters.get_annual_treatment_cost(
            ) * self._parameters.get_delta_t()

        # update total discounted cost and utility (corrected for half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._parameters.get_adj_discount_rate() / 2, 2*k + 1)
        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._parameters.get_adj_discount_rate() / 2, 2*k + 1)
Пример #5
0
    def update(self, k, current_state, next_state):

        # update cost
        cost = 0
        if next_state in [P.HealthStats.STROKE]:
            cost += Data.COST_STROKE

        # update cost of state
        else:
            cost += 0.5 * (self._param.get_annual_state_costs(current_state) +
                           self._param.get_annual_state_costs(next_state)
                           ) * self._param.get_delta_t()

        # add cost of drug treatment
        if next_state in [P.HealthStats.POST_STROKE]:
            cost += self._param.get_annual_drug_cost(
            ) * self._param.get_delta_t()

        # update utility
        utility = 0.5 * (self._param.get_annual_state_utilities(current_state)
                         + self._param.get_annual_state_utilities(next_state)
                         ) * self._param.get_delta_t()

        # update total discounted cost and utility
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._param.get_adj_discount_rate() / 2, 2*k + 1)
        self._totalDiscountedUtil += \
            EconCls.pv(utility, self._param.get_adj_discount_rate() / 2, 2*k + 1)
    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._param.get_annual_state_cost(current_state) +
                      self._param.get_annual_state_cost(next_state)
                      ) * self._param.get_delta_t()
        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)
                         ) * self._param.get_delta_t()

        # add the cost of treatment
        # if HIV death will occur
        if next_state in [P.HealthStats.STROKEDEATH]:
            cost += 0.5 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        else:
            cost += 1 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()

        # update total discounted cost and utility (corrected for the half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._param.get_adj_discount_rate() / 2, 2*k + 1)
        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._param.get_adj_discount_rate() / 2, 2*k + 1)
Пример #7
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 = 0.5 * (self._param.get_annual_state_cost(current_state) +
                      self._param.get_annual_state_cost(next_state)
                      ) * self._param.get_delta_t()

        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)
                         ) * self._param.get_delta_t()

        # treatment cost (incurred only in post-stroke state)
        if current_state is P.HealthStats.TREATMENT:
            if next_state is [P.HealthStats.DEAD]:
                cost += 0.5 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()
            else:
                cost += 1 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()

        # update total discounted cost and utility (NOT corrected for the half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost,self._param.get_adj_discount_rate(), k)
        self._totalDiscountedUtility += \
            EconCls.pv(utility,self._param.get_adj_discount_rate(), k)
Пример #8
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 = 0.5 * (self._param.get_annual_state_cost(current_state) +
                      self._param.get_annual_state_cost(next_state)) * self._param.get_delta_t()
        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)) * self._param.get_delta_t()

         # add the cost of treatment
        # if DEATH will occur
        if next_state in [HealthStats.STROKEDEATH] or next_state in [HealthStats.OTHERDEATH] and current_state in [HealthStats.POSTSTROKE]:
            cost += 0.5 * self._param.get_annual_treatment_cost() * self._param.get_delta_t()
        elif next_state in [HealthStats.STROKE] and (current_state in [HealthStats.POSTSTROKE] or current_state in [HealthStats.WELL]):
            cost += 5000
        elif current_state in [HealthStats.POSTSTROKE]:
            cost += 1 * self._param.get_annual_treatment_cost() * self._param.get_delta_t()

         # update total discounted cost and utility (removed the half-cycle effect)
        self._totalDiscountedCost += \
            Econ.pv(cost, self._param.get_adj_discount_rate() / 2, k + 1)
        self._totalDiscountedUtility += \
            Econ.pv(utility, self._param.get_adj_discount_rate() / 2, k + 1)
Пример #9
0
    def update(self, k, current_state, next_state):
        cost = (self._param.get_annual_state_cost(current_state)+(self._param.get_annual_state_cost(next_state))) \
               * self._param.get_delta_t()

        utility = (self._param.get_annual_state_utility(current_state) +
                         (self._param.get_annual_state_utility(next_state))) * self._param.get_delta_t()
        if next_state in [P.HealthStats.DEAD, P.HealthStats.STROKE_DEAD]:
            cost += self._param.get_annual_treatment_cost() * self._param.get_delta_t()
        else:
            cost += 1*self._param.get_annual_treatment_cost() * self._param.get_delta_t()
        self._totalDiscountedCost += EconCls.pv(payment=cost, discount_rate=self._param.get_adj_discount_rate(), discount_period=k+1)
        self._totalDiscountedUtility += EconCls.pv(payment=utility, discount_rate=self._param.get_adj_discount_rate(), discount_period=k+1)
Пример #10
0
    def update(self, k, current_state, next_state):
        cost = 0.5*(self._param.get_annual_state_cost(current_state)+(self._param.get_annual_state_cost(next_state))) \
               * self._param.get_delta_t()

        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         (self._param.get_annual_state_utility(next_state))) * self._param.get_delta_t()
        if next_state is P.HealthStats.DEATH:
            cost += 0.5*self._param.get_annual_treatment_cost() * self._param.get_delta_t()
        else:
            cost += 1*self._param.get_annual_treatment_cost() * self._param.get_delta_t()
        self._totalDiscountedCost += EconCls.pv(cost, self._param.get_adj_discount_rate()/2, 2*k+1)
        self._totalDiscountedUtility += EconCls.pv(utility, self._param.get_adj_discount_rate()/2, 2*k+1)
Пример #11
0
    def update(self, k, current_state, next_state):
        cost = self._param.get_annual_state_cost(
            current_state) * self._param.get_delta_t()

        utility = self._param.get_annual_state_utility(
            current_state) * self._param.get_delta_t()

        self._totalDiscountedCost += EconCls.pv(
            cost,
            self._param.get_adj_discount_rate() / 2, 2 * k + 1)
        self._totalDiscountedUtility += EconCls.pv(
            utility,
            self._param.get_adj_discount_rate() / 2, 2 * k + 1)
Пример #12
0
    def update(self, k, current_state, next_state):

        # state cost and utility
        cost = 0.5*(self._param.get_annual_state_cost(current_state)
                    +(self._param.get_annual_state_cost(next_state))) * self._param.get_delta_t()

        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         (self._param.get_annual_state_utility(next_state))) * self._param.get_delta_t()

        # treatment cost (incurred only in post-stroke state)
        #if current_state is P.HealthStats.POST_STROKE:
        #    if next_state is P.HealthStats.DEATH:
        #        cost += 0.5*self._param.get_annual_treatment_cost() * self._param.get_delta_t()
        #    else:
        #        cost += 1*self._param.get_annual_treatment_cost() * self._param.get_delta_t()

        self._totalDiscountedCost += EconCls.pv(cost, self._param.get_adj_discount_rate()/2, 2*k+1)
        self._totalDiscountedUtility += EconCls.pv(utility, self._param.get_adj_discount_rate()/2, 2*k+1)
Пример #13
0
    def update(self, k, current_state, next_state):

        # update cost
        cost = 0.5 * (self._param.get_annual_state_cost(current_state) +
                      (self._param.get_annual_state_cost(next_state))
                      ) * self._param.get_delta_t()
        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         (self._param.get_annual_state_utility(next_state))
                         ) * self._param.get_delta_t()

        # treatment cost (incurred only in post-stroke state)
        if current_state is P.HealthStats.POST_TIA:
            if next_state is P.HealthStats.DEAD_OTHER or next_state is P.HealthStats.DEAD_STROKE:
                cost += 0.5 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()
            else:
                cost += 1 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()

        if current_state is P.HealthStats.POST_MILD_STROKE:
            if next_state is P.HealthStats.DEAD_OTHER or next_state is P.HealthStats.DEAD_STROKE:
                cost += 0.5 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()
            else:
                cost += 1 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()

        if current_state is P.HealthStats.POST_MODERATE_SEVERE_STROKE:
            if next_state is P.HealthStats.DEAD_OTHER or next_state is P.HealthStats.DEAD_STROKE:
                cost += 0.5 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()
            else:
                cost += 1 * self._param.get_annual_treatment_cost(
                ) * self._param.get_delta_t()

        # update total discounted cost and utility
        self._totalDiscountedCost += EconCls.pv(
            cost, self._param.get_adj_discount_rate(), k)
        self._totalDiscountedUtility += EconCls.pv(
            utility, self._param.get_adj_discount_rate(), k)
Пример #14
0
    def update(self, k, current_state, next_state):

        # update cost
        cost = 0.5 * (self._parameters.get_annual_state_cost(current_state) +
                      self._parameters.get_annual_state_cost(next_state)
                      ) * self._parameters.get_delta_t()

        # update utility
        utility = 0.5 * (
            self._parameters.get_annual_state_utility(current_state) +
            self._parameters.get_annual_state_utility(next_state)
        ) * self._parameters.get_delta_t()

        # add cost of screening
        cost += self._parameters.get_screening_cost()

        # update total discounted cost and utility (corrected for half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._parameters.get_adj_discount_rate() / 2, 2*k + 1)
        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._parameters.get_adj_discount_rate() / 2, 2*k + 1)
    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._param.get_annual_state_cost(current_state) +
                      self._param.get_annual_state_cost(next_state)
                      ) * self._param.get_delta_t()

        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)
                         ) * self._param.get_delta_t()

        # add the cost of treatment
        # if DEAD will occur
        if current_state is P.HealthStats.WELL:
            cost += 0 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        elif current_state is P.HealthStats.BACKGROUND_DEATH:
            cost += 0 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        elif current_state is P.HealthStats.STROKE_DEATH:
            cost += 0 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        elif current_state is P.HealthStats.STROKE:
            cost += 0 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()
        else:
            cost += 1 * self._param.get_annual_treatment_cost(
            ) * self._param.get_delta_t()

        # update total discounted cost and utility (NOT corrected for the half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost,self._param.get_adj_discount_rate(), k)
        self._totalDiscountedUtility += \
            EconCls.pv(utility,self._param.get_adj_discount_rate(), k)
Пример #16
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._param.get_annual_state_cost(
            current_state) * self._param.get_delta_t()
        # update utility
        utility = self._param.get_annual_state_utility(
            current_state) * self._param.get_delta_t()

        if next_state in [P.HealthStats.WELL]:
            utility += 1 * (Data.SIM_LENGTH - k)

        # update total discounted cost and utility (corrected for the half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._param.get_adj_discount_rate() / 2, 2*k + 1)
        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._param.get_adj_discount_rate() / 2, 2*k + 1)
Пример #17
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 = 0.5 * (self._param.get_annual_state_cost(current_state) +
                      self._param.get_annual_state_cost(next_state)) * self._param.get_delta_t()
        # update utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)) * self._param.get_delta_t()

        # add the cost of treatment
        # if stroke will occur
        if self._currentState == P.HealthStats.STROKE:
            cost += self._param.get_onetime_Stroke_cost()

        # update total discounted cost and utility (corrected for the half-cycle effect)
        self._totalDiscountedCost += \
            EconCls.pv(cost, self._param.get_adj_discount_rate(), k)
        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._param.get_adj_discount_rate(), k)
Пример #18
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 utility
        utility = 0.5 * (self._param.get_annual_state_utility(current_state) +
                         self._param.get_annual_state_utility(next_state)
                         ) * self._param.get_delta_t()

        # update total discounted cost and utility (corrected for the half-cycle effect)

        self._totalDiscountedUtility += \
            EconCls.pv(utility, self._param.get_adj_discount_rate() / 2, 2*k + 1)
Пример #19
0
    def simulate_fiveshort(self, sim_length_short):
        """ simulate the patient over the specified simulation length """

        # random number generator for this patient
        self._rng = rndClasses.RNG(self._id)

        if self.vaccine == 0:
            k = 0
            # while the patient is alive and simulation length is not yet reached
            while (self.healthstat != 8) and k * ma.delta_t < sim_length_short:
                # find the transition probabilities of the future states
                trans_probs = ma.prob_matrix[0][self.healthstat]
                # create an empirical distribution
                empirical_dist = rndClasses.Empirical(trans_probs)
                # sample from the empirical distribution to get a new state
                # (returns an integer from {0, 1, 2, ...})
                new_state_index = empirical_dist.sample(self._rng)
                # caculate cost and utality
                cost = ma.cost_matrix[
                    self.
                    healthstat] + ma.salary * ma.work_loss_day[self.healthstat]
                utility = ma.utility_matrix[self.healthstat] * ma.delta_t
                # update total discounted cost and utility (corrected for the half-cycle effect)
                self.totalDiscountCost += \
                    EconCls.pv(cost, ma.discount_rate * ma.delta_t, k + 1)
                self.totalDiscountUtility += \
                    EconCls.pv(utility, ma.discount_rate * ma.delta_t, k + 1)
                # update diseases:
                if self.healthstat == HealthStats.Pneumoniae.value:
                    self.pneumonaie += 1
                if self.healthstat == HealthStats.Meningitis.value:
                    self.meningitis += 1
                if self.healthstat == HealthStats.AOM_T.value or self.healthstat == HealthStats.AOM_NT.value:
                    self.aom += 1
                # update disability number
                if self.healthstat == HealthStats.Disability.value:
                    self._ndisability = 1
                # update deafness number
                if self.healthstat == HealthStats.Deaf.value:
                    self._ndeaf = 1
                # update health state
                self.healthstat = new_state_index[0]
                #update number of deahts
                if self.healthstat == HealthStats.DEATH.value:
                    self._ndeath = 1
                # increment time step
                k += 1
        if self.vaccine == 1:
            k = 0
            while (self.healthstat != 8) and k * ma.delta_t < sim_length_short:
                # find the transition probabilities of the future states
                trans_probsv = ma.prob_matrix_vaccine[0][self.healthstat]
                # create an empirical distribution
                empirical_distv = rndClasses.Empirical(trans_probsv)
                # sample from the empirical distribution to get a new state
                # (returns an integer from {0, 1, 2, ...})
                new_state_indexv = empirical_distv.sample(self._rng)
                # caculate cost and utality
                cost = ma.cost_matrix[
                    self.
                    healthstat] + ma.salary * ma.work_loss_day[self.healthstat]
                utility = ma.utility_matrix[self.healthstat] * ma.delta_t
                # update total discounted cost and utility (corrected for the half-cycle effect)
                self.totalDiscountCost += \
                    EconCls.pv(cost, ma.discount_rate * ma.delta_t, k + 1)
                self.totalDiscountUtility += \
                    EconCls.pv(utility, ma.discount_rate * ma.delta_t, k + 1)
                # update diseases:
                if self.healthstat == HealthStats.Pneumoniae.value:
                    self.pneumonaie += 1
                if self.healthstat == HealthStats.Meningitis.value:
                    self.meningitis += 1
                if self.healthstat == HealthStats.AOM_T.value or self.healthstat == HealthStats.AOM_NT.value:
                    self.aom += 1
                # update disability number
                if self.healthstat == HealthStats.Disability.value:
                    self._ndisability = 1
                # update deafness number
                if self.healthstat == HealthStats.Deaf.value:
                    self._ndeaf = 1
                # update health state
                self.healthstat = new_state_indexv[0]
                #update number of deahts
                if self.healthstat == HealthStats.DEATH.value:
                    self._ndeath = 1

                if k == 3:
                    self.shot += 1
                    self.totalDiscountCost+= \
                        EconCls.pv(ma.vaccine_administration+ma.vaccine_cost, ma.discount_rate * ma.delta_t, k + 1)
                if k == 5:
                    self.shot += 1
                    self.totalDiscountCost+= \
                        EconCls.pv(ma.vaccine_administration+ma.vaccine_cost, ma.discount_rate * ma.delta_t, k + 1)
                if k == 11:
                    self.shot += 1
                    self.totalDiscountCost+= \
                        EconCls.pv(ma.vaccine_administration+ma.vaccine_cost, ma.discount_rate * ma.delta_t, k + 1)

                # increment time step
                k += 1
        if self.healthstat == 3:
            for i in (6, 16):
                self.totalDiscountCost += EconCls.pv(2746, ma.discount_rate,
                                                     i + 1)