@@ -481,17 +481,40 @@ def __init__(self, subconverters, **kwargs):
481481 super ().__init__ (** kwargs )
482482 self ._subconverters = [instantiate (PowerElectronicConverter , subconverter , ** kwargs ) for subconverter in subconverters ]
483483
484- self .subsignal_current_space_dims = np .array ([(np .squeeze (subconverter .currents .shape ) or 1 ) for subconverter in self ._subconverters ])
485- self .subsignal_voltage_space_dims = np .array ([(np .squeeze (subconverter .voltages .shape ) or 1 ) for subconverter in self ._subconverters ])
484+ self .subsignal_current_space_dims = []
485+ self .subsignal_voltage_space_dims = []
486+ self .action_space = []
487+ currents_low = []
488+ currents_high = []
489+ voltages_low = []
490+ voltages_high = []
491+
492+ # get the limits and space dims from each subconverter
493+ for subconverter in self ._subconverters :
494+ self .subsignal_current_space_dims .append (np .squeeze (subconverter .currents .shape ) or 1 )
495+ self .subsignal_voltage_space_dims .append (np .squeeze (subconverter .voltages .shape ) or 1 )
486496
487- self .action_space = MultiDiscrete ([ subconverter .action_space .n for subconverter in self . _subconverters ] )
497+ self .action_space . append ( subconverter .action_space .n )
488498
489- currents_low = np .concatenate ([subconverter .currents .low for subconverter in self ._subconverters ])
490- currents_high = np .concatenate ([subconverter .currents .high for subconverter in self ._subconverters ])
491- self .currents = Box (currents_low , currents_high )
499+ currents_low .append (subconverter .currents .low )
500+ currents_high .append (subconverter .currents .high )
501+
502+ voltages_low .append (subconverter .voltages .low )
503+ voltages_high .append (subconverter .voltages .high )
504+
505+ # convert to 1D list
506+ self .subsignal_current_space_dims = np .array (self .subsignal_current_space_dims )
507+ self .subsignal_voltage_space_dims = np .array (self .subsignal_voltage_space_dims )
508+
509+ currents_low = np .concatenate (currents_low )
510+ currents_high = np .concatenate (currents_high )
492511
493- voltages_low = np .concatenate ([subconverter .voltages .low for subconverter in self ._subconverters ])
494- voltages_high = np .concatenate ([subconverter .voltages .high for subconverter in self ._subconverters ])
512+ voltages_low = np .concatenate (voltages_low )
513+ voltages_high = np .concatenate (voltages_high )
514+
515+ # put limits into gym_space format
516+ self .action_space = MultiDiscrete (self .action_space )
517+ self .currents = Box (currents_low , currents_high )
495518 self .voltages = Box (voltages_low , voltages_high )
496519
497520 def convert (self , i_out , t ):
@@ -558,19 +581,45 @@ def __init__(self, subconverters, **kwargs):
558581 super ().__init__ (** kwargs )
559582 self ._subconverters = [instantiate (PowerElectronicConverter , subconverter , ** kwargs ) for subconverter in subconverters ]
560583
561- self .subsignal_current_space_dims = np .array ([(np .squeeze (subconverter .currents .shape ) or 1 ) for subconverter in self ._subconverters ])
562- self .subsignal_voltage_space_dims = np .array ([(np .squeeze (subconverter .voltages .shape ) or 1 ) for subconverter in self ._subconverters ])
584+ self .subsignal_current_space_dims = []
585+ self .subsignal_voltage_space_dims = []
586+ action_space_low = []
587+ action_space_high = []
588+ currents_low = []
589+ currents_high = []
590+ voltages_low = []
591+ voltages_high = []
563592
564- action_space_low = np .concatenate ([subconverter .action_space .low for subconverter in self ._subconverters ])
565- action_space_high = np .concatenate ([subconverter .action_space .high for subconverter in self ._subconverters ])
566- self .action_space = Box (action_space_low , action_space_high )
593+ # get the limits and space dims from each subconverter
594+ for subconverter in self ._subconverters :
595+ self .subsignal_current_space_dims .append (np .squeeze (subconverter .currents .shape ) or 1 )
596+ self .subsignal_voltage_space_dims .append (np .squeeze (subconverter .voltages .shape ) or 1 )
567597
568- currents_low = np .concatenate ([subconverter .currents .low for subconverter in self ._subconverters ])
569- currents_high = np .concatenate ([subconverter .currents .high for subconverter in self ._subconverters ])
570- self .currents = Box (currents_low , currents_high )
598+ action_space_low .append (subconverter .action_space .low )
599+ action_space_high .append (subconverter .action_space .high )
600+
601+ currents_low .append (subconverter .currents .low )
602+ currents_high .append (subconverter .currents .high )
603+
604+ voltages_low .append (subconverter .voltages .low )
605+ voltages_high .append (subconverter .voltages .high )
606+
607+ # convert to 1D list
608+ self .subsignal_current_space_dims = np .array (self .subsignal_current_space_dims )
609+ self .subsignal_voltage_space_dims = np .array (self .subsignal_voltage_space_dims )
610+
611+ action_space_low = np .concatenate (action_space_low )
612+ action_space_high = np .concatenate (action_space_high )
571613
572- voltages_low = np .concatenate ([subconverter .voltages .low for subconverter in self ._subconverters ])
573- voltages_high = np .concatenate ([subconverter .voltages .high for subconverter in self ._subconverters ])
614+ currents_low = np .concatenate (currents_low )
615+ currents_high = np .concatenate (currents_high )
616+
617+ voltages_low = np .concatenate (voltages_low )
618+ voltages_high = np .concatenate (voltages_high )
619+
620+ # put limits into gym_space format
621+ self .action_space = Box (action_space_low , action_space_high )
622+ self .currents = Box (currents_low , currents_high )
574623 self .voltages = Box (voltages_low , voltages_high )
575624
576625 def set_action (self , action , t ):
0 commit comments