gflownet.envs.constant ====================== .. py:module:: gflownet.envs.constant .. autoapi-nested-parse:: Base class for constant environments: simple, helper environment where the source state is the final state and the only valid action is EOS. Classes ------- .. autoapisummary:: gflownet.envs.constant.Constant Module Contents --------------- .. py:class:: Constant(state, **kwargs) Bases: :py:obj:`gflownet.envs.base.GFlowNetEnv` Constant environment. states2policy, states2proxy, states2readable and readable2state are not implemented in this meta-class. Depending on the state, the default methods may work or not. .. attribute:: state The state which will be set as constant, that is as source and final state. :type: list, dict, tensor, array .. py:attribute:: source .. py:attribute:: eos :value: (0,) .. py:method:: get_action_space() Constructs list with all possible actions, including eos. The action space consists of the EOS action only. .. 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. The only possible action (EOS) is only valid if the environmet is not done. :param state: Ignored. :type state: list, dict, tensor, array :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. If the environment is done, the only parent is the state, with EOS action. Otherwise, the source state has no parents, like all environments. :param state: Input state. If None, self.state is used. :type state: list, dict, tensor, array :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 state format. This environment has a single parent per state. * **actions** (*list*) -- List of actions that lead to state for each parent in parents. This environment has a single parent per state. .. 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: Ignored. :type skip_mask_check: bool :returns: * **self.state** (*list, dict, tensor, array*) -- The state after executing the action * **action** (*tuple*) -- Action executed * **valid** (*bool*) -- False, if the action is not allowed for the current state.