Skip to content
Snippets Groups Projects
Commit 064a8302 authored by David Radu's avatar David Radu
Browse files

testing LS bug

parent 64898db6
No related branches found
No related tags found
No related merge requests found
......@@ -27,17 +27,17 @@ siting_params:
SA:
set: True
neighborhood: 1
no_iterations: 2000
no_iterations: 500
no_epochs: 500
initial_temp: 100.
p: 0.1
no_runs: 100
no_runs_init: 50
no_runs: 10
no_runs_init: 100
algorithm: 'SGH' # 'MIR', 'SGH'
SGH:
set: False
p: 0.1
no_runs: 200
no_runs: 100
algorithm: 'SGH'
DGH:
set: False
......
......@@ -39,7 +39,7 @@ function main_SA(index_dict, deployment_dict, legacy_index_list,
x_init_alg, LB_init_alg = Array{Float64, 2}(undef, R_init, L), Array{Float64, 1}(undef, R_init)
for r = 1:R_init
if (div(r, 10) > 0) & (mod(r, 10) == 0)
@info "$(Dates.format(now(), "HH:MM:SS")) Run $(r)/$(R) of $(init_sol_algorithm)"
@info "$(Dates.format(now(), "HH:MM:SS")) Run $(r)/$(R_init) of $(init_sol_algorithm)"
end
x_init_alg[r, :], LB_init_alg[r] = randomised_greedy_heuristic_partition(D, c, n_partitions, p,
index_dict, legacy_index_list)
......
......@@ -126,8 +126,10 @@ function simulated_annealing_local_search_partition(D::Array{Float64, 2}, c::Flo
end
# Compute y and associated objective value
Dx_tmp .= Dx_incumbent
@inbounds for j in component_updates
Dx_tmp .= Dx_incumbent .+ view(D, :, ind_zeros2ones_tmp[j]) .- view(D, :, ind_ones2zeros_tmp[j])
Dx_tmp .+= view(D, :, ind_zeros2ones_tmp[j])
Dx_tmp .-= view(D, :, ind_ones2zeros_tmp[j])
end
y_tmp .= Dx_tmp .>= c
......
......@@ -73,11 +73,27 @@ if __name__ == '__main__':
criticality_data = xarray_to_ndarray(critical_window_mapping(time_windows_data, site_potential_data,
deployment_dict, model_parameters))
# deployment_dict = pickle.load(open(join(data_path, 'input/test/deployment_dict.p'), 'rb'))
# criticality_data = pickle.load(open(join(data_path, 'input/test/criticality_matrix.p'), 'rb'))
# site_coordinates = pickle.load(open(join(data_path, 'input/test/site_coordinates.p'), 'rb'))
# legacy_coordinates = pickle.load(open(join(data_path, 'input/test/legacy_coordinates.p'), 'rb'))
# site_positions = pickle.load(open(join(data_path, 'input/test/site_positions.p'), 'rb'))
jl_dict = generate_jl_input(deployment_dict, site_coordinates, site_positions, legacy_coordinates)
total_no_locs = sum(deployment_dict[r][t] for r in deployment_dict.keys() for t in deployment_dict[r].keys())
c = int(ceil(siting_parameters['c'] * total_no_locs))
pickle.dump(deployment_dict, open(join(data_path, 'input/test/deployment_dict.p'), 'wb'), protocol=4)
pickle.dump(criticality_data, open(join(data_path, 'input/test/criticality_matrix.p'), 'wb'), protocol=4)
pickle.dump(site_coordinates, open(join(data_path, 'input/test/site_coordinates.p'), 'wb'), protocol=4)
pickle.dump(legacy_coordinates, open(join(data_path, 'input/test/legacy_coordinates.p'), 'wb'), protocol=4)
pickle.dump(site_positions, open(join(data_path, 'input/test/site_positions.p'), 'wb'), protocol=4)
import sys
sys.exit()
logger.info('Data pre-processing finished. Opening Julia instance.')
j = julia.Julia(compiled_modules=False)
from julia import Main
Main.include("jl/SitingHeuristics.jl")
......@@ -143,9 +159,9 @@ if __name__ == '__main__':
jl_objective_pick = argmax(jl_obj)
jl_locations_vector = jl_sel[jl_objective_pick, :]
locations_dict = retrieve_location_dict(jl_locations_vector, model_parameters, site_positions)
retrieve_site_data(model_parameters, capacity_factors_data, criticality_data, deployment_dict,
site_positions, locations_dict, legacy_coordinates, output_folder, benchmark='PROD')
# locations_dict = retrieve_location_dict(jl_locations_vector, model_parameters, site_positions)
# retrieve_site_data(model_parameters, capacity_factors_data, criticality_data, deployment_dict,
# site_positions, locations_dict, legacy_coordinates, output_folder, benchmark='PROD')
pickle.dump(jl_sel, open(join(output_folder, 'solution_matrix.p'), 'wb'))
pickle.dump(jl_obj, open(join(output_folder, 'objective_vector.p'), 'wb'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment