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

首先是包装函数, 核心操作调用  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. Codeforces Round #216 (Div. 2) E. Valera and Queries 树状数组 离线处理

    题意:n个线段[Li, Ri], m次询问, 每次询问由cnt个点组成,输出包含cnt个点中任意一个点的线段的总数. 由于是无修改的,所以我们首先应该往离线上想, 不过我是没想出来. 首先反着做,先求 ...

  2. maven src/test/resources 下的logback-test.xml 读取 properties文件中的key-value值

    <profiles>        <profile>            <id>test-cd</id>            <prope ...

  3. Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式)介绍

    jedis是一个著名的key-value存储系统,而作为其官方推荐的java版客户端jedis也非常强大和稳定,支持事务.管道及有jedis自身实现的分布式. 在这里对jedis关于事务.管道和分布式 ...

  4. PL/SQL 9.0工具技巧

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

  5. DateTimePicker控件为空 分类: WinForm 2014-04-15 09:46 239人阅读 评论(0) 收藏

    设置属性:                 Format=Custom 加载事件:ValueChanged    private void dtpStart_ValueChanged(object s ...

  6. 10款AJAX/CSS/HTML的在线表单生成器

    本文转载:http://www.oschina.net/news/24327/10-ajax-css-html-online-form-builder 在这篇文章中,我们将介绍10个超棒的在线表单生成 ...

  7. [Javascript] Advanced Console Log Arguments

    Get more mileage from your console output by going beyond mere string logging - log entire introspec ...

  8. [AngularJS] Use ng-model-options to limit $digest

    Refer: http://toddmotto.com/super-fast-angular-ng-model-options-limit-digest-cycles/ Use: <input ...

  9. HDU 5040 Instrusive(BFS+优先队列)

    题意比较啰嗦. 就是搜索加上一些特殊的条件,比如可以在原地不动,也就是在原地呆一秒,如果有监控也可以花3秒的时间走过去. 这种类型的题目还是比较常见的.以下代码b[i][j][x]表示格子i行j列在x ...

  10. POJ 2891 扩展欧几里德

    这个题乍一看跟剩余定理似的,但是它不满足两两互素的条件,所以不能用剩余定理,也是给了一组同余方程,找出一个X满足这些方程,如果找不到的话就输出-1 因为它不满足互素的条件,所以两个两个的合并,最后合成 ...