clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
pop=100; % population
m_rate = .1; % mutation rate
c_pt = 2; % crossover point
good_enough = .08; % when to stop
weights = [1, .6, .4];
% chromosome format -------------------------------------------------------
power = 1;
cost = 2;
emission = 3;
source_1 = [20, .02, .01];
source_2 = [120, .20, .05];
source_3 = [15, .01, .02];
source_4 = [50, .02, .04];
sources = [source_1; source_2; source_3; source_4];
% define ranges
[num_sources, num_genes] = size(sources);
boundaries = zeros(num_genes, 2);
boundaries(1,:) = [15, 100]; % requested power range
boundaries(2,:) = [.15, 6.55]; % minimum cost to get max power
boundaries(3,:) = [.15, 3.75]; % minimum emissions to get max power
r = 2;
s = 2;
reproduction = @crossover;
survival = @elitism;
load = TimeSeries();
chromosomes = chromosome_gen(pop, sources);
vector = zeros(24, num_sources); % initialze vector for best chromosomes
econ = zeros(24, 1); % initialize vector for econonmic factor
enviro = zeros(24, 1); % intialize vector for environmental factor
time = zeros(24, 1); % vector to store time
for i = 1:length(load)
tic;
% get fitness vector
fit = fitness(chromosomes, sources, boundaries, weights, load(i));
[best, best_i] = min(fit);
% loop until a suitable chromosome is found
while(~stop_condition(fit, good_enough))
% reproduce with selected method
chromosomes = reproduction(chromosomes, pop, sources, boundaries, m_rate, c_pt);
fit = fitness(chromosomes, sources, boundaries, weights, load(i));
% kill with selected method
chromosomes = survival(pop, chromosomes, fit);
% check fitness of modified set
fit = fitness(chromosomes, sources, boundaries, weights, load(i));
[best,best_i]=min(fit);
% get rid of NaN
if(isnan(best))
best = 1;
end
end
% store elapsed time
elapsed = toc;
time(i) = elapsed;
% store chromosome in vector
vector = store_best(vector, fit, chromosomes, i);
% store economic factor
econ(i) = econ_fitness(chromosomes(best_i, :), sources, boundaries, weights);
% store environmental factor
enviro(i) = enviro_fitness(chromosomes(best_i, :), sources, boundaries, weights);
end
% plot information
enviro_plot(enviro);
econ_plot(econ);
power_plot(vector,load);
calculation_plot(time);
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![slx](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/MP4.png)
共 25 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- chunhan012023-05-06感谢大佬分享的资源,对我启发很大,给了我新的灵感。
![avatar](https://profile-avatar.csdnimg.cn/d5fa1452106248a4a63014172db25c5d_leavemyleave.jpg!1)
mYlEaVeiSmVp
- 粉丝: 1969
- 资源: 19万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)