Multi-Objective genetic algorithm------NSGA-II (partial source parsing) Status report print Report.c

Source: Internet
Author: User

1 /*Routines for storing population data into files*/2 3# include <stdio.h>4# include <stdlib.h>5# include <math.h>6 7# include"global.h"8# include"rand.h"9 Ten /*Function to print the information of a population in a file*/ One voidReport_pop (population *pop, FILE *FPT) A { -     intI, J, K; -      for(i=0; i<popsize; i++) the     { -          for(j=0; j<nobj; J + +) -         { -fprintf (FPT,"%e\t",pop->ind[i].obj[j]); +         } -         if(ncon!=0) +         { A              for(j=0; j<ncon; J + +) at             { -fprintf (FPT,"%e\t",pop->ind[i].constr[j]); -             } -         } -         if(nreal!=0) -         { in              for(j=0; j<nreal; J + +) -             { tofprintf (FPT,"%e\t",pop->ind[i].xreal[j]); +             } -         } the         if(nbin!=0) *         { $              for(j=0; j<nbin; J + +)Panax Notoginseng             { -                  for(k=0; k<nbits[j]; k++) the                 { +fprintf (FPT,"%d\t",pop->ind[i].gene[j][k]); A                 } the             } +         } -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; the } - Wuyi /*Function to print the information of feasible and non-dominated population in a file*/ the voidReport_feasible (population *pop, FILE *FPT) - { Wu     intI, J, K; -      for(i=0; i<popsize; i++) About     { $         if(Pop->ind[i].constr_violation = =0.0&& pop->ind[i].rank==1) -         { -              for(j=0; j<nobj; J + +) -             { Afprintf (FPT,"%e\t",pop->ind[i].obj[j]); +             } the              if(ncon!=0) -             { $                  for(j=0; j<ncon; J + +) the                 { thefprintf (FPT,"%e\t",pop->ind[i].constr[j]); the                 } the             } -             if(nreal!=0) in             { the                  for(j=0; j<nreal; J + +) the                 { Aboutfprintf (FPT,"%e\t",pop->ind[i].xreal[j]); the                 } the             } the             if(nbin!=0) +             { -                  for(j=0; j<nbin; J + +) the                 {Bayi                      for(k=0; k<nbits[j]; k++) the                     { thefprintf (FPT,"%d\t",pop->ind[i].gene[j][k]); -                     } -                 } the             } thefprintf (FPT,"%e\t",pop->ind[i].constr_violation); thefprintf (FPT,"%d\t",pop->Ind[i].rank); thefprintf (FPT,"%e\n",pop->ind[i].crowd_dist); -         } the     } the     return; the}

Report_pop the target function value of all the individuals in the population, limiting the condition value, and printing the encoded value.

Report_pop the object function value of the individual in the population of the non-dominant entity and limiting the sum of the conditions to 0 (constr_violation = = 0.0) , limiting the condition value, The encoded value is printed out.

Multi-Objective genetic algorithm------NSGA-II (partial source parsing) Status report print report.c

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.