Multi-Objective genetic algorithm------NSGA-II (partial source parsing) Two individual domination judgment dominance.c

Source: Internet
Author: User

1 /*Domination checking Routines*/2 3# include <stdio.h>4# include <stdlib.h>5# include <math.h>6 7# include"global.h"8# include"rand.h"9 Ten /*Routine for usual non-domination checking One It'll return the following values A 1 If a dominates B - -1 If B dominates a - 0 if both A and B are non-dominated*/ the  - intCheck_dominance (Individual *a, individual *b) - { -     inti; +     intFlag1; -     intFlag2; +Flag1 =0; AFlag2 =0; at     if(a->constr_violation<0&& b->constr_violation<0) -     { -         if(A->constr_violation > b->constr_violation) -         { -             return(1); -         } in         Else -         { to             if(A->constr_violation < b->constr_violation) +             { -                 return(-1); the             } *             Else $             {Panax Notoginseng                 return(0); -             } the         } +     } A     Else the     { +         if(A->constr_violation <0&& B->constr_violation = =0) -         { $             return(-1); $         } -         Else -         { the             if(A->constr_violation = =0&& B->constr_violation <0) -             {Wuyi                 return(1); the             } -             Else Wu             { -                  for(i=0; i<nobj; i++) About                 { $                     if(A->obj[i] < b->Obj[i]) -                     { -Flag1 =1; -  A                     } +                     Else the                     { -                         if(A->obj[i] > b->Obj[i]) $                         { theFlag2 =1; the                         } the                     } the                 } -                 if(flag1==1&& flag2==0) in                 { the                     return(1); the                 } About                 Else the                 { the                     if(flag1==0&& flag2==1) the                     { +                         return(-1); -                     } the                     ElseBayi                     { the                         return(0); the                     } -                 } -             } the         } the     } the}

The above code is to determine the dominance of two individuals.

Basically follow the two principles, the first is to determine whether two individuals are beyond the limit, that is, to determine the size of constr_violation.

If the individual does not exceed the limit , the individual's constr_violation >= 0, and the default value of Constr_violation is 0.

Then judge the dominant relationship between the two individuals.

The above code basically means, first of all, to determine whether two individuals exceed the limit , that is, constr_violation<0, if an individual exceeds the limit, the other has not exceeded the direct selection of individuals not exceeding the limit.

If two individuals exceed the limit, the individuals who exceed the limit are selected, i.e. constr_violation larger individuals.

If two individuals exceed the limit and the constr_violation is equal, then two individuals are judged to have no control over each other.

If none of the two individuals exceeds the limit, the dominant relationship of two individuals is judged. The specific operation here is to determine the size of each of the two individual target function values,

If the objective function of a individual has less than B, flag1==1. If the objective function of the B individual has less than a individual, flag2==1.

If Flag1==1 flag2==0, then a dominates B.

If Flag1==0 flag2==1, then B dominates a.

If Flag1==1 flag2==1, then a B does not dominate.

Multi-Objective genetic algorithm------NSGA-II (partial source parsing) Two individual domination judgment dominance.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.