NEAT C++ Visual Studio 2012 Microsoft编译器错误

NEAT C++ Compiler errors Microsoft Visual Studio 2012

本文关键字:Microsoft 编译器 错误 2012 Studio C++ Visual NEAT      更新时间:2023-10-16

我想在Visual Studio 2012下运行以下C++库(从2010年开始Microsoft):

http://nn.cs.utexas.edu/?neat-c

我已经修复了很多编译器错误,但对于某些问题,我找不到解决方案。编译器错误为:

1>------ Build started: Project: My_Neuronal_Network, Configuration: Debug Win32 ------
1>  species.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(454): warning C4101: 'spin' : unreferenced local variable
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(433): warning C4101: 'pause' : unreferenced local variable
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(453): warning C4101: 'marble' : unreferenced local variable
1>  population.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(71): warning C4101: 'count' : unreferenced local variable
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(432): warning C4101: 'pause' : unreferenced local variable
1>  genome.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1777): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1790): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1795): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1845): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1862): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1884): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1888): warning C4018: '<' : signed/unsigned mismatch
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1961): warning C4101: 'p1innov' : unreferenced local variable
1>  experiments.cpp
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(52): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(52): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(52): error C2133: 'evals' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(53): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(53): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(53): error C2133: 'genes' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(54): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(54): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(54): error C2133: 'nodes' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(316): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(316): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(316): error C2133: 'runs' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(512): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(513): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(514): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(515): error C3861: 'lrand48': identifier not found
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(573): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(575): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(580): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(581): warning C4305: 'initializing' : truncation from 'double' to 'const float'
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(623): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(623): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(623): error C2133: 'record' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(625): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(625): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(625): error C2133: 'genesrec' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(627): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(627): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(627): error C2133: 'nodesrec' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(629): error C2057: expected constant expression
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(629): error C2466: cannot allocate an array of constant size 0
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(629): error C2133: 'winnergens' : unknown size
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(692): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1experiments.cpp(706): warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
1>  Generating Code...
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(543): error C4703: potentially uninitialized local pointer variable 'bias' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1948): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1533): error C4703: potentially uninitialized local pointer variable 'newnode' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep1' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1777): error C4703: potentially uninitialized local pointer variable 'nodep2' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1808): error C4703: potentially uninitialized local pointer variable 'newgene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1531): error C4703: potentially uninitialized local pointer variable 'newgene1' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(1532): error C4703: potentially uninitialized local pointer variable 'newgene2' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(2500): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(2151): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1genome.cpp(2794): error C4703: potentially uninitialized local pointer variable 'chosengene' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(90): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(289): error C4703: potentially uninitialized local pointer variable 'new_genome' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1population.cpp(546): error C4703: potentially uninitialized local pointer variable 'best_species' used
1>c:userssebidesktopneuroevolutionneat.1.2.1neat.1.2.1species.cpp(89): error C4703: potentially uninitialized local pointer variable 'thechamp' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

整齐地.cpp定义了以下内容:

%neat.cpp
...
int NEAT::num_runs = 1;
...

第一个错误发生在:

%experiments.cpp
 int evals[NEAT::num_runs];  //Hold records for each run 

所以不知何故,这个值不是恒定的。如果我使用 const int NEAT::num_runs=1,我什么都不会改变;

是否有人已经使用过这个库并能够在可视化工作室下运行它?

此致敬意塞比

基本错误

error C4703: potentially uninitialized local pointer variable

此错误仅通过使用 NULL 初始化变量来解决。但实际上这不是错误,它是警告,可能会在项目设置中关闭。

genome.cpp, population.cpp, species.cpp中发生错误

所以 C4703 只是错误NEAT 实现的重要组成部分,这意味着它可以很容易地用 Visual C++ 编译。

在使用NEAT解决极平衡任务时会发生其他错误。它们可以被视为使用NEAT的示例。

是否有人已经使用过这个库并能够在可视化工作室下运行它?

我已经将NEAT提取到静态链接库,该库可用于其他Visual Studio项目。解决方案中还有第二个项目作为使用 NEAT.lib 的示例

你可以在这里查看我的解决方案

非本质错误

error C3861: 'lrand48': identifier not found

只需在 VisualC++ 中使用 rand()。

error C2133: 'evals' : unknown size

int evals[NEAT::num_runs]; - 只有在const NEAT::num_runs 时,才能在 Visual C++ 中使用它。编译器必须知道num_runs的值。

int *evalsPtr = new int[NEAT::num_runs]; - 在其他情况下使用此