这部分比较简单,具体的函数数值计算是需要调用设定的目标函数的,此部分一个不能忽略的问题是  超出限制条件的处理 , 故对此加以解释。

首先是包装函数, 核心操作调用  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的更多相关文章

  1. 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍

    NSGA(非支配排序遗传算法).NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化. 在官网: http://www.ii ...

  2. 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c

    遗传算法中的交叉操作是 对NSGA-II  源码分析的  最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的  函数模块. 这里,首先提一下,遗传算法的  交叉操作.变异操作都 ...

  3. 多目标遗传算法 ------ NSGA-II (部分源码解析)目标函数 problemdef.c

    /* Test problem definitions */ # include <stdio.h> # include <stdlib.h> # include <ma ...

  4. 多目标遗传算法 ------ NSGA-II (部分源码解析) 拥挤距离计算 crowddist.c

    /* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...

  5. 多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c

    /* Routines for storing population data into files */ # include <stdio.h> # include <stdlib ...

  6. 多目标遗传算法 ------ NSGA-II (部分源码解析)README 算法的部分英文解释

    This is the Readme file for NSGA-II code. About the Algorithm--------------------------------------- ...

  7. 多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c

    遗传算法的变异操作 /* Mutation routines */ # include <stdio.h> # include <stdlib.h> # include < ...

  8. 多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c

    /* Domination checking routines */ # include <stdio.h> # include <stdlib.h> # include &l ...

  9. 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c

    tourselect.c  文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...

  10. 多目标遗传算法 ------ NSGA-II (部分源码解析) 临时种群生成新父代种群 fillnds.c

    /* Nond-domination based selection routines */ # include <stdio.h> # include <stdlib.h> ...

随机推荐

  1. 《A First Course in Probability》-chaper4-离散型随机变量-负二项分布

    基于我们最为熟悉的离散型分布——二项分布,我们能够衍生出很多别的分布列,对于之前介绍过的几何分布,我们赋予其的含义是:某个事件成功的概率是p,在n次独立重复实验中恰好成功一次的概率是多少.顺着这层含义 ...

  2. 意大利进口的衬衫面料pH值严重超标·都市快报

    意大利进口的衬衫面料pH值严重超标·都市快报     意大利进口的衬衫面料pH值严重超标         董捷    2007-03-24           通讯员 浙 检 记 者 董 捷      ...

  3. Maven deploy

      1.在maven/conf/setting.xml中: 在<servers>中加入 <server> <id>internal</id> <u ...

  4. PL/SQL 9.0工具技巧

    1. 设置自动替换 tools--preferences--User interface--Editor--Autoreplace 2.

  5. redmine安装插件流程

    1.redmine用一键安装即可2.进入C:\Bitnami\redmine-3.1.1-1\,执行use_redmine.exe,进入dos系统 不能用cmd进入.3.把文件拷贝到C:\Bitnam ...

  6. tomcat环境搭建

    前言 学习任何一门技术的都需要环境的搭建,Hello world成为学习的开端.今天我就为大家带来tomcat的环境搭建过程. 配置环境变量 右击我的电脑->属性->高级系统设置-> ...

  7. java中的String.format使用

         format(String  format, Objece...  argues)函数相当于C语言中的printf函数,但是相对来说更灵活.      和C中的printf函数差不多,在fo ...

  8. php做站点购物车 你搞懂了吗?

    网上购物现已成为时尚,客户选择一个商品将其放入到购物车,然后返回继续购物或者去收银台,这个功能怎样实现呢?今天capucivar就将使用PHP来实现这个购物车的功能. 首先,做一个简单的首页,从数据库 ...

  9. nodejs这个过程POST求

    下面是一个web登陆模拟过程.当我们问一个链接,你得到一个表格,然后填写相应的表格值,然后提交登陆. var http = require('http'); var querystring = req ...

  10. 使用EF 的简单的增删改查

    using DAL; using Model; using System; using System.Collections.Generic; using System.Linq; using Sys ...