function [groups, centr, prob, exitflag] = misodata(p)
% MISODATA is an unsupervised clustering algorithm to capture scenarios
% from historical series.
%
% [ ... ] = MISODATA(p) partitions the points in the N-by-D data matrix
% in the selected .csv file into clusters. Where N is the number of data
% points and D the dimension of the historical series. MISODATA captures
% the scenarios from historical series according to p. p is a structure
% whose fields are:
% 'FileSerie' - Name of .csv file containing the historical series.
% 'dMin' - the minimum allowed distance between the centroids.
% Default value: 0.04
% 'max_std' - the maximum allowed standard deviation of scenarios.
% Default value: 0.55*p.dMin
% 'pMin' - scenario's minimum allowed probability of occurence.
% Default value: 1e-10
% 'SimName' - Name of the simulation.
% Default value: 'none'
% 'Niter' - Maximum number of iterations.
% Default value: 100
% 'ResultsPath' - Path for saving results.
% Default value: []
% 'PlotFlag' - Flag to plot two-dimensional graphs.
% Default value: false
% 'SaveFlag' - Flag to save results.
% Default value: false
% 'nCluMax' - maximum number of clusters.
% Default value: internally computed.
% 'nClu0' - initial number of clusters
% Default value: 1.
% 'UseDCF' - Use of the dimensional correction factor
% Default value: true
% 'Display' - off, final or iter
% Default value: iter.
%
% [GROUPS, CENTR, PROB] = MISODATA(p) GROUPS returns the historical
% series data points location in the CENTR K-by-N centroids matrix. Where
% K is the number of clusters obtained. PROB returns the probability of
% occurrence of the scenario associated with each centroid.
%
% [GROUPS, CENTR, PROB, EXITFLAG] = MISODATA(p) returns an EXITFLAG
% that describes the exit condition. Possible values of EXITFLAG and the
% corresponding exit conditions are:
%
% 1 Iterative proccess converged.
% 0 Number of iterations reached.
%
% See also KMEANS, CLUSTER.
tic % Measuring elapsed time
%% Reading the data
if ~any(strcmp(fieldnames(p), 'FileSerie'))
% error
error('ERROR: field p.FileSerie is mandatory in p structure!!!')
end
%
load(p.FileSerie, 'data')
[Nobs, nser] = size(data); % Number of data points and number of series
%
% Normalizing data
base_data_1 = min(data, [], 1);
base_data_2 = max(data, [], 1);
for iser = 1:nser
data(:, iser) = (data(:, iser)-base_data_1(iser))/(base_data_2(iser)-base_data_1(iser));
end
%
% Calculating unique observations in the series
data_unique = unique(data,'rows');
[Nobs_unique, ~] = size(data_unique); % Number of unique observations
%
%% Parameters treatment
% Use of dimensional correction factor
if ~any(strcmp(fieldnames(p), 'UseDCF'))
% default value
p.UseDCF = true;
end
%
% Mminimum allowed distance between the centroids
if ~any(strcmp(fieldnames(p), 'dMin'))
% default value
p.dMin = 0.04;
end
%
% Applying the Dimensional correction factor
if p.UseDCF
p.dMin = p.dMin*sqrt(nser);
end
%
% Maximum allowed standard deviation of scenarios
if ~any(strcmp(fieldnames(p), 'max_std'))
% default value
p.max_std = p.dMin*0.55;
elseif p.UseDCF
% Applying the Dimensional correction factor
p.max_std = p.max_std*sqrt(nser); % Dimensional correction factor
end
%
% Scenario's minimum allowed probability of occurence
if ~any(strcmp(fieldnames(p), 'pMin'))
% default value
p.pMin = 1e-10;
end
%
% Simulation name
if ~any(strcmp(fieldnames(p), 'SimName'))
% default value
p.SimName = 'none';
end
%
% Number of iterations
if ~any(strcmp(fieldnames(p), 'Niter'))
% default value
p.Niter = 100;
end
%
% Path for results
if ~any(strcmp(fieldnames(p), 'ResultsPath'))
% default value
p.ResultsPath = []; % Current folder
end
%
% Flag to plot two-dimensional graphs
if ~any(strcmp(fieldnames(p), 'PlotFlag'))
% default value
p.PlotFlag = false;
end
%
% Flag to save scenarios data as a .csv file
if ~any(strcmp(fieldnames(p), 'SaveFlag'))
% default value
p.SaveFlag = false;
end
%
% Flag to display results
if ~any(strcmp(fieldnames(p), 'Display'))
% default value
p.Display = 'iter';
end
%
% Maximum number of clusters.
if ~any(strcmp(fieldnames(p), 'nCluMax'))
% default value
p.nCluMax = round(1/p.pMin);
if p.nCluMax > Nobs_unique
p.nCluMax = Nobs_unique;
end
else
if p.nCluMax > Nobs_unique
p.nCluMax = Nobs_unique;
disp(['nCluMax greater than number of unique observations and was seted to ' num2str(Nobs_uniqe) '!!!'])
end
end
%
% Initial number of clusters.
if ~any(strcmp(fieldnames(p), 'nClu0'))
% default value
p.nClu0 = 1;
else
if p.nClu0 > p.nCluMax
p.nClu0 = p.nCluMax;
disp(['nClu0 greater than maximum number of clusters and was seted to ' num2str(p.nCluMax) '!!!'])
elseif p.nClu0 < 1
p.nClu0 = 1;
disp('nClu0 smaller than 1 and was seted to 1!!!')
end
end
%
%% m-ISODATA main program
%
% Minimum number of data per cluster
nmin = round(p.pMin*Nobs);
if nmin == 0
nmin = 1;
end
%
% Extracting initial clusters (as forecasted)
nClu = p.nClu0;
centrF = data_unique(randperm(Nobs_unique,nClu)', :);
%
% Historic of number of clusters
nClu_hist = zeros(p.Niter, 1);
%
% Stop criteria flags and counters
countSTOP = 0;
flagOSCI = 0;
nClu_old_s = nClu; % For stop criteria purposes
nClu_old_m = nClu; % For stop criteria purposes
iter = 0;
hist_desv = 1;
%
% main loop
if strcmp(p.Display, 'iter')
disp(' ')
end
while true
%
nClu_old = nClu; % For stop criteria purposes
%
if countSTOP == 0
%
% Grouping data into clusters
[groups, clucount] = GroupData(data, centrF);
%
% Erasing empty clusters
if any(clucount==0)
empty_idx = find(clucount==0)';
c = 0;
for idx = empty_idx
groups(groups>idx-c) = groups(groups>idx-c)-1;
c = c+1;
end
nClu = nClu-length(empty_idx);
clucount(empty_idx) = [];
end
%
% Updating stop criterion
if nClu == nClu_old
countSTOP = 1;
else
nClu_old = nClu;
countSTOP = 0;
end
end
if strcmp(p.Display, 'iter')
disp(['iter: ' num2str(iter) ' | nClu: ' num2str(nClu)]);
end
% Verifying stop criteria
if iter == p.Niter || countSTOP == 3 || (flagOSCI >= 4 && ~iter_odd) || (hist_desv < 0.05 && ~iter_odd)
%
%
% Calculating centroids
centr = CalcCentr(groups, data, clucount);
if p.PlotFlag
if nser == 2
plot_groups(nClu, nser, data, groups, p)
else
disp('Warning: "plot_flag = true" only available for two-dimensional series')
end
end
%
% Defining exitflag
if iter == p.Niter
exitflag = 0; % N�mero de itera僖es atingido
else
exitflag = 1; % Parada por estabiliza頒o
end
%
% Exit m-ISODATA program
break
end
%
% Updating iteration
iter = iter+1;
iter_odd = rem(iter, 2) ~= 0;
nClu_hist(iter) = nClu;
if iter>=10
hist_desv = std(nClu_hist(iter-9:iter))/mean(nClu_hist(iter-9:iter));
end
%
% Calculating centroids
centr = CalcCentr(groups, data, clucount);
%
% Calculating distances between centroids and data and obtaining medoids
[clu_desv, clu_bevec] = CalcDesv(data, groups,
没有合适的资源?快使用搜索试试~ 我知道了~
用于捕获电力系统中代表性场景的无监督聚类算法
共65个文件
m:20个
jpg:14个
fig:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 48 浏览量
2022-07-01
16:37:12
上传
评论 1
收藏 6.01MB RAR 举报
温馨提示
本文提出了一种新的无监督聚类算法用于提取风电、光伏代表性场景。可直接运行出结果
资源推荐
资源详情
资源评论
收起资源包目录
unsupervised clustering algorithm to capture representative scenarios in power systems.rar (65个子文件)
unsupervised clustering algorithm to capture representative scenarios in power systems
data
Series_3WF_5years_load.mat 604KB
LICENSE 6KB
IEEE_RTS_SYSTEM_DATA.mat 1KB
Series_2WindFarms_mod.mat 116KB
Series_Merrick.mat 313KB
result
fig_HAC_101wind.jpg 211KB
fig_kmeans_39wind.jpg 201KB
fig_kmeans_101wind.jpg 209KB
fig_DIC_AUS.fig 24KB
centr_HAC_39wind.mat 817B
fig_HAC_101wind.fig 320KB
centr_kmeans_101wind.mat 2KB
fig_hist_2WF.jpg 251KB
fig_POPF_result.fig 433KB
mISODATA_39wind.csv 2KB
centr_HAC_101wind.mat 2KB
fig_mISODATA_101wind.fig 318KB
fig_INST_COST.fig 18KB
fig_kmeans_39wind.fig 268KB
fig_DIC_AUS.jpg 106KB
fig_mISODATA_39wind.jpg 202KB
output 10KB
fig_DataDensity.jpg 395KB
fig_Clusters.fig 547KB
centr_mISODATA_39wind.mat 825B
fig_POPF_results.jpg 154KB
fig_hist_2WF.fig 28KB
output_GEP_noD.mat 2KB
fig_CQE_withnoD.fig 27KB
fig_Clusters.jpg 348KB
fig_CQE_withnoD.jpg 119KB
mISODATA_101wind.csv 5KB
fig_NSCE_withnoD.jpg 102KB
fig_HAC_39wind.fig 267KB
fig_NSCE_withnoD.fig 25KB
fig_HAC_39wind.jpg 203KB
fig_mISODATA_39wind.fig 264KB
fig_kmeans_101wind.fig 323KB
fig_INST_COST.jpg 99KB
centr_kmeans_39wind.mat 819B
centr_mISODATA_101wind.mat 2KB
fig_mISODATA_101wind.jpg 213KB
fig_DataDensity.fig 301KB
output_GEP.mat 2KB
code
load_GEP_model.m 2KB
main.m 987B
plot_groups.m 2KB
analysis_GEP.m 4KB
analysis_kmeans_101wind.m 794B
misodata.m 13KB
load_GEP_data.m 1KB
run_POPF.m 7KB
analysis_HAC_101wind.m 814B
analysis_GEP_noD.m 4KB
analysis_kmeans_39wind.m 792B
analysis_mISODATA_39wind.m 744B
analysis_WindFarmsDataGraphs.m 3KB
analysis_POPF.m 6KB
analysis_GEP_graphs.m 3KB
analysis_ClustersPlot_MKH.m 3KB
run 198B
analysis_GEP_bar.m 5KB
analysis_mISODATA_101wind.m 802B
analysis_HAC_39wind.m 814B
my_run.m 226B
共 65 条
- 1
资源评论
科研菜鸟的求学之路
- 粉丝: 135
- 资源: 52
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功