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

📄 1.htm

📁 遗传算法的详细描述文档,文档中附带一定的代码解释
💻 HTM
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://202.112.20.132"><font face="黑体"><big><big>白云黄鹤★</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center">                     遗传算法                                                   </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p   align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="100" align="center" valign="top"><br><p align="center">[<a href="index.htm">回到开始</a>][<a href="index.htm">上一层</a>][<a href="2.htm">下一篇</a>]
<hr><p align="left"><small>发信人: coy (我爱美好哦), 信区: Algorithm <br>

标  题: 遗传算法(1) <br>

发信站: 武汉白云黄鹤站 (Wed May 31 21:37:03 2000), 站内信件 <br>

  <br>

先前答应了人家,现在兑现,呵呵。 <br>

这一篇是说明。 <br>

                             COPYRIGHT NOTICE <br>

This software is copyright by Zbigniew Michalewicz. Permission is <br>

granted to copy and use the software for scientific, noncommercial <br>

purposes only. The software is provided "as is", i.e., without any <br>

warranties. <br>

                              GENERAL REMARKS <br>

The Genocop system aims at finding a global optimum (minimum or <br>

maximum: this is one of the input parameters) of a function; <br>

additional linear constraints (equations and inequalities) can <br>

be specified as well. <br>

This is a first version of Genocop system (version 1.0); it is meant to be <br>

a pre-release only. This version was implemented by one of my master <br>

students, Swarnalatha Swaminathan. <br>

Next versions would aim at better user interfaces <br>

and at improving usability of the system (different termination conditions, <br>

declaring integer and boolean variables, etc.). In summer 1993 I plan also <br>

to release Genocop II, which would handle nonlinear constraints as well. <br>



The system is based on the article "GENOCOP: A Genetic Algorithm for <br>

Numerical Optimization with Linear Constraints" accepted for publication <br>

in the Communications of the ACM. The paper was accepted there in <br>

April 1991 (16 months ago) and until today the editors of CACM did not <br>

schedule it in the coming issues of the journal. However, the article <br>

was incorporated (with a permission from the ACM) into one of the chapters <br>

of my new book "Genetic Algorithms + Data Structures = Evolution Programs" <br>

(Springer Verlag, August 1992). <br>

The current version of Genocop should run without changes on any BSD-UN*X <br>

system (preferably on a Sun SPARC machine). Note, however, that the <br>

system was NOT designed with portability in mind, i.e., the partability <br>

was not the main factor in the design process. <br>

                        HOW TO RUN THE GENOCOP SYSTEM <br>

To run the genocop system, there are four simple steps to follow: <br>

(1) prepare input file, say, "your_input", <br>

(2) incorporate the function in the eval.c file, <br>

(3) type "make", <br>

(4) type "genocop your_input your_output" ("your_output" is the name <br>

    of the output file provided by you). <br>

A simple example follows. The input file of this example is the <br>

transferred file "input" you have now in your directory, the typical <br>

output is present in the file "output". The function is already <br>



incorporated in the file "eval.c". <br>

In the example we try to maximize a function of 4 variables: <br>

  X[1]*sin(X[2]) + X[3]*X[3] -12.7*X[4] <br>

(NOTE: indexes of variables start from one, and not zero). <br>

Additional requirements are: <br>

one linear equality: <br>

    2*X[1] + X[2] - 3.5*X[4]  =  1 <br>

two linear inequalities: <br>

    X[2] + X[3]   <=  3.00 <br>

    X[1] - 2*X[2] <=  0.00 <br>

Also: <br>

 1.00   <=  X1   <=    8.00 <br>

 0.00   <=  X2   <=    8.00 <br>

-2.10   <=  X3   <=    3.10 <br>

 0.00   <=  X4   <=    4.40 <br>

The input file "input" is as follows (see file "input"): <br>

___________________________________________________ <br>

4 1  2 4 <br>

2.0     1.0     0.0     -3.5     1.0 <br>

0.0     1.0     1.0      0.0     3.0 <br>

1.0    -2.0     0.0      0.0     0.0 <br>

1.0 1 8.0 <br>

1.0 1 8.0 <br>

0.0 2 8.0 <br>

-2.1 3 3.1 <br>

0.0 4 4.4 <br>

70 500 <br>

4 4 4 4 4 8 <br>

0.2 <br>

1 <br>

2 <br>

0.25 <br>

10 <br>

___________________________________________________ <br>

Explanations (line by line) of the input file: <br>

4 1  2 4 <br>

These four integers have the following meaning (in order): <br>

number of variables, <br>

number of equalities, <br>

number of inequalities, <br>

number of domains specified. <br>

The next line: <br>

2.0     1.0     0.0     -3.5     1.0 <br>

represents the equation: <br>

 2*X[1] + X[2] - 3.5*X[4]  =  1; <br>



note, that for 4 variables you must provide 5 numbers (one for each variable <br>

and the additional one for a value of the right hand side of the equation). <br>

The next two lines: <br>

0.0     1.0     1.0      0.0     3.0 <br>

1.0    -2.0     0.0      0.0     0.0 <br>

represent two inequalities. NOTE, that all inequalities assume that <br>

left hand side is LESS OR EQUAL to the right hand side. In other words, <br>

to represent an inequality: <br>

       3.1*X[2] - 4.9*X[4] >= 12.1 <br>

you have to represent it as (assuming four variables): <br>

      0.0    -3.1     0.0     4.9    -12.1, i.e., <br>

      -3.1*X[2] + 4.9*X[4] <= -12.1 <br>

The next four lines of the input file: <br>

1.0 1 8.0 <br>

0.0 2 8.0 <br>

-2.1 3 3.1 <br>

0.0 4 4.4 <br>

describe domains of variables (the middle - integer - number of <br>

each line serves as an index of a variable). <br>

The line: <br>

70   500 <br>

indicate the population size (70) and the total number of generations (500). <br>



The next line: <br>

4 4 4 4 4 8 <br>

provides the frequencies of 6 operators (these are integers; their total <br>

should not exceed 50% of the population size). <br>

You can leave these frequencies as a standard set for all your <br>

experiments. <br>

The final lines of the input file are: <br>

0.2    (the coeficient q for cumulative probability distribution; <br>

        higher q values provide stronger selective pressure; <br>

        standard value 0.2 is already relatively high for a population <br>

        size 70). <br>

1      (1 is for maximization problem, 0 for minimization). <br>

2      (a parameter for non-uniform mutation; should stay as 2). <br>

0.25   (a parameter for arithmetical crossover, float between 0 and 1). <br>

10     (a parameter for simple crossover, leave it as it is). <br>

EVALUATION FUNCTION: <br>

One of the transferred files is "eval.c". For our current example, <br>

it is: <br>

_____________________________________________________ <br>

#include "thesis.h" <br>

float evaluate(X) <br>

VECTOR X; <br>

VECTOR X; <br>

{ <br>

 return(X[1]*sin(X[2]) + X[3]*X[3] -12.7*X[4]); <br>

} <br>

_____________________________________________________ <br>

To provide any function, just replace return line with <br>

appropriate expression, note again that variables are: <br>

X[1], X[2], etc. <br>

If you change the function, you will have to retype "make". <br>

Now, everything is ready. Just type: <br>

% make <br>

and <br>

% genocop your_input your_ouput <br>

and (hopefully) you'll get your result. <br>

IMPORTANT REMARKS: <br>

(1) If the input file contains more than one equations, these equations <br>

    must be linearly independent (this is responsibility of the user). <br>

(2) There is a line in the thesis.h file: <br>

#define TRIES 100 <br>

The variable TRIES defined the number of attempts the Genocop system <br>

tries to find a feasible point in the search space. If successful, <br>

the system will run further. If not, the Genocop will prompt you <br>

for an initial point. <br>



OUTPUT: the output file is self-explanatory. After several control <br>

lines, you get the generation number and the current best value <br>

(for generations, where there is an improvement). <br>

This is followed by the final population. <br>

FINAL NOTICE: It is quite likely that there are some bugs in the system; <br>

              please, report them to zbyszek@mosaic.uncc.edu. <br>

              I will try to take care of them in the next version (1.1). <br>

I hope these remarks would be sufficient to experiment with the system. <br>

Happy optimizing, <br>

Zbigniew Michalewicz <br>

****************************************************************************** <br>

* Mail: Department of Computer Science      E-mail: zbyszek@mosaic.uncc.edu  * <br>

*       University of North Carolina        Phone:  (704) 547-4873           * <br>

*       Charlotte, NC 28223                 Fax:    (704) 547-2352           * <br>

****************************************************************************** <br>

  <br>

  <br>

  <br>

-- <br>

                              ○ <br>

                             <//> <br>

                             /\ <br>

FINAL NOTICE: It is quite likely that there are some bugs in the system; <br>

              please, report them to zbyszek@mosaic.uncc.edu. <br>

              I will try to take care of them in the next version (1.1). <br>

I hope these remarks would be sufficient to experiment with the system. <br>

Happy optimizing, <br>

Zbigniew Michalewicz <br>

****************************************************************************** <br>

* Mail: Department of Computer Science      E-mail: zbyszek@mosaic.uncc.edu  * <br>

*       University of North Carolina        Phone:  (704) 547-4873           * <br>

*       Charlotte, NC 28223                 Fax:    (704) 547-2352           * <br>

****************************************************************************** <br>

  <br>

  <br>

  <br>

-- <br>

                              ○ <br>

                            \○/ <br>

                              ┃ <br>

                             /\ <br>

                    脖子扭扭,屁股扭扭,大家一起来跳舞 <br>

  <br>

※ 来源:.武汉白云黄鹤站 bbs.whnet.edu.cn.[FROM: 211.69.196.11] <br>

[阅读精华区资料]  结束Q, ← │ 上一项资料 U,↑│ 下一项资料 <Enter>,<Space>,↓ <br>

</small><hr>
<p align="center">[<a href="index.htm">回到开始</a>][<a href="index.htm">上一层</a>][<a href="2.htm">下一篇</a>]
<p align="center"><a href="http://cterm.163.net">欢迎访问Cterm主页</a></p>
</table>
</body>
</html>屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯

⌨️ 快捷键说明

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