display.c

来自「nsga2具体算法代码,用来多目标遗传算法的学习和研究」· C语言 代码 · 共 47 行

C
47
字号
/* Routines to display the population information using gnuplot */# include <stdio.h># include <stdlib.h># include <math.h># include <string.h># include <unistd.h># include "global.h"# include "rand.h"/* Function to display the current population for the subsequent generation */void onthefly_display (population *pop, FILE *gp, int ii){    int i;    int flag;    FILE *fpt;    fpt = fopen("plot.out","w");    flag = 0;    for (i=0; i<popsize; i++)    {        if (pop->ind[i].constr_violation==0)        {            if (choice!=3)                fprintf(fpt,"%e\t%e\n",pop->ind[i].obj[obj1-1],pop->ind[i].obj[obj2-1]);            else                fprintf(fpt,"%e\t%e\t%e\n",pop->ind[i].obj[obj1-1],pop->ind[i].obj[obj2-1],pop->ind[i].obj[obj3-1]);            fflush(fpt);            flag = 1;        }    }    if (flag==0)    {        printf("\n No feasible soln in this pop, hence no display");    }    else    {        if (choice!=3)            fprintf(gp,"set title 'Generation #%d'\n unset key\n plot 'plot.out' w points pointtype 6 pointsize 1\n",ii);        else            fprintf(gp,"set title 'Generation #%d'\n set view %d,%d\n unset key\n splot 'plot.out' w points pointtype 6 pointsize 1\n",ii,angle1,angle2);        fflush(gp);    }    fclose(fpt);    return;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?