一些其他函数
重量计算函数:
function wgtsum = weightsum(pop, weights)% 计算种群的重量% pop input 种群% weights input 重量向量% wgtsum output 种群重量popsize = size(pop, 1); wgtsum = zeros(popsize, 1);for i = 1:popsize wgtsum(i, 1) = weightsumv(pop(i, :), weights);endend
function wgtsum = weightsumv(stuffs, weights)% 计算一个个体的重量% stuffs input 物品序列% weights input 重量向量% wgtsum output 个体重量wgtsum = sum(weights(stuffs ~= 0));end
收益计算函数:
function pftsum = profitssum(pop, profits)% 计算种群收益% pop input 种群% profits input 收益向量% pftsum output 种群收益popsize = size(pop, 1); pftsum = zeros(popsize, 1);for i = 1:popsize pftsum(i, 1) = sum(profits(pop(i, :) ~= 0));endend
作者:mwangjs
链接:https://www.jianshu.com/p/69f1ab2a96d8
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦