Skip to content

Commit ccd6f66

Browse files
Merge pull request #90 from holgerteichgraeber/data_type
Bug #48
2 parents aa493af + 48f33b4 commit ccd6f66

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

src/clustering/run_clust.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ function run_clust(data::ClustData;
2626

2727
#clustering
2828
clust_data, cost, centers_all, weights_all, clustids_all, cost_all, iter_all =run_clust_method(data;norm_op=norm_op, norm_scope=norm_scope, method=method, representation=representation, n_clust=n_clust, n_init=n_init, iterations=iterations, attribute_weights=attribute_weights, orig_k_ids=deepcopy(data.k_ids), kwargs...)
29-
29+
3030
# inter period segmentation (reduce the number of time steps per cluster - not fully implemented yet)
3131
if n_seg!=data.T && n_seg!=0
32-
clust_data_merged = ClustDataMerged(clust_data)
32+
clust_data_merged = ClustDataMerged(clust_data)
3333
segmented_merged=intraperiod_segmentation(clust_data_merged;n_seg=n_seg,norm_scope=norm_scope,iterations=iterations)
3434
clust_data = ClustData(segmented_merged)
3535
else # if interperiod segmentation is not used
@@ -38,7 +38,7 @@ function run_clust(data::ClustData;
3838

3939
# set configuration file
4040
clust_config = set_clust_config(;norm_op=norm_op, norm_scope=norm_scope, method=method, representation=representation, n_clust=n_clust, n_seg=n_seg, n_init=n_init, iterations=iterations, attribute_weights=attribute_weights)
41-
41+
4242
if get_all_clust_results
4343
# save all locally converged solutions and the best into a struct
4444
clust_result = ClustResultAll(clust_data,cost,clust_config,centers_all,weights_all,clustids_all,cost_all,iter_all)
@@ -85,7 +85,7 @@ function run_clust_method(data::ClustData;
8585
data_norm = attribute_weighting(data_norm,attribute_weights)
8686
end
8787
data_norm_merged = ClustDataMerged(data_norm)
88-
88+
8989
# initialize data arrays (all initial starting points)
9090
centers = Array{Array{Float64},1}(undef,n_init)
9191
clustids = Array{Array{Int,1},1}(undef,n_init)
@@ -112,10 +112,10 @@ function run_clust_method(data::ClustData;
112112
k_ids=orig_k_ids
113113
k_ids[findall(orig_k_ids.!=0)]=clustids[ind_mincost]
114114
# save in merged format as array
115-
115+
116116
# NOTE if you need clustered data more precise than 8 digits change the following line accordingly
117117
n_digits_data_round=8 # Gurobi throws warning when rounding errors on order~1e-13 are passed in. Rounding errors occur in clustering of many zeros (e.g. solar).
118-
clust_data_merged = ClustDataMerged(data.region,data.years,n_clust,data.T,round.(centers[ind_mincost]; digits=n_digits_data_round),data_type(data),weights[ind_mincost],k_ids)
118+
clust_data_merged = ClustDataMerged(data.region,data.years,n_clust,data.T,round.(centers[ind_mincost]; digits=n_digits_data_round),data_norm_merged.data_type,weights[ind_mincost],k_ids)
119119
clust_data = ClustData(clust_data_merged)
120120
return clust_data, cost_best, centers, weights, clustids, cost, iter
121121
end

src/utils/utils.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -340,21 +340,3 @@ function run_pure_clust(data::ClustData;
340340
end
341341
return ClustResult(ClustData(data.region, data.years, data.K, data.T, mod_data, data.weights, data.k_ids;delta_t=data.delta_t),clust_result.cost, clust_result.config)
342342
end
343-
344-
"""
345-
data_type(clust_data::ClustData)
346-
Get data_type from a struct ClustData
347-
"""
348-
function data_type(data::ClustData)
349-
n_datasets = length(keys(data.data))
350-
data_type=String[]
351-
for (k,v) in data.data
352-
push!(data_type,k)
353-
end
354-
return data_type
355-
end
356-
357-
function data_type(data::ClustDataMerged)
358-
return data.data_type
359-
end
360-

0 commit comments

Comments
 (0)