Network Models

Shortest Path

OperationsResearchModels.solveMethod
solve(problem)

Description

Solves a shortest path problem given by an object of in type ShortestPathProblem.

Arguments

problem::ShortestPathProblem: The problem in type of ShortestPathProblem

Output

ShortestPathResult: The custom data type that holds path and cost.

Example

julia> conns = [
                   Connection(1, 2, 3),
                   Connection(1, 3, 2),
                   Connection(1, 4, 4),
                   Connection(2, 5, 3),
                   Connection(3, 5, 1),
                   Connection(3, 6, 1),
                   Connection(4, 6, 2),
                   Connection(5, 7, 6),
                   Connection(6, 7, 5),
               ];

julia> solve(ShortestPathProblem(conns));

julia> result.path
3-element Vector{Connection}:
 Connection(1, 3, 2, "x13")
 Connection(3, 6, 1, "x36")
 Connection(6, 7, 5, "x67")

julia> result.cost
8.0
source

Maximum Flow

OperationsResearchModels.solveMethod
solve(problem)

Arguments

problem::MaximumFlowProblem: The problem in type of MaximumFlowProblem

Output

MaximumFlowResult: The custom data type that holds path and flow.

Example

julia> conns = [
                   Connection(1, 2, 3),
                   Connection(1, 3, 2),
                   Connection(1, 4, 4),
                   Connection(2, 5, 3),
                   Connection(3, 5, 1),
                   Connection(3, 6, 1),
                   Connection(4, 6, 2),
                   Connection(5, 7, 6),
                   Connection(6, 7, 5),
               ];
julia> problem = MaximumFlowProblem(conns)
julia> result = solve(problem);

julia> result.path
9-element Vector{Connection}:
 Connection(1, 2, 3.0, "x12")
 Connection(1, 3, 2.0, "x13")
 Connection(1, 4, 2.0, "x14")
 Connection(2, 5, 3.0, "x25")
 Connection(3, 5, 1.0, "x35")
 Connection(3, 6, 1.0, "x36")
 Connection(4, 6, 2.0, "x46")
 Connection(5, 7, 4.0, "x57")
 Connection(6, 7, 3.0, "x67")

julia> result.flow
7.0
source

Minimum Spanning Tree

OperationsResearchModels.solveMethod
solve(problem::MstProblem)

Arguments

  • problem::MstProblem: The problem in type of MstProblem

Description

Obtains the minimum spanning tree.

Output

  • ::MstResult: A MstResult object that holds the results.

Examples

julia> conns = Connection[
                       Connection(1, 2, 10),
                       Connection(2, 3, 10),
                       Connection(3, 4, 10),
                       Connection(1, 4, 10)
                   ]

4-element Vector{Connection}:
 Connection(1, 2, 10, "x12")
 Connection(2, 3, 10, "x23")
 Connection(3, 4, 10, "x34")
 Connection(1, 4, 10, "x14")

 julia> result = solve(MstProblem(conns))
 MstResult(Connection[Connection(3, 4, 10, "x34"), Connection(1, 4, 10, "x14"), Connection(2, 3, 10, "x23")], 30.0)
 
 julia> result.distance
 30.0
 
 julia> result.connections
 3-element Vector{Connection}:
  Connection(3, 4, 10, "x34")
  Connection(1, 4, 10, "x14")
  Connection(2, 3, 10, "x23")
source