Skip to content

Commit c89b05c

Browse files
authored
Merge pull request #32 from OptimalTransportNetworks/development
Development
2 parents c27a9d4 + f94b7de commit c89b05c

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

NEWS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
# 0.1.8
2+
3+
* Fixed dual solution with `cross_good_congestion = true`, and set the default `duality = true` in `init_parameters()`. It is highly recommended to keep `beta <= 1` in fixed labor cases to harness the dual solutions, which yield a tremendous speedup.
4+
5+
# 0.1.7
6+
7+
* If `duality = true`, in `init_parameters()` (and `labor_mobility = false` - no dual solutions available for mobile labor cases), a new direct dual implementation of the model is used (with hard-coded sparse hessians passed directly to Ipopt) which is significantly faster than any other means of solving the model (10x speedup). However, with `cross_good_congestion = true`, the dual solution may be inaccurate. This may be fixed in the future.
8+
19
# 0.1.6
10+
211
## Breaking Changes
312
* All spatial parameters, including `Lj`, `Lr`, `Hj`, `hj`, `Zjn`, `omegaj`, `omegar`, and `region` are now stored in the `graph` structure created by `create_graph()`. `create_graph()` therefore only returns the `graph` structure, instead of both the (updated) parameters and the graph. Converesely, `init_parameters()` only contains parameters that are independent of the particular geography defined by `create_graph()`.
413

@@ -7,7 +16,6 @@
716
* Better spline options for plotting frictions surface (geography).
817
* More faithful translation of `apply_geography()`.
918

10-
1119
# 0.1.5
1220

1321
* Removed the MATLAB toolbox and corresponding documentation (PDF files) from the repo to decrease size. A new repo was created for the MATLAB toolbox at [SebKrantz/OptimalTransportNetworkToolbox](https://github.com/SebKrantz/OptimalTransportNetworkToolbox). This repo and especially the `docs` folder continue to be very useful for Julia users, but are no longer part of the Julia library.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OptimalTransportNetworks"
22
uuid = "e2b46e68-897f-4e4e-ba36-a93c9789fd96"
33
authors = ["Sebastian Krantz <sebastian.krantz@graduateinstitute.ch>"]
4-
version = "0.1.7"
4+
version = "0.1.8"
55

66
[deps]
77
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"

src/main/init_parameters.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Returns a `param` dict with the model parameters. These are independent of the g
2020
- `m::Vector{Float64}=ones(N)`: Vector of weights Nx1 in the cross congestion cost function
2121
- `annealing::Bool=true`: Switch for the use of annealing at the end of iterations (only if gamma > beta)
2222
- `verbose::Bool=true`: Switch to turn on/off text output (from Ipopt or other optimizers)
23-
- `duality::Bool=false`: Switch to turn on/off duality whenever available
23+
- `duality::Bool=true`: Switch to turn on/off duality whenever available (fixed labor and beta <= 1)
2424
- `warm_start::Bool=true`: Use the previous solution as a warm start for the next iteration
2525
- `kappa_min::Float64=1e-5`: Minimum value for road capacities K
2626
- `min_iter::Int64=20`: Minimum number of iterations
@@ -42,7 +42,7 @@ param = init_parameters(K = 10, labor_mobility = true)
4242
function init_parameters(; alpha = 0.5, beta = 1, gamma = 1, K = 1, sigma = 5, rho = 2, a = 0.8, N = 1,
4343
labor_mobility = false, cross_good_congestion=false, nu = 2, m = ones(N),
4444
annealing=true,
45-
verbose = true, duality = false, warm_start = true,
45+
verbose = true, duality = true, warm_start = true,
4646
kappa_min = 1e-5, min_iter = 20, max_iter = 200, tol = 1e-5, kwargs...)
4747
param = Dict()
4848

src/models/solve_allocation_by_duality.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ function hessian_duality(
236236
end
237237

238238
# Assign result
239-
values[ind] = -obj_factor * term + 1e-5 # Somehow need this increment to make it work
239+
values[ind] = -obj_factor * term # + 1e-5 # Somehow need this increment to make it work
240240
end
241241
end
242242
return

src/models/solve_allocation_by_duality_cgc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function hessian_duality_cgc(
230230
end
231231

232232
# Assign result
233-
values[ind] = -obj_factor * term + 1e-6
233+
values[ind] = -obj_factor * term # + 1e-6
234234
end
235235
end
236236
return
@@ -280,7 +280,7 @@ function recover_allocation_duality_cgc(x, auxdata)
280280
LL = max.(Lambda' - Lambda, 0) # P^n_k - P^n_j (non-negative flows)
281281
Qjk += m[n] * (LL / m[n]) .^ (nu/(nu-1))
282282
end
283-
Qjk = (Qjk .* temp) .^ (nu-1)/(nu*beta)
283+
Qjk = (Qjk .* temp) .^ ((nu-1)/(nu*beta))
284284

285285
# Calculate the flows Qjkn
286286
Qjkn = zeros(graph.J, graph.J, param.N)

0 commit comments

Comments
 (0)