/* 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. jsp----在jsp中写java代码(变量和函数方法)

    <%@page import="java.text.SimpleDateFormat"%><%@page language="java" im ...

  2. vi快捷键必知必会

    文本编辑器是所有计算机系统中最常用的一种工具.UNIX下的编辑器有ex,sed和vi等,其中,使用最为广泛的是vi,而vi命令繁多,论坛里好像这方面的总结不多,以下稍做总结,以资共享!渴望更正和补充! ...

  3. java strtus2 注解配置入门(一)

    因为工作的原因,所以接触到一些项目,有的项目虽然看着能有跟着做,可是具体里面的框架是别人配置的,具体框架还是不是非常的了解,所以这里在看一下我学到的 一点关于struts2中注解开发的一点点. 直接代 ...

  4. MVC小系列(九)【引入namespace】

    以前在页面引入一个namespace,可以这样: <%@ Import Namespace="Web.Helpers" %> 如果空间是所有页面都需要的,可以写进配置文 ...

  5. meteor中分页库alethes:pages用法汇总

    1.添加分页库: meteor add alethes:pages 2.新建分页: Pages = new Meteor.Pagination("collection-name") ...

  6. ASP.NET页面生命周期总结(1)

    图解:1) 浏览器   :把用户的操作封装成一个请求通过socket发送到后台服务器. 后台服务器:首先有个内核模块Http.sys 和针对每个应用程序池都有一个请求队列.然后请求到达http.sys ...

  7. iOS 计算两个日期之间的天数问题

    //获取当前时间若干年.月.日之后的时间 + (NSDate *)dateWithFromDate:(NSDate *)date years:(NSInteger)years months:(NSIn ...

  8. 利用switch语句计算特定的年份的月份共有几天。

    //利用switch语句计算特定的年份的月份共有几天. let year =2015 let month =2 //先判断闰年中二月份的情况 ifmonth ==2 { if (year %400 = ...

  9. iOS控件——UIView的viewWithTag:(int)findTag方法描述

    UIView拥有一个viewWithTag:(int)findTag方法,调用方式为[MyView viewWithTag:整形数字]该方法返回tag == findTag的控件.ios控件中允许多个 ...

  10. JS实现回到页面顶部动画效果 2016.03.23

    最近在模仿各大网站写页面样式和交互,发现好多都有回到顶部的需要,所以写了一下js,记录下来. 发现还可以添加从快到慢的动画效果和随时下拉滚动条停止滚动的功能, 参考了imooc上相关课程,最终实现JS ...