Environment API Reference
IsingEnvironment
Bases: BaseVecEnvironment[EnvState, EnvParams]
Ising environment for discrete energy-based models.
This environment is based on the paper https://arxiv.org/pdf/2202.01361.pdf.
The states are represented as 1d tensors of length ndim with values in
{-1, 0, 1}. s0 is empty (represented as -1), so s0=[-1, -1, ..., -1].
An action corresponds to replacing a -1 with a 0 or a 1.
Action i in [0, ndim - 1] corresponds to replacing s[i] with 0.
Action i in [ndim, 2 * ndim - 1] corresponds to replacing s[i - ndim] with 1.
NOTE: There is no exit action; the environment terminates when all spins are set.
Source code in gfnx/environment/ising.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
action_space
property
Action space of the environment.
backward_action_space
property
Backward action space of the environment.
name
property
Environment name.
observation_space
property
Observation space of the environment.
state_space
property
State space of the environment.
get_backward_action(state, forward_action, next_state, params)
Returns backward action given the forward transition.
Source code in gfnx/environment/ising.py
134 135 136 137 138 139 140 141 142 | |
get_forward_action(state, backward_action, prev_state, env_params)
Returns forward action given the backward transition.
Source code in gfnx/environment/ising.py
144 145 146 147 148 149 150 151 152 153 | |
get_invalid_backward_mask(state, params)
Get mask for a particular state to perform a backward action.
An action is invalid if there is no spin at the index of the action.
Source code in gfnx/environment/ising.py
168 169 170 171 172 173 | |
get_invalid_mask(state, env_params)
Get mask for a particular state to perform a forward action.
An action is invalid if there is already a spin (0 or 1) at the index of the action.
Mask is a concatenation of two masks: - mask for invalid forward actions for 0-spin - mask for invalid forward actions for 1-spin (identical to 0-spin)
Source code in gfnx/environment/ising.py
155 156 157 158 159 160 161 162 163 164 165 166 | |
get_obs(state, env_params)
Returns the lattice partial assignment of spins.
Source code in gfnx/environment/ising.py
130 131 132 | |