Skip to content

Commit

Permalink
- set time horizon in learning_role
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-mskw committed Nov 20, 2024
1 parent bc2db86 commit 0f302fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 9 additions & 0 deletions assume/reinforcement_learning/learning_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
get_schedule_fn,
linear_schedule,
)
from assume.common.utils import datetime2timestamp

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -124,6 +125,14 @@ def __init__(
# list of avg_changes
self.avg_rewards = []

def set_simulation_horizon_to_learning_role(self, start, end):
"""
Add simulation horizon to learning role for calculation of decay.
"""

self.start = datetime2timestamp(start)
self.end = datetime2timestamp(end)

def load_inter_episodic_data(self, inter_episodic_data):
"""
Load the inter-episodic data from the dict stored across simulation runs.
Expand Down
8 changes: 1 addition & 7 deletions assume/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def setup_learning(self) -> None:
from assume.reinforcement_learning.learning_role import Learning

self.learning_role = Learning(self.learning_config)
self._add_simulation_horizon_to_learning_role()
self.learning_role.set_simulation_horizon_to_learning_role(start=self.start, end=self.end)
# separate process does not support buffer and learning
self.learning_agent_addr = addr(self.addr, "learning_agent")
rl_agent = agent_composed_of(
Expand Down Expand Up @@ -480,13 +480,7 @@ def create_unit(
**unit_params,
)

def _add_simulation_horizon_to_learning_role(self):
"""
Add simulation horizon to learning role for calculation of decay.
"""

self.learning_role.start = datetime2timestamp(self.start)
self.learning_role.end = datetime2timestamp(self.end)

def _add_bidding_strategies_to_learning_role(self, unit_id, bidding_strategies):
"""
Expand Down

0 comments on commit 0f302fc

Please sign in to comment.