多目标遗传算法 ------ NSGA-II (部分源码解析) 目标函数值计算 eval.c
这部分比较简单,具体的函数数值计算是需要调用设定的目标函数的,此部分一个不能忽略的问题是 超出限制条件的处理 , 故对此加以解释。
首先是包装函数, 核心操作调用 evaluate_ind 实现。
/* Routine for evaluating population members */ # include <stdio.h>
# include <stdlib.h>
# include <math.h> # include "global.h"
# include "rand.h" /* Routine to evaluate objective function values and constraints for a population */
void evaluate_pop (population *pop)
{
int i;
for (i=; i<popsize; i++)
{
evaluate_ind (&(pop->ind[i]));
}
return;
}
/* Routine to evaluate objective function values and constraints for an individual */
void evaluate_ind (individual *ind)
{
int j;
test_problem (ind->xreal, ind->xbin, ind->gene, ind->obj, ind->constr);
if (ncon==)
{
ind->constr_violation = 0.0;
}
else
{
ind->constr_violation = 0.0;
for (j=; j<ncon; j++)
{
if (ind->constr[j]<0.0)
{
ind->constr_violation += ind->constr[j];
}
}
}
return;
}
6行 到 9行,根据标识位判断是否需要进行 超限 处理。
13行 到 19行, 对个体的所有限制条件遍历, 如果 某限制条件 constr[j]>=0 , 证明该个体在该条件上没有超限。
17行, 将 个体 所有超出限制条件的数值相加(所有小于0的 条件数值 constr[j]<0), 其和便是该个体的超限的非法数值 constr_violation ,
有此可知 constr_violation 小于0 说明该个体有超出限制条件的情况, 等于0 说明没有超出限制, 不存在大于0的情况。
多目标遗传算法 ------ NSGA-II (部分源码解析) 目标函数值计算 eval.c的更多相关文章
- 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍
NSGA(非支配排序遗传算法).NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化. 在官网: http://www.ii ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c
遗传算法中的交叉操作是 对NSGA-II 源码分析的 最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的 函数模块. 这里,首先提一下,遗传算法的 交叉操作.变异操作都 ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)目标函数 problemdef.c
/* Test problem definitions */ # include <stdio.h> # include <stdlib.h> # include <ma ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 拥挤距离计算 crowddist.c
/* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c
/* Routines for storing population data into files */ # include <stdio.h> # include <stdlib ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)README 算法的部分英文解释
This is the Readme file for NSGA-II code. About the Algorithm--------------------------------------- ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c
遗传算法的变异操作 /* Mutation routines */ # include <stdio.h> # include <stdlib.h> # include < ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c
/* Domination checking routines */ # include <stdio.h> # include <stdlib.h> # include &l ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c
tourselect.c 文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 临时种群生成新父代种群 fillnds.c
/* Nond-domination based selection routines */ # include <stdio.h> # include <stdlib.h> ...
随机推荐
- hdu 4608 I-number 大整数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4608 #include <cstdio> #include <cmath> # ...
- es6小技巧
let myKey = 'variableKey'; let obj = { key1: 'One', key2: 'Two', [myKey]: 'Three' /* 棒呆! */ }; 给变量键加 ...
- Python算法之---冒泡,选择,插入排序算法
''' Created on 2013-8-23 @author: codegeek ''' def bubble_sort(seq): for i in range(len(se ...
- setTimeout的作用以及setTimeout延时0毫秒的作用
以下代码输出的顺序是? console.log(1); setTimeout(function(){ console.log(2); }, 0); setTimeout(function(){ con ...
- SQL Server不区分大小写的问题
SQL Server不区分大小写的问题 默认情况下,SQL Server不区分大小写,如果数据表TEST的TNAME列中有数据“abcd”和“Abcd”, 如果使用查询语句:select * fr ...
- POJ - 1170 Shopping Offers (五维DP)
题目大意:有一个人要买b件商品,给出每件商品的编号,价格和数量,恰逢商店打折.有s种打折方式.问怎么才干使买的价格达到最低 解题思路:最多仅仅有五种商品.且每件商品最多仅仅有5个,所以能够用5维dp来 ...
- 谈谈iOS中粘性动画以及果冻效果的实现
在最近做个一个自定义PageControl——KYAnimatedPageControl中,我实现了CALayer的形变动画以及CALayer的弹性动画,效果先过目: https://github.c ...
- 安卓扫码:简单的ZXing使用记录
ZXing是Google提供的条形码.二维码等的生成.解析的库.最近工作需求去研究了一下,主要是研究怎么扫描二维码(QRCode).网上教程也不少,但大多看了不明所以,甚至看了半天都不知道解码到底从哪 ...
- Linux read/write fread/fwrite两者区别
Linux read/write fread/fwrite两者区别 1,fread是带缓冲的,read不带缓冲. 2,fopen是标准c里定义的,open是POSIX中定义的. 3,fread可以读一 ...
- Linux下解决高并发socket最大连接数所受的各种限制(解除IO限制)
linux作为服务器系统,当运行高并发TCP程序时,通常会出现连接建立到一定个数后不能再建立连接的情况 本人在工作时,测试高并发tcp程序(GPS服务器端程序),多次测试,发现每次连接建立到3800左 ...