Double-precision floating-point format

From formulasearchengine
Revision as of 01:23, 12 November 2013 by en>Grudgekeyper (Added how subnormal numbers are calculated)
Jump to navigation Jump to search

The Ford–Fulkerson method is an algorithm which computes the maximum flow in a flow network. It was published in 1956 by L. R. Ford, Jr. and D. R. Fulkerson.[1] The name "Ford–Fulkerson" is often also used for the Edmonds–Karp algorithm, which is a specialization of Ford–Fulkerson.

The idea behind the algorithm is as follows: As long as there is a path from the source (start node) to the sink (end node), with available capacity on all edges in the path, we send flow along one of these paths. Then we find another path, and so on. A path with available capacity is called an augmenting path.

Algorithm

Let G(V,E) be a graph, and for each edge from u to v, let c(u,v) be the capacity and f(u,v) be the flow. We want to find the maximum flow from the source s to the sink t. After every step in the algorithm the following is maintained:

Capacity constraints: (u,v)E f(u,v)c(u,v) The flow along an edge can not exceed its capacity.
Skew symmetry: (u,v)E f(u,v)=f(v,u) The net flow from u to v must be the opposite of the net flow from v to u (see example).
Flow conservation: uV:us and utwVf(u,w)=0 That is, unless u is s or t. The net flow to a node is zero, except for the source, which "produces" flow, and the sink, which "consumes" flow.

This means that the flow through the network is a legal flow after each round in the algorithm. We define the residual network Gf(V,Ef) to be the network with capacity cf(u,v)=c(u,v)f(u,v) and no flow. Notice that it can happen that a flow from v to u is allowed in the residual network, though disallowed in the original network: if f(u,v)>0 and c(v,u)=0 then cf(v,u)=c(v,u)f(v,u)=f(u,v)>0.

Algorithm Ford–Fulkerson

Inputs Graph G with flow capacity c, a source node s, and a sink node t
Output A flow f from s to t which is a maximum
  1. f(u,v)0 for all edges (u,v)
  2. While there is a path p from s to t in Gf, such that cf(u,v)>0 for all edges (u,v)p:
    1. Find cf(p)=min{cf(u,v):(u,v)p}
    2. For each edge (u,v)p
      1. f(u,v)f(u,v)+cf(p) (Send flow along the path)
      2. f(v,u)f(v,u)cf(p) (The flow might be "returned" later)

The path in step 2 can be found with for example a breadth-first search or a depth-first search in Gf(V,Ef). If you use the former, the algorithm is called Edmonds–Karp.

When no more paths in step 2 can be found, s will not be able to reach t in the residual network. If S is the set of nodes reachable by s in the residual network, then the total capacity in the original network of edges from S to the remainder of V is on the one hand equal to the total flow we found from s to t, and on the other hand serves as an upper bound for all such flows. This proves that the flow we found is maximal. See also Max-flow Min-cut theorem.

If the graph G(V,E) has multi Sources and Sinks, we act as follows. Suppose that T={t|tisasink} and S={s|sisasource}. Add a new source s with an edge (s,s) from s to every node sS, with capacity f(s,s)=ds(ds=(s,u)Ef(s,u)) . And add a new sink t with an edge (t,t) from t to every node tT, with capacity f(t,t)=dt(dt=(v,t)Ef(v,t)). Then applying the Ford–Fulkerson algorithm.

Also if every nodes u has constraint du, we replace this node with two nodes uin,uout, and an edge (uin,uout), with capacity f(uin,uout)=du. and then applying the Ford–Fulkerson algorithm.

Complexity

By adding the flow augmenting path to the flow already established in the graph, the maximum flow will be reached when no more flow augmenting paths can be found in the graph. However, there is no certainty that this situation will ever be reached, so the best that can be guaranteed is that the answer will be correct if the algorithm terminates. In the case that the algorithm runs forever, the flow might not even converge towards the maximum flow. However, this situation only occurs with irrational flow values. When the capacities are integers, the runtime of Ford-Fulkerson is bounded by O(Ef) (see big O notation), where E is the number of edges in the graph and f is the maximum flow in the graph. This is because each augmenting path can be found in O(E) time and increases the flow by an integer amount which is at least 1.

A variation of the Ford–Fulkerson algorithm with guaranteed termination and a runtime independent of the maximum flow value is the Edmonds–Karp algorithm, which runs in O(VE2) time.

Integral example

The following example shows the first steps of Ford–Fulkerson in a flow network with 4 nodes, source A and sink D. This example shows the worst-case behaviour of the algorithm. In each step, only a flow of 1 is sent across the network. If breadth-first-search were used instead, only two steps would be needed.

Path Capacity Resulting flow network
Initial flow network
A,B,C,D min(cf(A,B),cf(B,C),cf(C,D))=

min(c(A,B)f(A,B),c(B,C)f(B,C),c(C,D)f(C,D))=
min(10000,10,10000)=1

A,C,B,D min(cf(A,C),cf(C,B),cf(B,D))=

min(c(A,C)f(A,C),c(C,B)f(C,B),c(B,D)f(B,D))=
min(10000,0(1),10000)=1

After 1998 more steps …
Final flow network

Notice how flow is "pushed back" from C to B when finding the path A,C,B,D.

Non-terminating example

Consider the flow network shown on the right, with source s, sink t, capacities of edges e1, e2 and e3 respectively 1, r=(51)/2 and 1 and the capacity of all other edges some integer M2. The constant r was chosen so, that r2=1r. We use augmenting paths according to the following table, where p1={s,v4,v3,v2,v1,t}, p2={s,v2,v3,v4,t} and p3={s,v1,v2,v3,t}.

Step Augmenting path Sent flow Residual capacities
e1 e2 e3
0 r0=1 r 1
1 {s,v2,v3,t} 1 r0 r1 0
2 p1 r1 r2 0 r1
3 p2 r1 r2 r1 0
4 p1 r2 0 r3 r2
5 p3 r2 r2 r3 0

Note that after step 1 as well as after step 5, the residual capacities of edges e1, e2 and e3 are in the form rn, rn+1 and 0, respectively, for some n. This means that we can use augmenting paths p1, p2, p1 and p3 infinitely many times and residual capacities of these edges will always be in the same form. Total flow in the network after step 5 is 1+2(r1+r2). If we continue to use augmenting paths as above, the total flow converges to 1+2i=1ri=3+2r, while the maximum flow is 2M+1. In this case, the algorithm never terminates and the flow doesn't even converge to the maximum flow.[2]

50 year old Petroleum Engineer Kull from Dawson Creek, spends time with interests such as house brewing, property developers in singapore condo launch and camping. Discovers the beauty in planing a trip to places around the entire world, recently only coming back from .

Python implementation

class Edge(object):
    def __init__(self, u, v, w):
        self.source = u
        self.sink = v  
        self.capacity = w
    def __repr__(self):
        return "%s->%s:%s" % (self.source, self.sink, self.capacity)

class FlowNetwork(object):
    def __init__(self):
        self.adj = {}
        self.flow = {}
 
    def add_vertex(self, vertex):
        self.adj[vertex] = []
 
    def get_edges(self, v):
        return self.adj[v]
 
    def add_edge(self, u, v, w=0):
        if u == v:
            raise ValueError("u == v")
        edge = Edge(u,v,w)
        redge = Edge(v,u,0)
        edge.redge = redge  #redge is not defined in Edge class
        redge.redge = edge
        self.adj[u].append(edge)
        self.adj[v].append(redge)
        self.flow[edge] = 0
        self.flow[redge] = 0
 
    def find_path(self, source, sink, path):
        if source == sink:
            return path
        for edge in self.get_edges(source):
            residual = edge.capacity - self.flow[edge]
            if residual > 0 and not edge in path:
                result = self.find_path( edge.sink, sink, path + [edge]) 
                if result != None:
                    return result
 
    def max_flow(self, source, sink):
        path = self.find_path(source, sink, [])
        while path != None:
            residuals = [edge.capacity - self.flow[edge] for edge in path]
            flow = min(residuals)
            for edge in path:
                self.flow[edge] += flow
                self.flow[edge.redge] -= flow
            path = self.find_path(source, sink, [])
        return sum(self.flow[edge] for edge in self.get_edges(source))

Usage example

For the example flow network in maximum flow problem we do the following:

>>> g = FlowNetwork()
>>> [g.add_vertex(v) for v in "sopqrt"]
[None, None, None, None, None, None]
>>> g.add_edge('s','o',3)
>>> g.add_edge('s','p',3)
>>> g.add_edge('o','p',2)
>>> g.add_edge('o','q',3)
>>> g.add_edge('p','r',2)
>>> g.add_edge('r','t',3)
>>> g.add_edge('q','r',4)
>>> g.add_edge('q','t',2)
>>> print g.max_flow('s','t')
5

Notes

43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

References

  • 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534
  • 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534
  • 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534

Template:Commonscat-inline

  1. Template:Cite doi
  2. One of the biggest reasons investing in a Singapore new launch is an effective things is as a result of it is doable to be lent massive quantities of money at very low interest rates that you should utilize to purchase it. Then, if property values continue to go up, then you'll get a really high return on funding (ROI). Simply make sure you purchase one of the higher properties, reminiscent of the ones at Fernvale the Riverbank or any Singapore landed property Get Earnings by means of Renting

    In its statement, the singapore property listing - website link, government claimed that the majority citizens buying their first residence won't be hurt by the new measures. Some concessions can even be prolonged to chose teams of consumers, similar to married couples with a minimum of one Singaporean partner who are purchasing their second property so long as they intend to promote their first residential property. Lower the LTV limit on housing loans granted by monetary establishments regulated by MAS from 70% to 60% for property purchasers who are individuals with a number of outstanding housing loans on the time of the brand new housing purchase. Singapore Property Measures - 30 August 2010 The most popular seek for the number of bedrooms in Singapore is 4, followed by 2 and three. Lush Acres EC @ Sengkang

    Discover out more about real estate funding in the area, together with info on international funding incentives and property possession. Many Singaporeans have been investing in property across the causeway in recent years, attracted by comparatively low prices. However, those who need to exit their investments quickly are likely to face significant challenges when trying to sell their property – and could finally be stuck with a property they can't sell. Career improvement programmes, in-house valuation, auctions and administrative help, venture advertising and marketing, skilled talks and traisning are continuously planned for the sales associates to help them obtain better outcomes for his or her shoppers while at Knight Frank Singapore. No change Present Rules

    Extending the tax exemption would help. The exemption, which may be as a lot as $2 million per family, covers individuals who negotiate a principal reduction on their existing mortgage, sell their house short (i.e., for lower than the excellent loans), or take part in a foreclosure course of. An extension of theexemption would seem like a common-sense means to assist stabilize the housing market, but the political turmoil around the fiscal-cliff negotiations means widespread sense could not win out. Home Minority Chief Nancy Pelosi (D-Calif.) believes that the mortgage relief provision will be on the table during the grand-cut price talks, in response to communications director Nadeam Elshami. Buying or promoting of blue mild bulbs is unlawful.

    A vendor's stamp duty has been launched on industrial property for the primary time, at rates ranging from 5 per cent to 15 per cent. The Authorities might be trying to reassure the market that they aren't in opposition to foreigners and PRs investing in Singapore's property market. They imposed these measures because of extenuating components available in the market." The sale of new dual-key EC models will even be restricted to multi-generational households only. The models have two separate entrances, permitting grandparents, for example, to dwell separately. The vendor's stamp obligation takes effect right this moment and applies to industrial property and plots which might be offered inside three years of the date of buy. JLL named Best Performing Property Brand for second year running

    The data offered is for normal info purposes only and isn't supposed to be personalised investment or monetary advice. Motley Fool Singapore contributor Stanley Lim would not personal shares in any corporations talked about. Singapore private home costs increased by 1.eight% within the fourth quarter of 2012, up from 0.6% within the earlier quarter. Resale prices of government-built HDB residences which are usually bought by Singaporeans, elevated by 2.5%, quarter on quarter, the quickest acquire in five quarters. And industrial property, prices are actually double the levels of three years ago. No withholding tax in the event you sell your property. All your local information regarding vital HDB policies, condominium launches, land growth, commercial property and more

    There are various methods to go about discovering the precise property. Some local newspapers (together with the Straits Instances ) have categorised property sections and many local property brokers have websites. Now there are some specifics to consider when buying a 'new launch' rental. Intended use of the unit Every sale begins with 10 p.c low cost for finish of season sale; changes to 20 % discount storewide; follows by additional reduction of fiftyand ends with last discount of 70 % or extra. Typically there is even a warehouse sale or transferring out sale with huge mark-down of costs for stock clearance. Deborah Regulation from Expat Realtor shares her property market update, plus prime rental residences and houses at the moment available to lease Esparina EC @ Sengkang