net.sourceforge.combean.graph.alg.flow
Class MinCostFlowByLPAlg

Package class diagram package MinCostFlowByLPAlg
java.lang.Object
  extended by net.sourceforge.combean.graph.alg.AbstractGraphAlg
      extended by net.sourceforge.combean.graph.alg.flow.MinCostFlowByLPAlg
All Implemented Interfaces:
AbstractFlowAlg, FeasibleFlowAlg, MinCostFlowAlg, GraphAlgorithm

public class MinCostFlowByLPAlg
extends AbstractGraphAlg
implements MinCostFlowAlg

An implementation of a min-cost flow algorithm using an LP solver.


Constructor Summary
MinCostFlowByLPAlg()
          constructor
 
Method Summary
 FixedDoubleEdgeMap getFlowMap()
          Return the calculated flow.
 double getTotalCost()
          Calculate the total cost of the flow.
 boolean isFeasible()
          Check if a feasible flow exists.
 void run()
          Execute the algorithm.
 void setEdgeCapacityMap(FixedDoubleEdgeMap edgeCapacities)
          Set the edge capacities.
 void setEdgeWeightsMap(FixedDoubleEdgeMap edgeWeights)
          Set the cost of one unit of flow for each edge.
 void setInflowMap(FixedDoubleNodeMap inflowMap)
          Set the inflow at each node in the graph.
 void setLpModelLoader(LPModelSolver lpModelLoader)
           
 void setLpSolver(LPSolver lpSolver)
           
 
Methods inherited from class net.sourceforge.combean.graph.alg.AbstractGraphAlg
getGraph, setGraph
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.combean.interfaces.graph.alg.GraphAlgorithm
getGraph, setGraph
 

Constructor Detail

MinCostFlowByLPAlg

public MinCostFlowByLPAlg()
constructor

Method Detail

setLpModelLoader

public final void setLpModelLoader(LPModelSolver lpModelLoader)
Parameters:
lpModelLoader -

setLpSolver

public final void setLpSolver(LPSolver lpSolver)
Parameters:
lpSolver - The lpSolver to set.

setEdgeWeightsMap

public void setEdgeWeightsMap(FixedDoubleEdgeMap edgeWeights)
Description copied from interface: MinCostFlowAlg
Set the cost of one unit of flow for each edge. If this map is not set, the cost is assumed to be zero for each edge.

Specified by:
setEdgeWeightsMap in interface MinCostFlowAlg
Parameters:
edgeWeights - a map containing the cost of each edge in the graph

setInflowMap

public void setInflowMap(FixedDoubleNodeMap inflowMap)
Description copied from interface: FeasibleFlowAlg
Set the inflow at each node in the graph. A positive value means that additional flow is injected at the node, whereas a negative value represents the fact that flow is drained from the network. If this map is not set, the flow balance at each node is assumed to be zero, i.e., inbound equals outbound flow.

Specified by:
setInflowMap in interface FeasibleFlowAlg
Parameters:
inflowMap - the inflow at each node.

setEdgeCapacityMap

public void setEdgeCapacityMap(FixedDoubleEdgeMap edgeCapacities)
Description copied from interface: AbstractFlowAlg
Set the edge capacities.

Specified by:
setEdgeCapacityMap in interface AbstractFlowAlg
Parameters:
edgeCapacities - a map containing the edge capacities.

run

public void run()
Description copied from interface: GraphAlgorithm
Execute the algorithm.

Specified by:
run in interface GraphAlgorithm

isFeasible

public boolean isFeasible()
Description copied from interface: FeasibleFlowAlg
Check if a feasible flow exists. May only be called after the algorithm has been executed.

Specified by:
isFeasible in interface FeasibleFlowAlg
Returns:
true if a feasible flow exists.

getTotalCost

public double getTotalCost()
Description copied from interface: MinCostFlowAlg
Calculate the total cost of the flow. May only be called after the algorithm has been executed.

Specified by:
getTotalCost in interface MinCostFlowAlg
Returns:
the total cost of the flow.

getFlowMap

public FixedDoubleEdgeMap getFlowMap()
Description copied from interface: AbstractFlowAlg
Return the calculated flow. May only be called after the algorithm has been executed.

Specified by:
getFlowMap in interface AbstractFlowAlg
Returns:
the calculated flow.