Skip to content

env.reset() error in Q_learning_agent #160

@irmakakyeli

Description

@irmakakyeli

I am trying to work with the boptest gym environment and started to implement the example code given in Building_Control_with_RL_using_BOPTEST.ipynb however I can't get it to work as I receive an error in env.reset in Q_learning_agent.
The error is as follows, how can I solve this? thank you


TypeError Traceback (most recent call last)
Cell In[50], line 1
----> 1 obs, _ = env.reset()

File ~\anaconda3\Lib\site-packages\gymnasium\core.py:462, in ObservationWrapper.reset(self, seed, options)
458 def reset(
459 self, *, seed: int | None = None, options: dict[str, Any] | None = None
460 ) -> tuple[WrapperObsType, dict[str, Any]]:
461 """Modifies the :attr:env after calling :meth:reset, returning a modified observation using :meth:self.observation."""
--> 462 obs, info = self.env.reset(seed=seed, options=options)
463 return self.observation(obs), info

File ~\anaconda3\Lib\site-packages\gymnasium\core.py:414, in Wrapper.reset(self, seed, options)
410 def reset(
411 self, *, seed: int | None = None, options: dict[str, Any] | None = None
412 ) -> tuple[WrapperObsType, dict[str, Any]]:
413 """Uses the :meth:reset of the :attr:env that can be overwritten to change the returned data."""
--> 414 return self.env.reset(seed=seed, options=options)

File ~\Documents\GitHub\RL_ex\boptestGymService\boptestGymEnv.py:482, in BoptestGymEnv.reset(self, seed, options)
480 # Assign random start_time if it is None
481 if self.random_start_time:
--> 482 self.start_time = find_start_time()
484 # Initialize the building simulation
485 res = requests.put('{0}/initialize/{1}'.format(self.url,self.testid),
486 json={'start_time':int(self.start_time),
487 'warmup_period':int(self.warmup_period)}).json()['payload']

File ~\Documents\GitHub\RL_ex\boptestGymService\boptestGymEnv.py:468, in BoptestGymEnv.reset..find_start_time()
461 def find_start_time():
462 '''Recursive method to find a random start time out of
463 excluding_periods. An episode and an excluding_period that
464 are just touching each other are not considered as being
465 overlapped.
466
467 '''
--> 468 start_time = random.randint(0+self.bgn_year_margin,
469 3.1536e+7-self.end_year_margin)
470 episode = (start_time, start_time+self.max_episode_length)
471 if self.excluding_periods is not None:

File ~\anaconda3\Lib\random.py:336, in Random.randint(self, a, b)
332 def randint(self, a, b):
333 """Return random integer in range [a, b], including both end points.
334 """
--> 336 return self.randrange(a, b+1)

File ~\anaconda3\Lib\random.py:312, in Random.randrange(self, start, stop, step)
309 raise ValueError("empty range for randrange()")
311 # Stop argument supplied.
--> 312 istop = _index(stop)
313 width = istop - istart
314 istep = _index(step)

TypeError: 'float' object cannot be interpreted as an integer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions