Transportation Problem

The Solver

OperationsResearchModels.solve — Method
solve(t, initial = NoInitial)

Arguments

  • t::TransportationProblem: The problem in type of TransportationProblem
  • initial::TransportationResult: The initial solution of the transportation problem (optional). The default is NoInitial.

Output

  • TransportationResult: The custom data type that holds problem, solution, and optimum cost.

Description

Solves a transportation problem given by an object of in type TransportationProblem.

initial is used to store the initial solution of the transportation problem. Any custom implementation should take a TransportationProblem and return a TransportationResult object. Currently, northwestcorner and leastcost are implemented as custom initial solutions.

Example

t = TransportationProblem(
    [   1 1 1 1; 
        2 2 2 2; 
        3 3 3 3], 
    [100, 100, 100, 100], # Demands 
    [100, 100, 100])      # Supplies 


println(isbalanced(t))
# false

result = solve(t)

println(result)

# Transportation Results:
# Main problem:
# Transportation Problem:
# Costs: [1 1 1 1; 2 2 2 2; 3 3 3 3]
# Demand: [100, 100, 100, 100]
# Supply: [100, 100, 100]
# 
# Balanced problem:
# Transportation Problem:
# Costs: [1 1 1 1; 2 2 2 2; 3 3 3 3; 0 0 0 0]
# Demand: [100, 100, 100, 100]
# Supply: [100, 100, 100, 100]
# 
# Cost:
# 600.0
# Solution:
# [-0.0 -0.0 -0.0 100.0; 100.0 -0.0 -0.0 -0.0; -0.0 -0.0 100.0 -0.0; -0.0 100.0 -0.0 -0.0]

See also TransportationResult, solve(::TransportationProblem)

source
OperationsResearchModels.Transportation.TransportationResult — Type
TransportationResult(problem, balancedProblem, solution, cost)

Fields

  • problem::TransportationProblem: The original transportation problem.
  • balancedProblem::TransportationProblem: The balanced transportation problem.
  • solution::Matrix: The solution matrix of the transportation problem.
  • cost::Real: The optimal cost of the transportation problem.
  • model::Union{JuMP.Model, Nothing}: The JuMP model used to solve the transportation problem. Methods that do not use JuMP will set this field to nothing.

Description

The TransportationResult struct represents the result of solving a transportation problem. It contains the original problem, the balanced problem, the solution matrix, and the optimal cost.

See also TransportationProblem, solve(::TransportationProblem)

source

Initial basic solutions for a transportation problem

North-west Corner Method

OperationsResearchModels.Transportation.northwestcorner — Function
northwestcorner(a::TransportationProblem)::TransportationResult

Description

The northwest corner method is a heuristic for finding an initial basic feasible solution to a transportation problem. It starts at the northwest corner of the cost matrix and allocates as much as possible to the cell, then moves either down or right depending on whether the supply or demand has been met. The method continues until all supply and demand constraints are satisfied.

Arguments

  • a::TransportationProblem: The problem in type of TransportationProblem

Output

  • TransportationResult: The custom data type that holds problem, solution, and optimum cost.

See also TransportationResult, solve(::TransportationProblem)

source

The Least Cost Method

OperationsResearchModels.Transportation.leastcost — Function
leastcost(a::TransportationProblem)::TransportationResult

Description

The least cost method is a heuristic for finding an initial basic feasible solution to a transportation problem. It processes cells from lowest to highest cost, allocating as much as possible whenever both the corresponding supply and demand remain positive.

Arguments

  • a::TransportationProblem: The problem in type of TransportationProblem

Output

  • TransportationResult: The custom data type that holds problem, solution, and optimum cost.

See also TransportationResult, solve(::TransportationProblem)

source