FAILED [ 7%]Parameters used = C:/Users/lenovo/Documents/gan/Python/pypownet-master1/pypownet-master/tests/parameters/default14_for_tests/
tests\test_core.py:987 (test_core_Agent_test_limitOfProdsLost)
def test_core_Agent_test_limitOfProdsLost():
"""This function creates an Agent that tests the config variable: max_number_prods_game_over: 1
t = 1, it disconnects 1 prod
t = 2, it disconnects second prod, ==> causes a Game Over
t = 3, it checks that obs.productions_nodes = [0, 0, 0, 0, 0], ie, that the game reset.
This function checks that the game ended because of TooManyProductionsCut"""
parameters = "C:/Users/lenovo/Documents/gan/Python/pypownet-master1/pypownet-master/tests/parameters/default14_for_tests/"
print("Parameters used = ", parameters)
game_level = "level0"
loop_mode = "natural"
start_id = 0
game_over_mode = "soft"
renderer_latency = 1
render = False
# render = False
niter = 3
env_class = RunEnv
# Instantiate environment and agent
> env = env_class(parameters_folder=parameters, game_level=game_level,
chronic_looping_mode=loop_mode, start_id=start_id,
game_over_mode=game_over_mode, renderer_latency=renderer_latency)
test_core.py:1008:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\pypownet\environment.py:812: in __init__
self.reset()
..\pypownet\environment.py:830: in reset
self.observation_space = ObservationSpace(n_prods, n_loads, n_lines, n_substations,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Dict(MinimalistACObservation:Dict(MinimalistObservation:Dict(active_loads:Box(-inf, inf, (11,), float32), are_loads_cu...or_nodes:Box(-2147483646, 2147483645, (20,), int32), initial_lines_ex_nodes:Box(-2147483646, 2147483645, (20,), int32))
number_generators = 5, number_consumers = 11, number_power_lines = 20
number_substations = 14, n_timesteps_horizon_maintenance = 20
def __init__(self, number_generators, number_consumers, number_power_lines, number_substations,
n_timesteps_horizon_maintenance):
self.number_productions = number_generators
self.number_loads = number_consumers
self.number_power_lines = number_power_lines
self.number_substations = number_substations
self.n_timesteps_horizon_maintenance = n_timesteps_horizon_maintenance
self.grid_number_of_elements = self.number_productions + self.number_loads + 2 * self.number_power_lines
dict_spaces = OrderedDict([
('MinimalistACObservation', Dict(OrderedDict([
('MinimalistObservation', Dict(OrderedDict([
('active_loads', Box(low=-np.inf, high=np.inf, shape=(number_consumers,), dtype=np.float32)),
('are_loads_cut', MultiBinary(n=number_consumers)),
('planned_active_loads', Box(low=-np.inf, high=np.inf, shape=(number_consumers,),
dtype=np.float32)),
('loads_nodes', Box(-np.inf, np.inf, (number_consumers,), np.int32)),
('active_productions', Box(low=-np.inf, high=np.inf, shape=(number_generators,), dtype=np.float32)),
('are_productions_cut', MultiBinary(n=number_generators)),
('planned_active_productions', Box(low=-np.inf, high=np.inf, shape=(number_generators,),
dtype=np.float32)),
('productions_nodes', Box(-np.inf, np.inf, (number_generators,), np.int32)),
('lines_or_nodes', Box(-np.inf, np.inf, (number_power_lines,), np.int32)),
('lines_ex_nodes', Box(-np.inf, np.inf, (number_power_lines,), np.int32)),
('ampere_flows', Box(0, np.inf, (number_power_lines,), np.float32)),
('lines_status', MultiBinary(n=number_power_lines)),
('timesteps_before_lines_reconnectable', Box(0, np.inf, (number_power_lines,), np.int32)),
('timesteps_before_lines_reactionable', Box(0, np.inf, (number_power_lines,), np.int32)),
('timesteps_before_nodes_reactionable', Box(0, np.inf, (self.number_substations,), np.int32)),
('timesteps_before_planned_maintenance', Box(0, np.inf, (number_power_lines,), np.int32)),
('date_year', Discrete(3000)),
('date_month', Discrete(12)),
('date_day', Discrete(32)),
('date_hour', Discrete(24)),
('date_minute', Discrete(60)),
('date_second', Discrete(60)),
]))),
('reactive_loads', Box(low=-np.inf, high=np.inf, shape=(number_consumers,), dtype=np.float32)),
('voltage_loads', Box(low=-np.inf, high=np.inf, shape=(number_consumers,), dtype=np.float32)),
('reactive_productions', Box(low=-np.inf, high=np.inf, shape=(number_generators,), dtype=np.float32)),
('voltage_productions', Box(low=-np.inf, high=np.inf, shape=(number_generators,), dtype=np.float32)),
('active_flows_origin', Box(low=-np.inf, high=np.inf, shape=(number_power_lines,), dtype=np.float32)),
('reactive_flows_origin', Box(low=-np.inf, high=np.inf, shape=(number_power_lines,), dtype=np.float32)),
('voltage_flows_origin', Box(low=-np.inf, high=np.inf, shape=(number_power_lines,), dtype=np.float32)),
('active_flows_extremity', Box(low=-np.inf, high=np.inf, shape=(number_power_lines,),
dtype=np.float32)),
('reactive_flows_extremity', Box(low=-np.inf, high=np.inf, shape=(number_power_lines,),
dtype=np.float32)),
('voltage_flows_extremity', Box(low=-np.inf, high=np.inf, shape=(number_power_lines,),
dtype=np.float32)),
('planned_reactive_loads', Box(low=-np.inf, high=np.inf, shape=(number_consumers,), dtype=np.float32)),
('planned_voltage_productions', Box(low=-np.inf, high=np.inf, shape=(number_generators,),
dtype=np.float32)),
]))),
('substations_ids', Box(-np.inf, np.inf, (number_substations,), np.int32)),
('loads_substations_ids', Box(-np.inf, np.inf, (number_consumers,), np.int32)),
('productions_substations_ids', Box(-np.inf, np.inf, (number_generators,), np.int32)),
('lines_or_substations_ids', Box(-np.inf, np.inf, (number_power_lines,), np.int32)),
('lines_ex_substations_ids', Box(-np.inf, np.inf, (number_power_lines,), np.int32)),
('thermal_limits', Box(0, np.inf, (number_power_lines,), np.int32)),
('initial_productions_nodes', Box(-np.inf, np.inf, (number_generators,), np.int32)),
('initial_loads_nodes', Box(-np.inf, np.inf, (number_consumers,), np.int32)),
('initial_lines_or_nodes', Box(-np.inf, np.inf, (number_power_lines,), np.int32)),
('initial_lines_ex_nodes', Box(-np.inf, np.inf, (number_power_lines,), np.int32)),
])
super().__init__(dict_spaces)
def seek_shapes(gym_dict, shape):
""" Computes and returns the shape of self ie the set of all its attributes shapes as a tuple of tuples.
:param gym_dict: an instance of gym Spaces
:param shape: a container that is recursively filled with res
:return: a tuple of tuples
"""
# loop through all dicts first
for k, v in gym_dict.spaces.items():
if isinstance(v, Dict) or isinstance(v, OrderedDict):
shape = seek_shapes(v, shape)
# then save shapes
for k, v in gym_dict.spaces.items():
if not (isinstance(v, Dict) or isinstance(v, OrderedDict)):
shape += (v.shape,) if not isinstance(v, Discrete) else ((1,),)
return shape
> self.shape = seek_shapes(self, ())
E AttributeError: can't set attribute
..\pypownet\environment.py:374: AttributeError
self.shape = seek_shapes(self, ())这样写不行,参数不能是(),可以是变量,类,判断语句等。
别的报错因为你的代码不全,报错的内容也不全,看不出来是什么原因