多目标遗传算法 ------ NSGA-II (部分源码解析)状态报告 打印 report.c
/* 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的更多相关文章
- 多目标遗传算法 ------ NSGA-II (部分源码解析)介绍
NSGA(非支配排序遗传算法).NSGA-II(带精英策略的快速非支配排序遗传算法),都是基于遗传算法的多目标优化算法,是基于pareto最优解讨论的多目标优化. 在官网: http://www.ii ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 交叉操作 crossover.c
遗传算法中的交叉操作是 对NSGA-II 源码分析的 最后一部分, 这一部分也是我 从读该算法源代码和看该算法论文理解偏差最大的 函数模块. 这里,首先提一下,遗传算法的 交叉操作.变异操作都 ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)目标函数 problemdef.c
/* Test problem definitions */ # include <stdio.h> # include <stdlib.h> # include <ma ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 拥挤距离计算 crowddist.c
/* Crowding distance computation routines */ # include <stdio.h> # include <stdlib.h> # ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)README 算法的部分英文解释
This is the Readme file for NSGA-II code. About the Algorithm--------------------------------------- ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 实数、二进制编码的变异操作 mutation.c
遗传算法的变异操作 /* Mutation routines */ # include <stdio.h> # include <stdlib.h> # include < ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)两个个体支配判断 dominance.c
/* Domination checking routines */ # include <stdio.h> # include <stdlib.h> # include &l ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析)二元锦标赛选择 tourselect.c
tourselect.c 文件中共有两个函数: selection (population *old_pop, population *new_pop) individual* tournament ...
- 多目标遗传算法 ------ NSGA-II (部分源码解析) 临时种群生成新父代种群 fillnds.c
/* Nond-domination based selection routines */ # include <stdio.h> # include <stdlib.h> ...
随机推荐
- [Javascript] Chaining the Array map and filter methods
Both map and filter do not modify the array. Instead they return a new array of the results. Because ...
- C#数据库读取数据后转换为INT32后计算的小技巧
这有什么难的,不管是什么数据库, 首先分别读出userinfo中usermoney的值 存入s1,card中extramoney的值s2 读出字段数据你应该会吧! 再用userinfo中字段userm ...
- java_一对一自由聊天
客户端 package cn.qianfeng.kaoti03; import java.io.BufferedReader; import java.io.IOException; import j ...
- 【转】【2015MIIC】迅雷CTO陈磊:互联网思维会害死很多传统企业
MIIC2015大会的“跨界与重构”论坛上,迅雷CTO.网心科技CEO陈磊的演讲引起众多共鸣——独家揭秘“互联网大忽悠”,给这群人画了像,互联网大忽悠通常有五招: 第1招,画大饼,给你一个宏伟的目标: ...
- .net中下载文件的方法(转)
.net中下载文件的方法 一.//TransmitFile实现下载 protected void Button1_Click(object sender, EventArgs e) ...
- ThinkPHP函数详解:L方法
L方法用于启用多语言的情况下,设置和获取当前的语言定义.调用格式:L('语言变量'[,'语言值'])设置语言变量除了使用语言包定义语言变量之外,我们可以用L方法动态设置语言变量,例如: L('LANG ...
- gulp自动化框架的搭建
自动化框架的搭建:https://github.com/zjhsd2007/www 屏蔽掉的部分是Test(文件夹的目录 也是你的项目名称);本地项目启动后 配合sass,会自动启动浏览器,然后好处多 ...
- 20160322 javaweb 学习笔记--response 重定向
//一般方法 response.setStatus(302); response.setHeader("Location", "/20160314/index.jsp&q ...
- 【转】【JavaScript】禁用backspace键的后退功能,但是可以删除文本内容
在JavaScript中添加以下代码,就可实现 禁用backspace键的后退功能,但是可以删除文本内容 // 禁用backspace键的后退功能,但是可以删除文本内容 document.onkeyd ...
- NSMutableParagraphStyle /NSParagraphStyle
// NSParagraphStyleAttributeName 段落的风格(设置首行,行间距,对齐方式什么的)看自己需要什么属性,写什么 NSMutableParagraphStyle *par ...