gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 05:31:34 24 4
gpt4 key购买 nike

我想在 Microsoft Visual Studio 2012 下运行以下 C++ 库(自 2010 年起):

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

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

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

在 neat.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;,我什么都不会改变;

有人已经使用过这个库并且能够在 visual studio 下运行它吗?

最好的问候塞比

最佳答案

基本错误

error C4703: potentially uninitialized local pointer variable

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

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

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

使用 NEAT 解决极平衡任务时会出现其他错误。它们可能被视为 NEAT 用法的示例。

Has Someone already used this library and was able to run this under visual studio?

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

You can check my solution here

非本质错误

error C3861: 'lrand48': identifier not found

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

error C2133: 'evals' : unknown size

int evals[NEAT::num_runs]; - 仅当 NEAT::num_runsconst 时,您才能在 Visual C++ 中使用它。 num_runs 的值必须为编译器所知。

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

关于c++ - NEAT C++ 编译器错误 Microsoft Visual Studio 2012,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35526227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com