investment ========== .. py:module:: investment .. autoapi-nested-parse:: Climate-economics environment: Discrete investment options Attributes ---------- .. autoapisummary:: investment.CHOICES investment.SECTORS investment.TAGS investment.TECHS investment.AMOUNTS investment.ALLOWED_SECTOR2TAGS investment.ALLOWED_TAG2SECTOR investment.ALLOWED_SECTOR2TECH investment.ALLOWED_TAG2TECH Classes ------- .. autoapisummary:: investment.InvestmentDiscrete Module Contents --------------- .. py:data:: CHOICES :value: ('SECTOR', 'TAG', 'TECH', 'AMOUNT') .. py:data:: SECTORS :value: ('POWER', 'ENERGY', 'VEHICLES', 'STORAGE', 'DAC') .. py:data:: TAGS :value: ('GREEN', 'BROWN', 'CCS') .. py:data:: TECHS :value: ('power_COAL_noccs', 'power_COAL_ccs', 'power_NUCLEAR', 'power_OIL', 'power_GAS_noccs',... .. py:data:: AMOUNTS :value: ('HIGH', 'MEDIUM', 'LOW', 'NONE') .. py:data:: ALLOWED_SECTOR2TAGS .. py:data:: ALLOWED_TAG2SECTOR .. py:data:: ALLOWED_SECTOR2TECH .. py:data:: ALLOWED_TAG2TECH .. py:class:: InvestmentDiscrete(sectors = None, tags = None, techs = None, amounts = None, **kwargs) Bases: :py:obj:`gflownet.envs.base.GFlowNetEnv` Base class of GFlowNet environments .. py:attribute:: choices :value: ('SECTOR', 'TAG', 'TECH', 'AMOUNT') .. py:attribute:: n_sectors .. py:attribute:: n_tags .. py:attribute:: n_techs .. py:attribute:: n_amounts .. py:attribute:: idx2token_choices .. py:attribute:: token2idx_choices .. py:attribute:: idx2token_sectors .. py:attribute:: token2idx_sectors .. py:attribute:: idx2token_tags .. py:attribute:: token2idx_tags .. py:attribute:: idx2token_techs .. py:attribute:: token2idx_techs .. py:attribute:: idx2token_amounts .. py:attribute:: token2idx_amounts .. py:attribute:: source .. py:attribute:: network_structure .. py:attribute:: eos .. py:method:: get_action_space() Constructs list with all possible actions, including eos. An action is represented by a two-element tuple: the first element is the index of the element of the dictionary (state) to be changed; the second element is the value used to update the state. For example, action (3, 2) sets for choice 3 (technology) the value at index 2 (coal power with CCS), starting from index 1. .. py:method:: get_mask_invalid_actions_forward(state = None, done = None) Returns a list of length the action space with values: - True if the forward action is invalid from the current state. - False otherwise. :param state: Input state. If None, self.state is used. :type state: dict :param done: Whether the trajectory is done. If None, self.done is used. :type done: bool :returns: *A list of boolean values.* .. py:method:: get_parents(state = None, done = None, action = None) Determines all parents and actions that lead to state. :param state: Input state. If None, self.state is used. :type state: dict :param done: Whether the trajectory is done. If None, self.done is used. :type done: bool :param action: Ignored :type action: None :returns: * **parents** (*list*) -- List of parents in environment format. * **actions** (*list*) -- List of actions that lead to state for each parent in parents. .. py:method:: step(action, skip_mask_check = False) Executes step given an action. :param action: Action to be executed. :type action: tuple :param skip_mask_check: If True, skip computing forward mask of invalid actions to check if the action is valid. :type skip_mask_check: bool :returns: * **self.state** (*dict*) -- The sequence after executing the action * **action** (*tuple*) -- Action executed * **valid** (*bool*) -- False, if the action is not allowed for the current state. .. py:method:: states2proxy(states) Prepares a batch of states in "environment format" for a proxy: the batch is simply converted into a tensor of indices. :param states: A batch of states in environment format, either as a list of states or as a list of tensors. :type states: list or tensor :returns: *A list containing all the states in the batch, represented themselves as lists.* .. py:method:: states2policy(states) Prepares a batch of states in "environment format" for the policy model: states are one-hot encoded. :param states: A batch of states in environment format, either as a list of states or as a list of tensors. :type states: list or tensor :returns: *A tensor containing all the states in the batch.* .. py:method:: state2readable(state = None) Converts a state into a human-readable string. The output string contains the letter corresponding to each index in the state, separated by spaces. :param states: A state in environment format. If None, self.state is used. :type states: tensor :returns: *A string of space-separated letters.* .. py:method:: readable2state(readable) Converts a state in readable format into the environment format (dict of indices). :param readable: A state in readable format, with fields separated by " | ". Example: "POWER | UNASSIGNED_TAG | power_HYDRO | HIGH" :type readable: str :returns: *dict* -- A state dictionary with indices for SECTOR, TAG, TECH, and AMOUNT. .. py:method:: get_uniform_terminating_states(n_states, seed = None) Constructs a batch of n states uniformly sampled in the sample space of the environment. :param n_states: The number of states to sample. :type n_states: int :param seed: Random seed. :type seed: int .. py:method:: well_defined_investment(state = None) .. py:method:: get_assigned_attributes(state = None)