/* 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. [Javascript] Immute Object

    Three ways to make object immutable: 1. Use JSON.parse(JSON.stringify(obj)): this approach is little ...

  2. ltrace killed by SIGTRAP

    [Ltrace-devel] ltrace stucks with pthreads Heiko Carstens heiko.carstens at de.ibm.comFri Apr 14 11: ...

  3. 从源码角度深入理解LayoutInflater

    关于LayoutInflater,在开发中经常会遇到,特别是在使用ListView的时候,这个几乎是必不可少.今天我们就一起来探讨LayoutInflater的工作原理. 一般情况下,有两种方式获得一 ...

  4. pthread

    pthread是UNIX操作系统中创建和控制线程的一系列API,通过了解这些API,可以更加清晰的理解线程究竟是什么. 调用pthread的API首先要包含<pthread.h>这一头文件 ...

  5. css定义多重背景动画

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style typ ...

  6. 移动端rem布局的适配mixin【转藏】

    /*================================================================ 以下为基于ip5 宽度320做的适配,标准html{font-si ...

  7. String sql = "update web_admin set adminname=? ,password=? where id=?;怎么给“?” 传值?

    PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES                                ...

  8. Nginx+Tomcat+memcached负载均衡实现session共享

    http://blog.csdn.net/love_ubuntu/article/details/8464983 1.  安装各个软件不用说了. 2.  到tomcat的安装目录lib中,加入: me ...

  9. 将文件的编码格式转换为utf-8

    背景:项目中有一些其他部门发过来的代码,编码格式有utf-8,也有GBK,而且是散乱在各个文件夹中的,处理起来十分的麻烦.我想把他们都转成统一的utf-8的格式.代码很简单,直接上代码好了. impo ...

  10. MVC小系列(十六)【在控制器级别或具体Action级别上动态设定模板页(Layout)】

    方法就是使用:ActionFilterAttribute它的几个方法:OnActionExecuted,OnActionExecuting,OnResultExecuted和OnResultExecu ...