def add_uncontrollable(fro, to, lb, ub, edge_id):

            # no negative lower bound
            # no infinite upperbound
            assert lb <= ub
            assert not lb < 0
            assert not math.isinf(ub)

            ub_edge = DistanceGraphEdge(fro, to, ub, EdgeType.SIMPLE, renaming=renaming)
            lb_edge = DistanceGraphEdge(to, fro, -lb, EdgeType.SIMPLE, renaming=renaming)

            if edge_id is not None:
                # Note that the sign for the upper and lower bound supports are reversed
                # Since they are being subtracted during the reduction
                self.edge_support[ub_edge] = EdgeSupport.base({(EdgeSupport.UPPER, edge_id): -1,})
                self.edge_support[lb_edge] = EdgeSupport.base({(EdgeSupport.LOWER, edge_id): 1,})
            else:
                self.edge_support[ub_edge] = EdgeSupport.base({})
                self.edge_support[lb_edge] = EdgeSupport.base({})

            #edge_list.append(ub_edge)
            #edge_list.append(lb_edge)
            #contingent_nodes.append(to)
            if to in contingent_edges_at_node:
                collection = contingent_edges_at_node[to]
                collection.append(lb_edge)
                collection.append(ub_edge)
            else:
                collection = []
                collection.append(lb_edge)
                collection.append(ub_edge)
                contingent_edges_at_node[to] = collection
Exemple #2
0
        def add_controllable(fro, to, lb, ub, edge_id):

            # lb cannot be larger than ub
            # assert lb <= ub

            ub_edge = DistanceGraphEdge(fro, to, ub, EdgeType.SIMPLE, renaming=renaming)
            lb_edge = DistanceGraphEdge(to, fro, -lb, EdgeType.SIMPLE, renaming=renaming)
            if edge_id is not None:
                self.edge_support[ub_edge] = EdgeSupport.base({
                                                                 (EdgeSupport.UPPER, edge_id): 1,
                                                              })
                self.edge_support[lb_edge] = EdgeSupport.base({
                                                                  (EdgeSupport.LOWER, edge_id): -1,
                                                              })
            else:
                self.edge_support[ub_edge] = EdgeSupport.base({})
                self.edge_support[lb_edge] = EdgeSupport.base({})

            if not math.isinf(ub):
                edge_list.append(ub_edge)
                # print("UB edge: "+ str(ub_edge))
            # else:
            #     print("Ignoring +inf UB of " + e.id)

            if not math.isinf(lb):
                edge_list.append(lb_edge)
Exemple #3
0
        def add_uncontrollable(fro, to, lb, ub, edge_id):

            # no negative lower bound
            # no infinite upperbound
            assert lb <= ub
            assert not lb < 0
            assert not math.isinf(ub)

            ub_edge = DistanceGraphEdge(fro,
                                        to,
                                        ub,
                                        EdgeType.SIMPLE,
                                        renaming=renaming)
            lb_edge = DistanceGraphEdge(to,
                                        fro,
                                        -lb,
                                        EdgeType.SIMPLE,
                                        renaming=renaming)

            if edge_id is not None:
                # Note that the sign for the upper and lower bound supports are reversed
                # Since they are being subtracted during the reduction
                self.edge_support[ub_edge] = EdgeSupport.base({
                    (EdgeSupport.UPPER, edge_id):
                    -1,
                })
                self.edge_support[lb_edge] = EdgeSupport.base({
                    (EdgeSupport.LOWER, edge_id):
                    1,
                })
            else:
                self.edge_support[ub_edge] = EdgeSupport.base({})
                self.edge_support[lb_edge] = EdgeSupport.base({})

            #edge_list.append(ub_edge)
            #edge_list.append(lb_edge)
            #contingent_nodes.append(to)
            if to in contingent_edges_at_node:
                collection = contingent_edges_at_node[to]
                collection.append(lb_edge)
                collection.append(ub_edge)
            else:
                collection = []
                collection.append(lb_edge)
                collection.append(ub_edge)
                contingent_edges_at_node[to] = collection
Exemple #4
0
        def add_controllable(fro, to, lb, ub, edge_id):

            # lb cannot be larger than ub
            # assert lb <= ub

            ub_edge = DistanceGraphEdge(fro,
                                        to,
                                        ub,
                                        EdgeType.SIMPLE,
                                        renaming=renaming)
            lb_edge = DistanceGraphEdge(to,
                                        fro,
                                        -lb,
                                        EdgeType.SIMPLE,
                                        renaming=renaming)

            if edge_id is not None:
                self.edge_support[ub_edge] = EdgeSupport.base({
                    (EdgeSupport.UPPER, edge_id):
                    1,
                })
                self.edge_support[lb_edge] = EdgeSupport.base({
                    (EdgeSupport.LOWER, edge_id):
                    -1,
                })
            else:
                self.edge_support[ub_edge] = EdgeSupport.base({})
                self.edge_support[lb_edge] = EdgeSupport.base({})

            if not math.isinf(ub):
                edge_list.append(ub_edge)
            # else:
            #     print("Ignoring +inf UB of " + e.id)

            if not math.isinf(lb):
                edge_list.append(lb_edge)
Exemple #5
0
        def add_uncontrollable(fro, new_node, to, lb, ub, edge_id):

            # no negative lower bound
            # no infinite upperbound
            assert lb <= ub
            assert not lb < 0
            assert not math.isinf(ub)

            if new_node is not None:
                lb_ub_edge = DistanceGraphEdge(fro, new_node, lb, EdgeType.SIMPLE, renaming=renaming)
                lb_lb_edge = DistanceGraphEdge(new_node, fro, -lb, EdgeType.SIMPLE, renaming=renaming)
                self.edge_support[lb_ub_edge] = EdgeSupport.base({
                                                                    (EdgeSupport.LOWER, edge_id): 1,
                                                                 })
                self.edge_support[lb_lb_edge] = EdgeSupport.base({
                                                                    (EdgeSupport.LOWER, edge_id): -1,
                                                                })

                edge_list.append(lb_ub_edge)
                edge_list.append(lb_lb_edge)

                # print("LBUB edge: "+ str(lb_ub_edge))
                # print("LBLB edge: "+ str(lb_lb_edge))
            else:
                new_node = fro

            ub_edge = DistanceGraphEdge(new_node, to, ub-lb, EdgeType.SIMPLE, renaming=renaming)
            lb_edge = DistanceGraphEdge(to, new_node, 0, EdgeType.SIMPLE, renaming=renaming)

            self.edge_support[ub_edge] = EdgeSupport.base({
                                                              (EdgeSupport.LOWER, edge_id): -1,
                                                              (EdgeSupport.UPPER, edge_id): 1,
                                                          })
            self.edge_support[lb_edge] = EdgeSupport.base({})

            ub_cond_edge = DistanceGraphEdge(to, new_node, lb-ub, EdgeType.UPPER_CASE, to, renaming=renaming)
            lb_cond_edge = DistanceGraphEdge(new_node, to, 0, EdgeType.LOWER_CASE, to, renaming=renaming)

            self.edge_support[ub_cond_edge] =  EdgeSupport.base({
                                                                (EdgeSupport.LOWER, edge_id): 1,
                                                                (EdgeSupport.UPPER, edge_id): -1,
                                                           })
            self.edge_support[lb_cond_edge] = EdgeSupport.base({})

            edge_list.append(ub_edge)
            edge_list.append(lb_edge)
            edge_list.append(ub_cond_edge)
            edge_list.append(lb_cond_edge)
Exemple #6
0
        def add_uncontrollable(fro, new_node, to, lb, ub, edge_id):

            # no negative lower bound
            # no infinite upperbound
            assert lb <= ub
            assert not lb < 0
            assert not math.isinf(ub)

            if new_node is not None:
                lb_ub_edge = DistanceGraphEdge(fro,
                                               new_node,
                                               lb,
                                               EdgeType.SIMPLE,
                                               renaming=renaming)
                lb_lb_edge = DistanceGraphEdge(new_node,
                                               fro,
                                               -lb,
                                               EdgeType.SIMPLE,
                                               renaming=renaming)
                self.edge_support[lb_ub_edge] = EdgeSupport.base({
                    (EdgeSupport.LOWER, edge_id):
                    1,
                })
                self.edge_support[lb_lb_edge] = EdgeSupport.base({
                    (EdgeSupport.LOWER, edge_id):
                    -1,
                })

                edge_list.append(lb_ub_edge)
                edge_list.append(lb_lb_edge)

                # print("LBUB edge: "+ str(lb_ub_edge))
                # print("LBLB edge: "+ str(lb_lb_edge))
            else:
                new_node = fro

            ub_edge = DistanceGraphEdge(new_node,
                                        to,
                                        ub - lb,
                                        EdgeType.SIMPLE,
                                        renaming=renaming)
            lb_edge = DistanceGraphEdge(to,
                                        new_node,
                                        0,
                                        EdgeType.SIMPLE,
                                        renaming=renaming)

            self.edge_support[ub_edge] = EdgeSupport.base({
                (EdgeSupport.LOWER, edge_id):
                -1,
                (EdgeSupport.UPPER, edge_id):
                1,
            })
            self.edge_support[lb_edge] = EdgeSupport.base({})

            ub_cond_edge = DistanceGraphEdge(to,
                                             new_node,
                                             lb - ub,
                                             EdgeType.UPPER_CASE,
                                             to,
                                             renaming=renaming)
            lb_cond_edge = DistanceGraphEdge(new_node,
                                             to,
                                             0,
                                             EdgeType.LOWER_CASE,
                                             to,
                                             renaming=renaming)

            self.edge_support[ub_cond_edge] = EdgeSupport.base({
                (EdgeSupport.LOWER, edge_id):
                1,
                (EdgeSupport.UPPER, edge_id):
                -1,
            })
            self.edge_support[lb_cond_edge] = EdgeSupport.base({})

            edge_list.append(ub_edge)
            edge_list.append(lb_edge)
            edge_list.append(ub_cond_edge)
            edge_list.append(lb_cond_edge)