Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend given_list_topo_encode when lines are disconnected #11

Open
marota opened this issue Jun 22, 2022 · 4 comments
Open

Extend given_list_topo_encode when lines are disconnected #11

marota opened this issue Jun 22, 2022 · 4 comments

Comments

@marota
Copy link

marota commented Jun 22, 2022

The current implementation of given_list_topo_encode does not allow to detect a topology present in list_topos if a line is disconnected at this substation.

For instance if we have in list_topo this sub_topology_in_dic=[1,2,2,2,1] and that the first line is disconnected giving this sub_topology_in_obs=[1,-1,2,2,1], a match is not found

@marota
Copy link
Author

marota commented Jun 22, 2022

I here propose a code evolution to take that into account

        res = np.zeros(self.nb_diff_topo)
        # retrieve the topology
        topo_vect = 1 * obs.topo_vect

        # and now put the right number
        for sub_id in range(obs.n_sub):
            # TODO there might be a way to optimize that, but what for ?
            beg_, end_ = self.subs_index[sub_id]
            this_sub_topo = topo_vect[beg_:end_]
            disco = this_sub_topo == -1
            conn = ~disco
            if np.all(this_sub_topo[conn] == 2) or np.all(this_sub_topo[conn] == 1):
                # complete / reference topology, so i don't do anything
                continue

            # so i have a different topology that the reference one
            #lookup = (sub_id, tuple([el if el >= 1 else 1 for el in this_sub_topo]))
            topo_found=False

            if (np.all(conn)):
                lookup = (sub_id, tuple([el if el >= 1 else 1 for el in this_sub_topo]))
                if lookup in self.dict_topo:
                    res[self.dict_topo[lookup]] = 1.
                    topo_found = True
            else:
                for topo_sub in self.dict_topo:
                    if topo_sub[0] == sub_id:
                        topo=np.array(topo_sub[1])
                        if np.all(topo[conn]==this_sub_topo[conn]):
                            res[self.dict_topo[topo_sub]] = 1.
                            topo_found=True
                            conn_elements_bus_bar_2=conn[(topo_found==2)]
                            break

            #if lookup in self.dict_topo:
            #    res[self.dict_topo[lookup]] = 1.
            #else:
            if not topo_found:
                warnings.warn(f"Topology {lookup} is not found on the topo dictionary")
            return res

@BDonnot
Copy link
Owner

BDonnot commented Jun 22, 2022

Hello,

I think that's a feature and not a bug, unfortunately

What if both [2,2,1,2,1] and [2,1,1,2,1] are in the list of the topology, what happens to [-1,2,1,2,1] ? Which one should and I match ?

@BDonnot
Copy link
Owner

BDonnot commented Jun 22, 2022

I chose to check only for the first one which might not be really nice in fact, more thoughts are needed I think

@marota
Copy link
Author

marota commented Jun 22, 2022

Hello,

I think that's a feature and not a bug, unfortunately

What if both [2,2,1,2,1] and [2,1,1,2,1] are in the list of the topology, what happens to [-1,2,1,2,1] ? Which one should and I match ?

Then yes both are legitimate. Yet in that case, you might only want to activate one of those two bits (chosen randomly) in the encoding to avoid redundancy. It would also make two examples to learn from one observation (but this is more a training optimisation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants