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

📄 change_order.c

📁 很好的一个约束遗传算法优化程序
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "genocop.h"/********************************************************************************//*                                                                              *//*           FUNCTION NAME     :   get_var_order()                              *//*                                                                              *//*           SYNOPSIS          :   void get_var_order(tot,cart,var_order)       *//*                                                                              *//*           DESCRIPTION       :   This function changes the order of the       *//*                                  variables, by placing the group of variables*//*                                  that form the `p' variables to be eliminated*//*                                  first, followed by the remaining variables  *//*                                                                              *//*           FUNCTIONS CALLED  :   None                                         *//*                                                                              *//*           CALLING FUNCITONS :   main()                                       *//*                                                                              *//*           AUTHOR            :   Swarnalatha Swaminathan                      *//*                                                                              *//*           DATE              :   1/17/92                                      *//*                                                                              *//*                                                                              *//*           REV            DATE            BY           DESCRIPTION            *//*           ---            ----            --           -----------            *//*                                                                              *//*                                                                              *//********************************************************************************/void get_var_order(tot, cart, var_order)    IVECTOR         tot,		    /* array with total number of					     * variables and equalities */                    cart;		    /* array with the subscript of					     * the variables to be eliminated */    IMATRIX         var_order;		    /* matrix with the variables in					     * one column and a tag in the */ /* other to identify as to whether it is to be eliminated */ /* or not */{    int             i, in_val;    for (i = 1; i <= tot[0]; i++)    {	var_order[i][1] = i;	var_order[i][2] = 0;    }    printf("\n%d variables can be eliminated out of %d.", tot[1], tot[0]);    printf("\nPlease enter the chosen ones below.\n\n");    for (i = 1; i <= tot[1]; i++)    {	do	{	    printf("Enter index (subscript) of variable %d to be eliminated :", i);	    scanf("%d", &in_val);	    if ((in_val < 1) || (in_val > tot[0]))		printf("\nInvalid subscript.  Must be in the range 1 to %d\n", tot[0]);	} while ((in_val < 1) || (in_val > tot[0]));	printf("Value %d accepted.\n", in_val);	var_order[in_val][2] = 1;	/* var_order[cart[i]][2] = 1; */    }}/********************************************************************************//*                                                                              *//*           FUNCTION NAME     :   find_x1_x2()                                 *//*                                                                              *//*           SYNOPSIS          :   void find_x1_x2(tot,var_order,eq_co,x1,x2)   *//*                                                                              *//*           DESCRIPTION       :   This function splits the original vector of  *//*                                  variables into x1 and x2, where x1 consists *//*                                  of the 'p' variables to be eliminated and   *//*                                  x2 consists of the remaining variables      *//*                                                                              *//*           FUNCTIONS CALLED  :   None                                         *//*                                                                              *//*           CALLING FUNCITONS :   main()                                       *//*                                                                              *//*           AUTHOR            :   Swarnalatha Swaminathan                      *//*                                                                              *//*           DATE              :   1/17/92                                      *//*                                                                              *//*                                                                              *//*           REV            DATE            BY           DESCRIPTION            *//*           ---            ----            --           -----------            *//*                                                                              *//*                                                                              *//********************************************************************************/void find_x1_x2(tot, var_order, x1, x2)    int             tot;		    /* total number of variables */    IMATRIX         var_order;		    /* array of variables with tag					     * identifying them */ /* to be eliminated */    IVECTOR         x1,			    /* array of variables to be					     * eliminated */                    x2;			    /* array of remaining variables */{    int             i, j = 1, k = 1;    for (i = 1; i <= tot; i++)    {	if (var_order[i][2] == 1)	    x1[j++] = var_order[i][1];	else	    x2[k++] = var_order[i][1];    }}/********************************************************************************//*                                                                              *//*           FUNCTION NAME     :   find_ac1_ac2()                               *//*                                                                              *//*           SYNOPSIS          :   void find_ac1_ac2(t1,t2,t3,x1,x2,mat,ac1,ac2)*//*                                                                              *//*           DESCRIPTION       :   This function splits the original equality   *//*                                  or the inequality matrix into two matrices; *//*                                  the p-equalities or the inequalities and the*//*                                  remaining part of the matrix                *//*                                                                              *//*           FUNCTIONS CALLED  :   None                                         *//*                                                                              *//*           CALLING FUNCITONS :   main()                                       *//*                                                                              *//*           AUTHOR            :   Swarnalatha Swaminathan                      *//*                                                                              *//*           DATE              :   1/17/92                                      *//*                                                                              *//*                                                                              *//*           REV            DATE            BY           DESCRIPTION            *//*           ---            ----            --           -----------            *//*                                                                              *//*                                                                              *//********************************************************************************/void find_ac1_ac2(t1, t2, t3, x1, x2, mat, ac1, ac2)    int             t1, t2, t3;    IVECTOR         x1, x2;		    /* the variables corresponding to					     * the split matrices */    MATRIX          mat,		    /* the original matrix to be					     * split */                    ac1, ac2;		    /* the split matrices */{    int             i, j, k;    for (i = 1; i <= t1; i++)	for (j = 1; j <= t2; j++)	    ac1[j][i] = mat[j][x1[i]];    for (i = 1; i <= t3; i++)	for (j = 1; j <= t2; j++)	    ac2[j][i] = mat[j][x2[i]];}/********************************************************************************//*                                                                              *//*           FUNCTION NAME     :   find_lu1_lu2()                               *//*                                                                              *//*           SYNOPSIS          :   void find_lu1_lu2_(tot,x1,x2,dom,dom1,dom2)  *//*                                                                              *//*           DESCRIPTION       :   This function splits the lower or the upper  *//*                                  bounds of the total domain constraints into *//*                                  two groups, one with the domain constraints *//*                                  for the variables to be eliminated and the  *//*                                  other one for the remaining variables       *//*                                                                              *//*           FUNCTIONS CALLED  :   None                                         *//*                                                                              *//*           CALLING FUNCITONS :   main()                                       *//*                                                                              *//*           AUTHOR            :   Swarnalatha Swaminathan                      *//*                                                                              *//*           DATE              :   1/17/92                                      *//*                                                                              *//*                                                                              *//*           REV            DATE            BY           DESCRIPTION            *//*           ---            ----            --           -----------            *//*                                                                              *//*                                                                              *//********************************************************************************/void find_lu1_lu2(tot, x1, x2, dom, dom1, dom2)    IVECTOR         tot, x1, x2;    VECTOR          dom,		    /* the original array of the					     * lower or the upper bounds */                    dom1, dom2;		    /* the original bounds split in					     * to two groups */{    int             i, j, k;    for (i = 1; i <= tot[1]; i++)	dom1[i] = dom[x1[i]];    for (i = 1; i <= tot[0] - tot[1]; i++)	dom2[i] = dom[x2[i]];}/********************************************************************************//*                                                                              *//*           FUNCTION NAME     :   find_limits()                                *//*                                                                              *//*           SYNOPSIS          :   void find_limits(tot,domains,llim,ulim)      *//*                                                                              *//*           DESCRIPTION       :   This function forms seperate arrays for the  *//*                                  lower and upper limits of the domains from  *//*                                  the original domain constraints read already*//*                                  from the input file                         *//*                                                                              *//*           FUNCTIONS CALLED  :   None                                         *//*                                                                              *//*           CALLING FUNCITONS :   main()                                       *//*                                                                              *//*           AUTHOR            :   Swarnalatha Swaminathan                      *//*                                                                              *//*           DATE              :   1/17/92                                      *//*                                                                              *//*                                                                              *//*           REV            DATE            BY           DESCRIPTION            *//*           ---            ----            --           -----------            *//*                                                                              *//*                                                                              *//********************************************************************************/void find_limits(tot, domains, llim, ulim)    int             tot;    MATRIX          domains;		    /* matrix containing the domain					     * variables and the limits */    VECTOR          llim, ulim;		    /* vectors of lower and upper					     * limits */{    int             i;    for (i = 1; i <= tot; i++)    {	llim[i] = domains[i][1];	ulim[i] = domains[i][3];    }}/********************************************************************************//*                                                                              *//*           FUNCTION NAME     :   find_new_in_eq()                             *//*                                                                              *//*           SYNOPSIS          :   void find_new_in_eq(a1b.a1a2,ll,ul,rc,newin) *//*                                                                              *//*           DESCRIPTION       :   This function converts the original          *//*                                  equality constraints into domain            *//*                                  constraints eliminating the p-equalities    *//*                                                                              *//*           FUNCTIONS CALLED  :   None                                         *//*                                                                              *//*           CALLING FUNCITONS :   main()                                       *//*                                                                              *//*           AUTHOR            :   Swarnalatha Swaminathan                      *//*                                                                              */

⌨️ 快捷键说明

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