Example #1
0
    def get_action_to_set(self):
        line_status = self.get_line_status()
        line_status = 2 * line_status - 1
        line_status = line_status.astype(dt_int)
        topo_vect = self.get_topo_vect()
        self.runpf()

        prod_p, _, prod_v = self.generators_info()
        load_p, load_q, _ = self.loads_info()
        # prod_p, prod_q, prod_v = self.init_pp_backend._gens_info()
        # load_p, load_q, load_v = self.init_pp_backend._loads_info()
        complete_action_class = CompleteAction.init_grid(self)
        set_me = complete_action_class()
        set_me.update({
            "set_line_status": 1 * line_status,
            "set_bus": 1 * topo_vect
        })

        injs = {
            "prod_p": prod_p,
            "prod_v": prod_v,
            "load_p": load_p,
            "load_q": load_q
        }
        set_me.update({"injection": injs})
        return set_me
Example #2
0
    def get_action_to_set(self):
        line_status = self.get_line_status()
        line_status = 2 * line_status - 1
        line_status = line_status.astype(np.int)
        topo_vect = self.get_topo_vect()
        prod_p, _, prod_v = self.generators_info()
        load_p, load_q, _ = self.loads_info()
        set_me = CompleteAction(self)
        set_me.update({"set_line_status": line_status,
                       "set_bus": topo_vect})

        #injs = {"prod_p": prod_p, "prod_v": prod_v,
        #              "load_p": load_p, "load_q": load_q}}

        # set_me.update({"injection": injs})
        return set_me
Example #3
0
 def get_action_to_set(self):
     line_status = self.get_line_status()
     line_status = 2 * line_status - 1
     line_status = line_status.astype(dt_int)
     topo_vect = self.get_topo_vect()
     prod_p, _, prod_v = self.generators_info()
     load_p, load_q, _ = self.loads_info()
     complete_action_class = CompleteAction.init_grid(self)
     set_me = complete_action_class(self)
     set_me.update({"set_line_status": line_status, "set_bus": topo_vect})
     return set_me
Example #4
0
 def _get_action_to_set_deprecated(self):
     warnings.warn(
         "DEPRECATION: grid2op <=1.4 is not well supported with lightsim2grid. Lots of bugs have been"
         "fixed since then. Please upgrade to grid2op >= 1.5",
         DeprecationWarning)
     line_status = self.get_line_status()
     line_status = 2 * line_status - 1
     line_status = line_status.astype(dt_int)
     topo_vect = self.get_topo_vect()
     prod_p, _, prod_v = self.generators_info()
     load_p, load_q, _ = self.loads_info()
     complete_action_class = CompleteAction.init_grid(self)
     set_me = complete_action_class()
     set_me.update({"set_line_status": line_status, "set_bus": topo_vect})
     return set_me
Example #5
0
    def __init__(
            self,
            path_grid_json,  # complete path where the grid is represented as a json file
            name="dc_approx",
            is_dc=True,
            attr_x=("prod_p", "prod_v", "load_p", "load_q",
                    "topo_vect"),  # input that will be given to the proxy
            attr_y=("a_or", "a_ex", "p_or", "p_ex", "q_or", "q_ex", "prod_q",
                    "load_v", "v_or",
                    "v_ex"),  # output that we want the proxy to predict
    ):
        BaseProxy.__init__(self,
                           name=name,
                           max_row_training_set=1,
                           eval_batch_size=1,
                           attr_x=attr_x,
                           attr_y=attr_y)

        # datasets
        self._supported_output = {
            "a_or", "a_ex", "p_or", "p_ex", "q_or", "q_ex", "prod_q", "load_v",
            "v_or", "v_ex"
        }
        self.is_dc = is_dc
        for el in ("prod_p", "prod_v", "load_p", "load_q", "topo_vect"):
            if not el in self.attr_x:
                raise RuntimeError(
                    f"The DC approximation need the variable \"{el}\" to be computed."
                )
        for el in self.attr_y:
            if not el in self._supported_output:
                raise RuntimeError(
                    f"This solver cannot output the variable \"{el}\" at the moment. "
                    f"Only possible outputs are \"{self._supported_output}\".")

        # specific part to dc model
        self.solver = PandaPowerBackend()
        self.solver.set_env_name(self.name)
        self.solver.load_grid(
            path_grid_json)  # the real powergrid of the environment
        self.solver.assert_grid_correct()
        self._bk_act_class = _BackendAction.init_grid(self.solver)
        self._act_class = CompleteAction.init_grid(self.solver)

        # internal variables (speed optimisation)
        self._indx_var = {}
        for el in ("prod_p", "prod_v", "load_p", "load_q", "topo_vect"):
            self._indx_var[el] = self.attr_x.index(el)