# (A, B, Y) = FacilitiesData() # # Generates data that includes a matrix B of connections between x # locations (facilities), A the matrix representing connections y # (source) locations and x (facility) locations, and Y of size m-by-2 # (m == 4) representing source locations. function FacilitiesData() Y = float([0 0; 1 0; 0 1; 1 1]); # Connect resource sources to facilities on the sides, respectively super_low_cost = .01; low_cost = .94; high_cost = 1.0; A = (low_cost * [0 1 0 0; 1 0 0 0; 0 0 1 0; 0 0 0 1] + high_cost * [1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0] + super_low_cost * [0 0 1 0; 0 0 0 1; 0 1 0 0; 1 0 0 0]); # Connect facilities in a cycle B = .05 * float([0 1 0 0; 0 0 1 0; 0 0 0 1; 1 0 0 0]); return (A, B, Y); end # PlotFacilities(A::Array{Float64,2}, B::Array{Float64, 2} # X::Array{Float64, 2}, Y::Array{Float64, 2}) # # Plots facility and source locations, along with active paths between # them. Facilities are printed as dark boxes, locations as light # (white) boxes. Arguments: # # A - prices per unit transport between sources and facilities (m-by-n) # B - prices per unit transport between facilities (n-by-n) # X - n-by-2 matrix of facility locations # Y - m-by-2 matrix of source locations function PlotFacilities(A::Array{Float64, 2}, B::Array{Float64, 2}, X::Array{Float64, 2}, Y::Array{Float64, 2}) figure(); nn = size(X, 1); mm = size(Y, 1); # Plot the Y locations, the source points for ii = 1:size(Y, 1) plot(Y[ii, 1], Y[ii, 2], color="k", markersize=12, marker="o", markerfacecolor=[1,1,1]); end # First, plot the X locations, which are the actual placed facilities for ii = 1:size(X, 1) plot(X[ii, 1], X[ii, 2], color="k", markersize=8, marker="s", markerfacecolor="k"); end # Plot the edges between X and Y for ii = 1:mm for jj = 1:nn if (A[ii, jj] > 0) # Draw edge between Y[ii, :] and X[jj, :] plot([Y[ii, 1], X[jj, 1]], [Y[ii, 2], X[jj, 2]], color="k", linewidth=2, linestyle="-."); end end end # Plot the edges between X and X for ii = 1:nn for jj = 1:nn if (B[ii, jj] > 0) plot([X[ii, 1], X[jj, 1]], [X[ii, 2], X[jj, 2]], color="k", linewidth=2, linestyle="--"); end end end horiz_min = minimum(Y[:, 1]); horiz_max = maximum(Y[:, 1]); vert_min = minimum(Y[:, 2]); vert_max = maximum(Y[:, 2]); xticks([]); yticks([]); dh = .05 * (horiz_max - horiz_min); dv = .05 * (vert_max - vert_min); axis([horiz_min - dh, horiz_max + dh, vert_min - dv, vert_max + dv]); end