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

首先是包装函数, 核心操作调用  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. Clouds

    1.Eucalyptus: Eucalyptus is a Linux-based software architecture that implements scalable private and ...

  2. Spring与SpringMVC的容器关系分析

    Spring和SpringMVC作为Bean管理容器和MVC层的默认框架,已被众多WEB应用采用,而实际使用时,由于有了强大的注解功能,很多基于XML的配置方式已经被替代,但是在实际项目中,同时配置S ...

  3. Git 中README.md中MarkDown语法示例

    转 http://blog.csdn.net/brokge/article/details/38388757 简介 Markdown的语法简洁明了.学习容易,而且功能比纯文本更强,因此有很多人用它写博 ...

  4. SpringBoot 配置文件 application.properties

    转:http://www.qiyadeng.com/post/spring-boot-application-properties #########COMMON SPRING BOOT PROPER ...

  5. linux —— 学习笔记(汇总)

    笔记目录:一.系统知识 和 基本概念                    二.常用操作                   三.系统管理(内存.设备.服务等管理)                   ...

  6. php数组和字符串转换

    PHP 中由于数组和字符串这两种变量类型是如此常用,以至于 PHP 具有两个函数,可以在字符串和数组之间互相进行转换. $array=explode(separator,$string); $stri ...

  7. 【LeetCode】Swap Nodes in Pairs

    Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2-& ...

  8. linux下ssh免密登陆

    如果 有A.B两台主机: 要实现的效果: A主机ssh登录B主机无需输入password: 加密方式选 rsa|dsa均能够.默认rsa 做法: 1.登录A主机 2.ssh-keygen -t [rs ...

  9. HTML5新特性之Canvas+drag(拖拽图像实现图像反转)

    1.什么是canvas 在网页上使用canvas元素时,会创建一块矩形区域,默认矩形区域宽度300px,高度150px.. 页面中加入canvas元素后,可以通过javascript自由控制.可以在其 ...

  10. [PWA] 4. Hijacking Request

    We want to do offline first, the first thing we need to do is we should able to catch the browser re ...