|
43 | 43 | - `balancedProblem::TransportationProblem`: The balanced transportation problem. |
44 | 44 | - `solution::Matrix`: The solution matrix of the transportation problem. |
45 | 45 | - `cost::Real`: The optimal cost of the transportation problem. |
| 46 | +- `model::Union{JuMP.Model, Nothing}`: The JuMP model used to solve the transportation problem. Methods that |
| 47 | + do not use JuMP will set this field to `nothing`. |
| 48 | +
|
46 | 49 |
|
47 | 50 | # Description |
48 | 51 |
|
49 | 52 | The `TransportationResult` struct represents the result of solving a transportation problem. |
50 | 53 | It contains the original problem, the balanced problem, the solution matrix, and the optimal cost. |
| 54 | +
|
51 | 55 | """ |
52 | 56 | struct TransportationResult |
53 | 57 | originalProblem::TransportationProblem |
54 | 58 | balancedProblem::TransportationProblem |
55 | 59 | solution::Matrix |
56 | 60 | cost::Real |
| 61 | + model::Union{JuMP.Model, Nothing} |
57 | 62 | end |
58 | 63 |
|
59 | 64 | function Base.show(io::IO, t::TransportationProblem) |
@@ -202,7 +207,7 @@ function solve( |
202 | 207 | solution = value.(x) |
203 | 208 | cost = JuMP.objective_value(model) |
204 | 209 |
|
205 | | - result = TransportationResult(t, newt, solution, cost) |
| 210 | + result = TransportationResult(t, newt, solution, cost, model) |
206 | 211 | return result |
207 | 212 | end |
208 | 213 |
|
@@ -253,7 +258,7 @@ function northwestcorner(t::TransportationProblem)::TransportationResult |
253 | 258 | end |
254 | 259 |
|
255 | 260 | cost = problem.costs .* asgnmatrix |> sum |
256 | | - result = TransportationResult(t, problem, asgnmatrix, cost) |
| 261 | + result = TransportationResult(t, problem, asgnmatrix, cost, nothing) |
257 | 262 | return result |
258 | 263 | end |
259 | 264 |
|
@@ -295,13 +300,13 @@ function leastcost(t::TransportationProblem)::TransportationResult |
295 | 300 | end |
296 | 301 | cost += amount * mincost |
297 | 302 | end |
298 | | - result = TransportationResult(t, problem, asgnmatrix, cost) |
| 303 | + result = TransportationResult(t, problem, asgnmatrix, cost, nothing) |
299 | 304 | return result |
300 | 305 | end |
301 | 306 |
|
302 | 307 |
|
303 | 308 | function NoInitial(t::TransportationProblem)::TransportationResult |
304 | | - TransportationResult(t, t, zeros(size(t.costs)), 0.0) |
| 309 | + TransportationResult(t, t, zeros(size(t.costs)), 0.0, nothing) |
305 | 310 | end |
306 | 311 |
|
307 | 312 |
|
|
0 commit comments