资源简介
SPEA2是多目标进化算法的经典程序,对于DTLZ序列测试函数有较好的求解性能。
代码片段和文件信息
/*========================================================================
PISA (www.tik.ee.ethz.ch/pisa/)
========================================================================
Computer Engineering (TIK)
ETH Zurich
========================================================================
SPEA2 - Strength Pareto EA 2
Implementation in C for the selector side.
Implements Petri net.
file: spea2.c
author: Marco Laumanns laumanns@tik.ee.ethz.ch
revision by: Stefan Bleuler bleuler@tik.ee.ethz.ch
last change: $date$
========================================================================
*/
/* CAUTION: is not standard C
It is used only for sleep() and usleep() in wait().
In Windows use Sleep() in or implement busy waiting.
*/
#include
#include
#include
#include
#include “spea2.h“
#ifdef PISA_UNIX
#include
#endif
#ifdef PISA_WIN
#include
#endif
/*------------------------------| main() |-------------------------------*/
int main(int argc char* argv[])
{
/* command line parameters */
char paramfile[FILE_NAME_LENGTH]; /* file with local parameters */
char filenamebase[FILE_NAME_LENGTH]; /* filename base
e.g. “dir/test.“ */
double poll = 1.0; /* polling interval in seconds */
/* other variables */
int state = -1;
char statefile[FILE_NAME_LENGTH];
int result;
/* reading command line parameters */
if (argc != 4)
PISA_ERROR(“Selector: wrong number of arguments“);
sscanf(argv[1] “%s“ paramfile);
sscanf(argv[2] “%s“ filenamebase);
sscanf(argv[3] “%lf“ &poll);
/* generate name of statefile */
sprintf(statefile “%ssta“ filenamebase);
/* main loop */
while (state != 6) /* stop state for selector */
/* Caution: if reading of the statefile fails
(e.g. no permission) this is an infinite loop */
{
state = read_flag(statefile);
if (state == 1) /* inital selection */
{
initialize(paramfile filenamebase);
result = read_ini(); /* read ini file */
if (result == 0) /* reading ini file successful */
{
select_initial(); /* do selection */
write_arc(); /* write arc file (all individuals
that could ever be used again) */
write_sel(); /* write sel file */
state = 2;
write_flag(statefile state);
} /* else don‘t do anything and wait again */
}
else if (state == 3) /* selection */
{
if(check_arc() == 0 && check_sel() == 0)
{
result = read_var(); /*
- 上一篇:STM32F103ZET6原理图及pcb.rar
- 下一篇:电子商务的发展外文翻译
评论
共有 条评论