【问题标题】:Error in Genetic Algorithm (Octave)遗传算法中的错误(八度)
【发布时间】:2016-03-09 21:04:31
【问题描述】:

我正在尝试用 octave 实现遗传算法。

我的代码是http://codepad.org/NeaWqa90

我收到以下错误:

>> run("a.m")
parse error near line 31 of file /home/teron/a.m

  nested functions not implemented in this context

>>> function [x,y]=crossover(x,y)
           ^
error: called from 'run' in file /usr/share/octave/4.0.0/m/miscellaneous/run.m near line 84, column 5
>>

我不知道如何解决这个错误

【问题讨论】:

  • 请在此处发布您的代码的相关部分,这样人们就不必为了获得必要的上下文而去其他网站(请注意,我并不是说发布您的整个程序,只是与错误相关的部分)。另外,你做了什么来试图解决这个错误?你说你不能,但没有说为什么。您是否进行过任何调试或其他问题的解决?
  • 另外,我现在标记这个,因为它属于调试请求的类别,没有足够的细节来说明与你得到的相比应该发生什么

标签: algorithm matlab compiler-errors octave genetic-algorithm


【解决方案1】:

错误信息相当丰富,即关于“嵌套函数”的部分。例如,下面给出了同样的错误。

function fun1
    function fun2
    end
end

将其保存到文本文件中(例如temp.m),然后运行它。

octave:2> run('temp.m')
parse error near line 3 of file /home/me/temp.m

  nested functions not implemented in this context

>>>     function fun2
               ^
error: called from 'run' in file /usr/share/octave/3.8.1/m/miscellaneous/run.m near line 80, column 5

我怀疑您在第 13 行附近遗漏了一个 end,但格式良好的代码将有很长的路要走。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-11
    • 2017-11-25
    • 2012-10-01
    • 2018-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-12
    相关资源
    最近更新 更多