Overview
Policies define how agents select actions given states. Neurenix provides multiple policy types for different learning scenarios, supporting both discrete and continuous action spaces.Base Policy Class
All policies inherit from the basePolicy class:
neurenix/rl/policy.py:16
Key Methods
| Method | Description |
|---|---|
__call__(state) | Select action (calls select_action) |
select_action(state) | Core action selection logic |
step() | Update policy parameters (e.g., epsilon decay) |
reset() | Reset policy to initial state |
save(path) | Save policy to disk |
load(path) | Load policy from disk |
Random Policy
Selects actions uniformly at random from the action space:neurenix/rl/policy.py:84
Continuous Action Spaces
Greedy Policy
Selects the action with the highest value according to a value function:neurenix/rl/policy.py:124
Epsilon-Greedy Policy
Balances exploration and exploitation with epsilon parameter:neurenix/rl/policy.py:174
Exploration Schedule
The epsilon value decays over time:- Explores broadly early in training (high epsilon)
- Exploits learned knowledge later (low epsilon)
Softmax Policy
Selects actions according to a Boltzmann distribution:neurenix/rl/policy.py:240
Temperature Parameter
- High temperature (T >> 1): More uniform distribution (more exploration)
- Low temperature (T → 0): More peaked distribution (more exploitation)
Gaussian Policy
For continuous action spaces, samples from Gaussian distribution:neurenix/rl/policy.py:300
Action Clipping
Actions are automatically clipped to valid range:Policy Comparison
| Policy | Action Space | Exploration | Use Case |
|---|---|---|---|
| Random | Discrete/Continuous | Maximum | Baseline, early exploration |
| Greedy | Discrete | None | Evaluation, final policy |
| Epsilon-Greedy | Discrete | Controlled | DQN, Q-learning |
| Softmax | Discrete | Temperature-based | Value-based methods |
| Gaussian | Continuous | Fixed noise | Actor-critic, policy gradient |
Using Policies with Agents
neurenix/rl/agent.py:18
Custom Policies
Implement domain-specific action selection:Best Practices
Exploration Schedule
Action Space Normalization
Policy Evaluation
Next Steps
Algorithms
Learn about RL algorithms
Value Functions
Understand value estimation