ibpsa / project1-boptest-gym

Other
43 stars 20 forks source link

README Quick Start Code Error #143

Closed IamAniket12 closed 2 months ago

IamAniket12 commented 2 months ago

The quick start code provided in the README is producing an error. Could you please review the code and error message below

from stable_baselines3 import DQN

# url for the BOPTEST service. 
url = 'https://api.boptest.net' 

# Decide the state-action space of your test case
env = BoptestGymEnv(
        url                  = url,
        testcase             = 'bestest_hydronic_heat_pump',
        actions              = ['oveHeaPumY_u'],
        observations         = {'time':(0,604800),
                                'reaTZon_y':(280.,310.),
                                'TDryBul':(265,303),
                                'HDirNor':(0,862),
                                'InternalGainsRad[1]':(0,219),
                                'PriceElectricPowerHighlyDynamic':(-0.4,0.4),
                                'LowerSetp[1]':(280.,310.),
                                'UpperSetp[1]':(280.,310.)}, 
        predictive_period    = 24*3600, 
        regressive_period    = 6*3600, 
        random_start_time    = True,
        max_episode_length   = 24*3600,
        warmup_period        = 24*3600,
        step_period          = 3600)

# Normalize observations and discretize action space
env = NormalizedObservationWrapper(env)
env = DiscretizedActionWrapper(env,n_bins_act=10)

# Instantiate an RL agent
model = DQN('MlpPolicy', env, verbose=1, gamma=0.99,
            learning_rate=5e-4, batch_size=24, 
            buffer_size=365*24, learning_starts=24, train_freq=1)

# Main training loop
model.learn(total_timesteps=10)

# Loop for one episode of experience (one day)
done = False
obs, _ = env.reset()
while not done:
  action, _ = model.predict(obs, deterministic=True) 
  obs,reward,terminated,truncated,info = env.step(action)
  done = (terminated or truncated)

# Obtain KPIs for evaluation
env.get_kpis()

Error


    "name": "TypeError",
    "message": "BoptestGymEnv.__init__() got an unexpected keyword argument 'testcase'",
    "stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[12], line 8
      5 url = 'https://api.boptest.net' 
      7 # Decide the state-action space of your test case
----> 8 env = BoptestGymEnv(
      9         url                  = url,
     10         testcase             = 'bestest_hydronic_heat_pump',
     11         actions              = ['oveHeaPumY_u'],
     12         observations         = {'time':(0,604800),
     13                                 'reaTZon_y':(280.,310.),
     14                                 'TDryBul':(265,303),
     15                                 'HDirNor':(0,862),
     16                                 'InternalGainsRad[1]':(0,219),
     17                                 'PriceElectricPowerHighlyDynamic':(-0.4,0.4),
     18                                 'LowerSetp[1]':(280.,310.),
     19                                 'UpperSetp[1]':(280.,310.)}, 
     20         predictive_period    = 24*3600, 
     21         regressive_period    = 6*3600, 
     22         random_start_time    = True,
     23         max_episode_length   = 24*3600,
     24         warmup_period        = 24*3600,
     25         step_period          = 3600)
     27 # Normalize observations and discretize action space
     28 env = NormalizedObservationWrapper(env)

TypeError: BoptestGymEnv.__init__() got an unexpected keyword argument 'testcase'"
}```
dhblum commented 2 months ago

Hello. Are you using the boptest-gym-service branch of the repo for use with BOPTEST-Service? This is described in Step 2. of the README in the section for "using BOPTEST-Service". If you are deploying the test case locally, use the steps described in the section of the README for "running BOPTEST locally".

IamAniket12 commented 2 months ago

Worked, Thank you!!