def step(self, actions=None, log=True): # Implement the actions and take a step forward done = self.env.step(actions) # Log the flows in the networks if log: self._logger() # Estimate the _performormance __performance = 0.0 # temp variable for ID, attribute in self.config["performance_targets"]: if attribute == "flooding": __flood = self.env.methods[attribute](ID) if __flood > 0.0: __performance += 10**6 elif attribute == "flow": __target = self._performormance_threshold __performance += threshold(self.env.methods[attribute](ID), __target, scaling=1.0) # Check for water in the last timestep elif done and attribute == "depthN": __depth = self.env.methods[attribute](ID) if __depth > 0.10: __performance += 7 * 10**5 # Record the _performormance self.data_log["performance_measure"].append(__performance) # Terminate the simulation if done: self.env.terminate() return done
def step(self, actions=None, log=True): # Implement the actions and take a step forward done = self.env.step(actions) # Log the flows in the networks if log: self._logger() # Estimate the performance __performance = 0.0 for ID, attribute in self.config["performance_targets"]: if attribute == "flooding": __flood = self.env.methods[attribute](ID) if __flood > 0.0: __performance += 10**6 if attribute == "flow": __flow = self.env.methods[attribute](ID) __performance = threshold(value=__flow, target=self.threshold, scaling=10.0) # Record the _performance self.data_log["performance_measure"].append(__performance) # Terminate the simulation if done: self.env.terminate() return done
def step(self, actions, log=True): # Implement the action and take a step forward _, done = self.env.step(actions) # Log the flows in the networks if log: self._logger() # Estimate the _performormance __performance = 0.0 # temporary variable for ID, attribute in self.config["performance_targets"]: if attribute == "flooding": flood = self.env.methods[attribute](ID) if flood > 0.0: __performance += 10 ** 9 elif attribute == "loading": _target = self._performormance_threshold pollutantLoading = ( self.env.methods["pollutantL"](ID, 0) * self.env.methods["flow"](ID) * 28.3168 / (10 ** 6) ) __performance += threshold(pollutantLoading, _target) # Record the _performormance self.data_log["performance_measure"].append(__performance) # Terminate the simulation if done: self.env._terminate() return done
def step(self, actions, log=True): # Implement the actions and take a step forward _, done = self.env.step(actions) # Log the flows in the networks if log: self._logger() # Estimate the _performormance __performorm = 0.0 # temp variable for ID, attribute in self.config["performance_targets"]: if attribute == "flooding": flood = self.env.methods[attribute](ID) if flood > 0.0: __performorm += 10**6 else: _target = self._performormance_threshold __performorm += threshold(self.env.methods[attribute](ID), _target, scaling=1.0) # Record the _performormance self.data_log["performance_measure"].append(__performorm) # Terminate the simulation if done: self.env._terminate() return done
def step(self, actions=None, log=True): # Implement the actions and take a step forward done = self.env.step(actions) # Temp variables __performance = 0.0 # Determine current timestep in simulation by # obtaining the differeence between the current time # and previous time, and converting to seconds __currentsimtime = self.env._getCurrentSimulationDateTime() if len(self.data_log["simulation_time"]) > 1: __prevsimtime = self.data_log["simulation_time"][-1] else: __prevsimtime = self.env._getInitialSimulationDateTime() __timestep = (__currentsimtime - __prevsimtime).total_seconds() # Log the flows in the networks if log: self._logger() # Estimate the performance for ID, attribute in self.config["performance_targets"]: # compute penalty for flooding if attribute == "flooding": __flood = self.env.methods[attribute](ID) if __flood > 0.0: __performance += __flood * (10 ** 6) # compute penalty for CSO overflow # TODO - decide if we want to have a penalty for negative flow if attribute == "flow": __flow = self.env.methods[attribute](ID) __volume = __timestep * __flow __performance += threshold(value=__volume, target=0.0, scaling=1.0) # Record the _performance self.data_log["performance_measure"].append(__performance) # Terminate the simulation if done: self.env.terminate() return done
def step(self, actions=None, log=True): # Implement the actions and take a step forward done = self.env.step(actions) # Log the flows in the networks if log: self._logger() # Estimate the performance __performance = 0.0 for ID, attribute in self.config["performance_targets"]: # compute penalty for flooding if attribute == "flooding": __flood = self.env.methods[attribute](ID) if __flood > 0.0: __performance += 10**6 # compute penalty for flow out of network above threshold if attribute == "flow": __flow = self.env.methods[attribute](ID) __performance += threshold(value=__flow, target=self.threshold, scaling=10.0) # compute penalty for depth at basins above/below predefined ranges if attribute == "depthN": depth = self.env.methods[attribute](ID) temp = self.depth_thresholds[ID] if ID == "basin_S": if depth > temp[1]: # flooding value __performance += 10**6 elif depth > temp[0]: __temp = (depth - temp[0]) / (temp[1] - temp[0]) __performance += exponentialpenalty( value=__temp, max_penalty=self.max_penalty, scaling=1.0) else: __performance += 0.0 else: if depth > temp[0] or depth < temp[ 1]: # flooding value + fish dead __performance += 10**6 elif depth > temp[2]: __temp = (depth - temp[2]) / (temp[0] - temp[2]) __performance += exponentialpenalty( value=__temp, max_penalty=self.max_penalty, scaling=1.0) elif depth < temp[3]: __temp = (temp[3] - depth) / (temp[3] - temp[1]) __performance += exponentialpenalty( value=__temp, max_penalty=self.max_penalty, scaling=1.0) else: __performance += 0.0 # Record the _performance self.data_log["performance_measure"].append(__performance) # Terminate the simulation if done: self.env.terminate() return done