epidemioptim/environments/cost_functions/one_cost_death.py
def compute_cost(self, previous_state, state, label_to_id, action, others={}):
        """
        Compute each cost and an aggregated measure of costs as well as constraints.

        Parameters
        ----------
        previous_state: 2D nd.array
            Previous model states (either 1D or 2D with first dimension # of states).
        state: 2D nd.array
            Current model states (either 1D or 2D with first dimension # of states).
        label_to_id: dict
            Mapping between state labels and indices in the state vector.
        action: int or nd.array
            Int for discrete envs and nd.array in continuous envs.

        Returns
        -------
        cost_aggregated: float
            Aggregated cost using the beta mixing parameter.
        costs: list of floats
            All costs.
        over_constraints: list of bools
            Whether the constraints are violated.
        """
        previous_state = np.atleast_2d(previous_state)
        state = np.atleast_2d(state)

        # compute costs
        costs = np.array([c.compute_cost(previous_state, state, label_to_id, action, others) for c in self.costs]).transpose()
        cumulative_costs = np.array([c.compute_cumulative_cost(previous_state, state, label_to_id, action, others) for c in self.costs]).transpose()

        # Apply constraints
        cost_aggregated = self.compute_aggregated_cost(costs.copy())
        over_constraints = 0#np.atleast_2d([False] * state.shape[0]).transpose()
        return cost_aggregated, costs, over_constraints

        Compute each cost and an aggregated measure of costs as well as constraints.

        Parameters
        ----------
        previous_state: 2D nd.array
            Previous model states (either 1D or 2D with first dimension # of states).
        state: 2D nd.array
            Current model states (either 1D or 2D with first dimension # of states).
        label_to_id: dict
            Mapping between state labels and indices in the state vector.
        action: int or nd.array
            Int for discrete envs and nd.array in continuous envs.

        Returns
        -------
        cost_aggregated: float
            Aggregated cost using the beta mixing parameter.
        costs: list of floats
            All costs.
        over_constraints: list of bools
            Whether the constraints are violated.
        
Compute each cost and an aggregated measure of costs as well as constraints.
Parameters

2D nd.array
Previous model states (either 1D or 2D with first dimension # of states).
state: 2D nd.array
Current model states (either 1D or 2D with first dimension # of states).
label_to_id: dict
Mapping between state labels and indices in the state vector.
action: int or nd.array
Int for discrete envs and nd.array in continuous envs.

Returns

float
Aggregated cost using the beta mixing parameter.
costs: list of floats
All costs.
over_constraints: list of bools
Whether the constraints are violated.
Compute each cost and an aggregated measure of costs as well as constraints . Parameters 2D nd . array Previous model states ( either 1D or 2D with first dimension # of states ) . state : 2D nd . array Current model states ( either 1D or 2D with first dimension # of states ) . label_to_id : dict Mapping between state labels and indices in the state vector . action : int or nd . array Int for discrete envs and nd . array in continuous envs . Returns float Aggregated cost using the beta mixing parameter . costs : list of floats All costs . over_constraints : list of bools Whether the constraints are violated .
def compute_cost(self, previous_state, state, label_to_id, action, others={}):
        previous_state = np.atleast_2d(previous_state)
        state = np.atleast_2d(state)
        costs = np.array([c.compute_cost(previous_state, state, label_to_id, action, others) for c in self.costs]).transpose()
        cumulative_costs = np.array([c.compute_cumulative_cost(previous_state, state, label_to_id, action, others) for c in self.costs]).transpose()
        cost_aggregated = self.compute_aggregated_cost(costs.copy())
        over_constraints = 0
        return cost_aggregated, costs, over_constraints
def compute_cost ( self , previous_state , state , label_to_id , action , others = { } ) : previous_state = np . atleast_2d ( previous_state ) state = np . atleast_2d ( state ) costs = np . array ( [ c . compute_cost ( previous_state , state , label_to_id , action , others ) for c in self . costs ] ) . transpose ( ) cumulative_costs = np . array ( [ c . compute_cumulative_cost ( previous_state , state , label_to_id , action , others ) for c in self . costs ] ) . transpose ( ) cost_aggregated = self . compute_aggregated_cost ( costs . copy ( ) ) over_constraints = 0 return cost_aggregated , costs , over_constraints
Compute each cost and an aggregated measure of costs as well as constraints.
Compute each cost and an aggregated measure of costs as well as constraints .
"""
        Compute each cost and an aggregated measure of costs as well as constraints.

        Parameters
        ----------
        previous_state: 2D nd.array
            Previous model states (either 1D or 2D with first dimension # of states).
        state: 2D nd.array
            Current model states (either 1D or 2D with first dimension # of states).
        label_to_id: dict
            Mapping between state labels and indices in the state vector.
        action: int or nd.array
            Int for discrete envs and nd.array in continuous envs.

        Returns
        -------
        cost_aggregated: float
            Aggregated cost using the beta mixing parameter.
        costs: list of floats
            All costs.
        over_constraints: list of bools
            Whether the constraints are violated.
        """ # compute costs # Apply constraints #np.atleast_2d([False] * state.shape[0]).transpose()
self
previous_state
state
label_to_id
action
others