Environment¶
Environment
¶
Partially Observable Markov Decision Process (POMDP) for combinatorial optimization.
Similar to Gymnasium, environments represent the task that an agent is supposed to solve. For maximum customizability, different components are composed/orchestrated in this class.
Source code in gyozas/environment.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 | |
__init__(instance_generator, observation_function=None, reward_function=None, information_function=None, scip_params=None, render_mode=None, dynamics=None, **dynamics_kwargs)
¶
Create a new environment object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance_generator
|
InstanceGenerator | Iterator[Model]
|
An iterator yielding PySCIPOpt Model instances to solve. |
required |
observation_function
|
An observation function used to customize the observation returned by
:meth: |
None
|
|
reward_function
|
A reward function used to customize the reward returned by :meth: |
None
|
|
information_function
|
An information function used to customize the additional information
returned by :meth: |
None
|
|
scip_params
|
Parameters set on the underlying SCIP Model at the start of every episode. |
None
|
|
render_mode
|
If set, enables rendering of the branching tree. |
None
|
|
dynamics
|
The dynamics controlling the MDP transitions. Defaults to BranchingDynamics. |
None
|
|
**dynamics_kwargs
|
Additional keyword arguments. |
{}
|
Source code in gyozas/environment.py
reset(**dynamics_kwargs)
¶
Start a new episode.
This method brings the environment to a new initial state, i.e. starts a new episode. The method can be called at any point in time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dynamics_kwargs
|
Extra arguments are forwarded to the underlying Dynamics. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
observation |
Any
|
The observation extracted from the initial state. |
action_set |
Any
|
An optional subset that defines which actions are accepted in the next transition. |
reward_offset |
float
|
An offset on the total cumulated reward, a.k.a. the initial reward. |
done |
bool
|
A boolean flag indicating whether the current state is terminal. |
info |
Any
|
A collection of environment specific information about the transition. |
Source code in gyozas/environment.py
step(action, **dynamics_kwargs)
¶
Transition from one state to another.
This method takes a user action to transition from the current state to the next. The method cannot be called if the environment has not been reset since its instantiation or since a terminal state has been reached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
The action to take as part of the Markov Decision Process. |
required | |
dynamics_kwargs
|
Extra arguments are forwarded to the underlying Dynamics. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
observation |
Any
|
The observation extracted from the new state. |
action_set |
Any
|
An optional subset that defines which actions are accepted in the next transition. |
reward |
float
|
A real number to use for reinforcement learning. |
done |
bool
|
A boolean flag indicating whether the current state is terminal. |
info |
Any
|
A collection of environment specific information about the transition. |
Source code in gyozas/environment.py
close()
¶
Close the environment and free resources.
Source code in gyozas/environment.py
seed(value)
¶
Set the random seed of the environment for reproducibility.
Seeds the dynamics' SCIP randomization and the instance generator
(if it exposes a seed method).