gfn.gym.set_addition ==================== .. py:module:: gfn.gym.set_addition Classes ------- .. autoapisummary:: gfn.gym.set_addition.SetAddition Module Contents --------------- .. py:class:: SetAddition(n_items, max_items, reward_fn, fixed_length = False, device = None, debug = False) Bases: :py:obj:`gfn.env.DiscreteEnv` Append only MDP, similarly to what is described in Remark 8 of Shen et al. 2023 [Towards Understanding and Improving GFlowNet Training](https://proceedings.mlr.press/v202/shen23a.html) The state is a binary vector of length `n_items`, where 1 indicates the presence of an item. Actions are integers from 0 to `n_items - 1` to add the corresponding item, or `n_items` to exit. Adding an existing item is invalid. The trajectory must end when `max_items` are present. Recommended preprocessor: `IdentityPreprocessor`. .. attribute:: n_items The number of items in the set. :type: int .. attribute:: max_items The maximum number of items that can be added to the set. :type: int .. attribute:: reward_fn The reward function. :type: Callable .. attribute:: fixed_length Whether the trajectories have a fixed length. :type: bool .. py:attribute:: States :type: type[gfn.env.DiscreteStates] .. py:property:: all_states :type: gfn.env.DiscreteStates Returns all the states of the environment. .. py:method:: backward_step(states, actions) Performs a backward step in the environment. :param states: The current states. :param actions: The actions to take. :returns: The previous states. .. py:attribute:: fixed_length :value: False .. py:method:: get_states_indices(states) Returns the indices of the states. :param states: The states to get the indices of. :returns: The indices of the states. .. py:method:: make_states_class() Returns the DiscreteStates class for the SetAddition environment. .. py:attribute:: max_traj_len .. py:attribute:: n_items .. py:method:: reward(final_states) Computes the reward for a batch of final states. :param final_states: The final states. :returns: The reward of the final states. .. py:attribute:: reward_fn .. py:method:: step(states, actions) Performs a step in the environment. :param states: The current states. :param actions: The actions to take. :returns: The next states. .. py:property:: terminating_states :type: gfn.env.DiscreteStates Returns the terminating states of the environment.