Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
perceptualrobots committed Nov 2, 2023
1 parent 18b8322 commit eb3eca3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions nbs/04_hierarchy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,14 @@
" return hierarchy, score \n",
" \n",
"\n",
" @classmethod\n",
" def get_environment_properties(cls, filename):\n",
" \n",
" prp = PCTRunProperties()\n",
" prp.load_db(filename)\n",
" environment_properties = eval(prp.db['environment_properties'])\n",
" \n",
" return environment_properties\n",
"\n",
" @classmethod\n",
" def run_from_file(cls, filename, env_props=None, seed=None, render=False, history=False, move=None, plots=None, hpct_verbose= False, runs=None, outdir=None, early_termination = None, draw_file=None):\n",
Expand Down
4 changes: 3 additions & 1 deletion nbs/12_yaw_module.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,16 @@
"\n",
" # added wind speed\n",
" wind_speed = self.wind_timeseries[\"wind_speed\"][self.index_wind_timeseries]\n",
" yaw_error = oriented_angle(self.yaw_angle - self.wind_timeseries[\"wind_direction\"][self.index_wind_timeseries:self.index_wind_timeseries+12].mean())\n",
" yaw_error = abs(oriented_angle(self.yaw_angle - self.wind_timeseries[\"wind_direction\"][self.index_wind_timeseries:self.index_wind_timeseries+12].mean()))\n",
" self.state = new_state\n",
"\n",
" if self.reward_type=='surface2':\n",
" reward1 = -(yaw_error**3)\n",
" reward2 = -(yaw_error ** 2 * wind_speed ** 2)\n",
" reward3 = 1+self.w2 * (self.step_since_last_2 > self.filter_duration and self.step_since_last_0 > self.filter_duration)\n",
" reward = (reward1 + reward2)/reward3\n",
" elif self.reward_type == 'power':\n",
" reward = self.get_power(self.wind_timeseries[\"wind_speed\"][self.index_wind_timeseries],new_yaw_error) # power generated by turbine\n",
" else: \n",
" reward1 = -self.wind_timeseries[\"wind_speed\"][self.index_wind_timeseries]**3 \\\n",
" * oriented_angle(self.yaw_angle - self.wind_timeseries[\"wind_direction\"][self.index_wind_timeseries:self.index_wind_timeseries+12].mean()) ** 2 \n",
Expand Down
2 changes: 2 additions & 0 deletions pct/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@
'pct/hierarchy.py'),
'pct.hierarchy.PCTHierarchy.get_environment': ( 'hierarchy.html#pcthierarchy.get_environment',
'pct/hierarchy.py'),
'pct.hierarchy.PCTHierarchy.get_environment_properties': ( 'hierarchy.html#pcthierarchy.get_environment_properties',
'pct/hierarchy.py'),
'pct.hierarchy.PCTHierarchy.get_error_collector': ( 'hierarchy.html#pcthierarchy.get_error_collector',
'pct/hierarchy.py'),
'pct.hierarchy.PCTHierarchy.get_function': ('hierarchy.html#pcthierarchy.get_function', 'pct/hierarchy.py'),
Expand Down
8 changes: 8 additions & 0 deletions pct/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,14 @@ def run_from_config(cls, config, min, render=False, error_collector_type=None,
return hierarchy, score


@classmethod
def get_environment_properties(cls, filename):

prp = PCTRunProperties()
prp.load_db(filename)
environment_properties = eval(prp.db['environment_properties'])

return environment_properties

@classmethod
def run_from_file(cls, filename, env_props=None, seed=None, render=False, history=False, move=None, plots=None, hpct_verbose= False, runs=None, outdir=None, early_termination = None, draw_file=None):
Expand Down
4 changes: 3 additions & 1 deletion pct/yaw_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,16 @@ def step(self, action):

# added wind speed
wind_speed = self.wind_timeseries["wind_speed"][self.index_wind_timeseries]
yaw_error = oriented_angle(self.yaw_angle - self.wind_timeseries["wind_direction"][self.index_wind_timeseries:self.index_wind_timeseries+12].mean())
yaw_error = abs(oriented_angle(self.yaw_angle - self.wind_timeseries["wind_direction"][self.index_wind_timeseries:self.index_wind_timeseries+12].mean()))
self.state = new_state

if self.reward_type=='surface2':
reward1 = -(yaw_error**3)
reward2 = -(yaw_error ** 2 * wind_speed ** 2)
reward3 = 1+self.w2 * (self.step_since_last_2 > self.filter_duration and self.step_since_last_0 > self.filter_duration)
reward = (reward1 + reward2)/reward3
elif self.reward_type == 'power':
reward = self.get_power(self.wind_timeseries["wind_speed"][self.index_wind_timeseries],new_yaw_error) # power generated by turbine
else:
reward1 = -self.wind_timeseries["wind_speed"][self.index_wind_timeseries]**3 \
* oriented_angle(self.yaw_angle - self.wind_timeseries["wind_direction"][self.index_wind_timeseries:self.index_wind_timeseries+12].mean()) ** 2
Expand Down

0 comments on commit eb3eca3

Please sign in to comment.