/* Routines for storing population data into files */

 # include <stdio.h>
# include <stdlib.h>
# include <math.h> # include "global.h"
# include "rand.h" /* Function to print the information of a population in a file */
void report_pop (population *pop, FILE *fpt)
{
int i, j, k;
for (i=; i<popsize; i++)
{
for (j=; j<nobj; j++)
{
fprintf(fpt,"%e\t",pop->ind[i].obj[j]);
}
if (ncon!=)
{
for (j=; j<ncon; j++)
{
fprintf(fpt,"%e\t",pop->ind[i].constr[j]);
}
}
if (nreal!=)
{
for (j=; j<nreal; j++)
{
fprintf(fpt,"%e\t",pop->ind[i].xreal[j]);
}
}
if (nbin!=)
{
for (j=; j<nbin; j++)
{
for (k=; k<nbits[j]; k++)
{
fprintf(fpt,"%d\t",pop->ind[i].gene[j][k]);
}
}
}
fprintf(fpt,"%e\t",pop->ind[i].constr_violation);
fprintf(fpt,"%d\t",pop->ind[i].rank);
fprintf(fpt,"%e\n",pop->ind[i].crowd_dist);
}
return;
} /* Function to print the information of feasible and non-dominated population in a file */
void report_feasible (population *pop, FILE *fpt)
{
int i, j, k;
for (i=; i<popsize; i++)
{
if (pop->ind[i].constr_violation == 0.0 && pop->ind[i].rank==)
{
for (j=; j<nobj; j++)
{
fprintf(fpt,"%e\t",pop->ind[i].obj[j]);
}
if (ncon!=)
{
for (j=; j<ncon; j++)
{
fprintf(fpt,"%e\t",pop->ind[i].constr[j]);
}
}
if (nreal!=)
{
for (j=; j<nreal; j++)
{
fprintf(fpt,"%e\t",pop->ind[i].xreal[j]);
}
}
if (nbin!=)
{
for (j=; j<nbin; j++)
{
for (k=; k<nbits[j]; k++)
{
fprintf(fpt,"%d\t",pop->ind[i].gene[j][k]);
}
}
}
fprintf(fpt,"%e\t",pop->ind[i].constr_violation);
fprintf(fpt,"%d\t",pop->ind[i].rank);
fprintf(fpt,"%e\n",pop->ind[i].crowd_dist);
}
}
return;
}

report_pop   将种群中所有个体的   目标函数值, 限制条件值, 编码值  打印出来。

report_pop   种群中的非支配个体并且限制条件总和为0   (constr_violation == 0.0的个体的   目标函数值, 限制条件值, 编码值  打印出来。

多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.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 (部分源码解析)README 算法的部分英文解释

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

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

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

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

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

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

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

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

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

随机推荐

  1. [AngularJS + Webpack] require directives

    direictives/index.js: module.exports = function(ngModule) { //register all the directives here requi ...

  2. mydumper工作原理 :myownstars专家

    http://blog.itpub.net/15480802/viewspace-1465080/

  3. careercup-递归和动态规划 9.2

    9.2 设想有个机器人坐在X*Y网格的左上角,只能向右.向下移动.机器人从(0,0)到(X,Y)有多少种走法? 进阶: 假设有些点为“禁区”,机器人不能踏足.设计一种算法,找到一条路径,让机器人从左上 ...

  4. keepalived + haproxy 实现web 双主模型的高可用负载均衡--转

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://xz159065974.blog.51cto.com/8618592/140581 ...

  5. struts2+ajax

    web网页开发中需要用到struts2来处理action,通过struts2定义后端java类. <action name="loginAction" class=" ...

  6. javascript笔记09:javascript的下拉式导航菜单

    <!DOCTYPE html> <html> <body> <script> function hideAll() { for(i=0;i<odi ...

  7. maven项目在tomcat中运行遇到的问题

    在使用maven构建项目,并在tomcat容器中运行的时候遇到了一些问题,现做一下记录 maven项目中jdk版本会自动恢复 maven项目的编译jdk即使在window -> java -&g ...

  8. Maven笔记(一)

    1. 坐标 Maven坐标为各种构件引入了秩序,任何一个构件都有必须明确定义自己的坐标,而一组Maven坐标是通过一些元素定义的,它们是groupId, artifactId, version, pa ...

  9. ThinkPHP函数详解:cookie方法

    cookie函数也是一个多元化操作函数,完成cookie的设置.获取和删除操作. Cookie 用于Cookie 设置.获取.删除操作 用法cookie($name, $value='', $opti ...

  10. 20160410javaweb之JDBC---DBUtils框架

    DBUtils 1.DbUtils 工具类 2.QueryRunner -- 两行代码搞定增删改查 (1)QueryRunner() --需要控制事务时,使用这组方法 int update(Conne ...