⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 non_domination_sort_initialize.c

📁 多目标算法的DSP实现。可以直接在DSP平台上进行多目标优化
💻 C
字号:
# include <stdio.h>
# include <math.h>

# include "malloc.h"
# include "global.h"

//# include "check_dominance.c"
//# include "crowding_distance.c"
//# include "list.c"// 对初始化群体进行非支配解排序并计算拥挤距离void non_domination_sort_and_crowding_distance (population *new_pop){    int flag;    int i;    int end;    int front_size;    int rank = 1;    list *orig;    list *cur;    list *temp1, *temp2;    orig = (list *)malloc(sizeof(list));    cur = (list *)malloc(sizeof(list));    front_size = 0;    orig->index = -1;    orig->prior = NULL;    orig->next = NULL;    cur->index = -1;    cur->prior = NULL;    cur->next = NULL;    temp1 = orig;    for (i=0; i<POPSIZE; i++)    {        insert (temp1, i);        temp1 = temp1->next;    }    do    {        if (orig->next->next == NULL)        {            new_pop->ind[orig->next->index].rank = rank;            new_pop->ind[orig->next->index].crowd_dist = INF;            break;        }        temp1 = orig->next;        insert (cur, temp1->index);        front_size = 1;        temp2 = cur->next;        temp1 = del (temp1);        temp1 = temp1->next;        do        {            temp2 = cur->next;            do            {                end = 0;                flag = check_dominance (&(new_pop->ind[temp1->index]), &(new_pop->ind[temp2->index]));                if (flag == 1)                {                    insert (orig, temp2->index);                    temp2 = del (temp2);                    front_size--;                    temp2 = temp2->next;                }                if (flag == 0)                {                    temp2 = temp2->next;                }                if (flag == -1)                {                    end = 1;                }            }            while (end != 1 && temp2 != NULL);            if (flag == 0 || flag == 1)            {                insert (cur, temp1->index);                front_size++;                temp1 = del (temp1);            }            temp1 = temp1->next;        }        while (temp1 != NULL);        temp2 = cur->next;        do        {            new_pop->ind[temp2->index].rank = rank;            temp2 = temp2->next;	        }        while (temp2 != NULL);        crowding_distance_list (new_pop, cur->next, front_size);        temp2 = cur->next;        do        {            temp2 = del (temp2);            temp2 = temp2->next;        }        while (cur->next !=NULL);        rank++;    }    while (orig->next!=NULL);    free (orig);    free (cur);    return;}

⌨️ 快捷键说明

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